first commit

This commit is contained in:
2026-09-02 16:31:50 +08:00
commit a461727193
911 changed files with 692450 additions and 0 deletions
@@ -0,0 +1,55 @@
<Page
x:Class="JSMachine.WMS.Storage.BusinessModules.Views.HomePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mvvm="http://prismlibrary.com/"
xmlns:customercontrols="clr-namespace:JSMachine.WMS.Common.CustomerControls;assembly=JSMachine.WMS.Common"
Title="HomePage"
d:DesignHeight="450"
d:DesignWidth="800"
mvvm:ViewModelLocator.AutoWireViewModel="True"
Loaded="Page_Loaded"
mc:Ignorable="d">
<Viewbox Stretch="Fill">
<Canvas
Grid.Row="1"
Width="1920"
Height="980"
VerticalAlignment="Top">
<!--<Border
Canvas.Left="5"
Canvas.Top="6"
Width="1910"
Height="40"
BorderBrush="#999999"
BorderThickness="0,0,0,2">
<WrapPanel
Name="ButtonContainer"
VerticalAlignment="Bottom"
Button.Click="TabClick"
Orientation="Horizontal">
<Button
x:Name="ButtonHome"
Content="{DynamicResource HomePage_Button_ButtonHome}"
Style="{StaticResource MenuButton}" />
<Button
x:Name="ButtonOrder"
Content="{DynamicResource HomePage_Button_ButtonOrder}"
Style="{StaticResource MenuButton}" />
</WrapPanel>
</Border>-->
<customercontrols:ConnectionStatusView
Grid.Row="2"
Grid.ColumnSpan="3"
Canvas.Top="20" Canvas.Right="30"
Background="Transparent" />
<ContentControl
x:Name="Page_Change"
Canvas.Left="5"
Canvas.Top="10"
Width="1920" />
</Canvas>
</Viewbox>
</Page>
@@ -0,0 +1,102 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using JSMachine.WMS.Storage.BusinessModules.Views;
using Prism.Events;
using Prism.Ioc;
using static JSMachine.WMS.Common.EventBus.HotKeyEventBus;
namespace JSMachine.WMS.Storage.BusinessModules.Views
{
/// <summary>
/// HomePage.xaml 的交互逻辑
/// </summary>
public partial class HomePage : Page
{
private static IEventAggregator _eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
public bool IsMainWindows { get; set; } = true;
private LinearGradientBrush ActiveBrush = new();
public HomePage()
{
InitializeComponent();
Init();
RegisterHotKey();
}
/// <summary>
/// 注册快捷键
/// </summary>
private void RegisterHotKey()
{
////没有权限点击的按钮不允许使用快捷键
//_eventAggregator.GetEvent<ProductionHomeHotKeyEvent>().Subscribe(() =>
//{
// if (this.ButtonHome.Visibility == Visibility.Visible && this.ButtonHome.IsEnabled)
// this.ButtonHome.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
//});
//_eventAggregator.GetEvent<OrderManageHotKeyEvent>().Subscribe(() =>
//{
// if (this.ButtonOrder.Visibility == Visibility.Visible && this.ButtonOrder.IsEnabled)
// this.ButtonOrder.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
//});
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
//Page_Change.Content = new ProductionHomeView() { };
ActiveBrush.StartPoint = new Point(0, 0);
ActiveBrush.EndPoint = new Point(0, 1);
ActiveBrush.Opacity = 1;
ActiveBrush.GradientStops.Add(new GradientStop(color: (Color)ColorConverter.ConvertFromString("#111111"), offset: 0));
ActiveBrush.GradientStops.Add(new GradientStop(color: (Color)ColorConverter.ConvertFromString("#999999"), offset: 0.5));
ActiveBrush.GradientStops.Add(new GradientStop(color: (Color)ColorConverter.ConvertFromString("#111111"), offset: 1));
}
public void Init()
{
//ButtonHome.Background = ActiveBrush;//主页默认选中黑色
//ButtonHome.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"));
}
public void TabClick(object sender, RoutedEventArgs e)
{
Button button = (Button)e.OriginalSource;
ShowButtonBlack();
button.Background = ActiveBrush;
button.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"));
switch (button.Name)
{
case "ButtonHome":
{
Page_Change.Content = new PaperStorageView() { };
};
break;
}
}
private void ShowButtonBlack()
{
LinearGradientBrush brush = new LinearGradientBrush();
brush.StartPoint = new Point(0, 0);
brush.EndPoint = new Point(0, 1);
brush.Opacity = 1;
brush.GradientStops.Add(new GradientStop(color: (Color)ColorConverter.ConvertFromString("#BBBBBB"), offset: 0));
brush.GradientStops.Add(new GradientStop(color: (Color)ColorConverter.ConvertFromString("#FFFFFF"), offset: 0.5));
brush.GradientStops.Add(new GradientStop(color: (Color)ColorConverter.ConvertFromString("#BBBBBB"), offset: 1));
//for (int i = 0; i < ButtonContainer.Children.Count; i++)
//{
// Button button = ButtonContainer.Children[i] as Button;
// button.Background = brush;
// button.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("Black"));
//}
}
}
}
@@ -0,0 +1,246 @@
<UserControl
x:Class="JSMachine.WMS.Storage.BusinessModules.Views.PaperStorageView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converter="clr-namespace:JSMachine.WMS.Common.Converter;assembly=JSMachine.WMS.Common"
xmlns:customercontrols="clr-namespace:JSMachine.WMS.Common.CustomerControls;assembly=JSMachine.WMS.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:JSMachine.WMS.Storage.BusinessModules.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mvvm="http://prismlibrary.com/"
Width="1920"
Height="980"
mvvm:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
<converter:DateTimeConverter x:Key="DateTimeConverter" />
<converter:PrintStateToStrConverter x:Key="PrintStateToStrConverter" />
</ResourceDictionary>
</UserControl.Resources>
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="8*" />
<RowDefinition Height="6*" />
<RowDefinition Height="90*" />
<RowDefinition Height="6*" />
</Grid.RowDefinitions>
<Button
Grid.Row="0"
Width="200"
Height="50"
HorizontalAlignment="Left"
Command="{Binding IAtuoPrintCmd}"
Content="新卷标签自动打印"
FontSize="20"
Style="{StaticResource MenuButton}" />
<WrapPanel Grid.Row="1">
<hc:DateTimePicker
x:Name="DateTimePickerStart"
Width="330"
Margin="0,0,0,5"
VerticalAlignment="Center"
hc:InfoElement.Title="开始时间"
hc:InfoElement.TitlePlacement="Left"
hc:InfoElement.TitleWidth="80"
Background="Transparent"
FontSize="18"
Foreground="#CC8"
SelectedDateTime="{Binding StartTime}"
SelectedDateTimeChanged="DateTimePickerStart_SelectedDateTimeChanged"
ShowClearButton="True"
Style="{StaticResource DateTimePickerPlus}" />
<hc:DateTimePicker
x:Name="DateTimePickerEnd"
Width="330"
Margin="20,0,0,5"
VerticalAlignment="Center"
hc:InfoElement.Title="结束时间"
hc:InfoElement.TitlePlacement="Left"
hc:InfoElement.TitleWidth="80"
Background="Transparent"
FontSize="18"
Foreground="#CC8"
SelectedDateTime="{Binding EndTime}"
SelectedDateTimeChanged="DateTimePickerEnd_SelectedDateTimeChanged"
ShowClearButton="True"
Style="{StaticResource DateTimePickerPlus}" />
<TextBox
x:Name="TxtPaperLabel"
Width="250"
Margin="20,0,0,5"
hc:InfoElement.Placeholder="请输入卷标"
hc:InfoElement.Title="原纸卷标"
hc:InfoElement.TitlePlacement="Left"
Background="Transparent"
FontSize="18"
Foreground="#CC8"
SelectionChanged="TxtPaperLabel_SelectionChanged"
Style="{StaticResource TextBoxExtend}"
Text="{Binding PaperLabel, UpdateSourceTrigger=PropertyChanged}" />
<TextBox
x:Name="TxtSupplier"
Width="250"
Margin="20,0,0,5"
hc:InfoElement.Placeholder="请输入供应商"
hc:InfoElement.Title="供应商"
hc:InfoElement.TitlePlacement="Left"
Background="Transparent"
FontSize="18"
Foreground="#CC8"
SelectionChanged="TxtSupplier_SelectionChanged"
Style="{StaticResource TextBoxExtend}"
Text="{Binding Supplier, UpdateSourceTrigger=PropertyChanged}" />
<TextBox
x:Name="TxtPaperCode"
Width="250"
Margin="20,0,0,5"
hc:InfoElement.Placeholder="请输入纸质"
hc:InfoElement.Title="纸质"
hc:InfoElement.TitlePlacement="Left"
Background="Transparent"
FontSize="18"
Foreground="#CC8"
SelectionChanged="TxtPaperCode_SelectionChanged"
Style="{StaticResource TextBoxExtend}"
Text="{Binding PaperCode, UpdateSourceTrigger=PropertyChanged}" />
<TextBox
x:Name="TxtPaperWidth"
Width="250"
Margin="20,0,0,5"
hc:InfoElement.Placeholder="请输入门幅"
hc:InfoElement.Title="门幅"
hc:InfoElement.TitlePlacement="Left"
Background="Transparent"
FontSize="18"
Foreground="#CC8"
SelectionChanged="TxtPaperWidth_SelectionChanged"
Style="{StaticResource TextBoxExtend}"
Text="{Binding PaperWidth, UpdateSourceTrigger=PropertyChanged}" />
</WrapPanel>
<DataGrid
Grid.Row="2"
Grid.RowSpan="2"
Width="Auto"
Height="760"
VerticalAlignment="Top"
AutoGenerateColumns="False"
Background="Transparent"
CanUserSortColumns="False"
DataGrid.CellStyle="{StaticResource DataGridCellStyle}"
DataGrid.RowStyle="{StaticResource DataGridRowStyle}"
DataGrid.Style="{StaticResource DataGridStyle}"
EnableRowVirtualization="True"
FontSize="20"
IsReadOnly="True"
ItemsSource="{Binding PaperNewStockIns}"
RowHeaderWidth="0"
SelectedItem="{Binding SelectedPaperNewStockIn}"
SelectionMode="Single"
VerticalScrollBarVisibility="Auto">
<DataGrid.ColumnHeaderStyle>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="FontWeight" Value="Bold" />
</Style>
</DataGrid.ColumnHeaderStyle>
<DataGrid.Columns>
<DataGridTextColumn
Width="0.6*"
Binding="{Binding PaperLabel}"
ElementStyle="{StaticResource DataGridTextStyle}"
Header="原纸卷标"
HeaderStyle="{StaticResource HeaderStyle}" />
<DataGridTextColumn
Width="*"
Binding="{Binding Supplier}"
ElementStyle="{StaticResource DataGridTextStyle}"
Header="供应商"
HeaderStyle="{StaticResource HeaderStyle}" />
<DataGridTextColumn
Width="0.4*"
Binding="{Binding PaperUnitWeight}"
ElementStyle="{StaticResource DataGridTextStyle}"
Header="克重"
HeaderStyle="{StaticResource HeaderStyle}" />
<DataGridTextColumn
Width="0.4*"
Binding="{Binding PaperCode}"
ElementStyle="{StaticResource DataGridTextStyle}"
Header="纸质"
HeaderStyle="{StaticResource HeaderStyle}" />
<DataGridTextColumn
Width="0.4*"
Binding="{Binding PaperWidth}"
ElementStyle="{StaticResource DataGridTextStyle}"
Header="门幅"
HeaderStyle="{StaticResource HeaderStyle}" />
<DataGridTextColumn
Width="*"
Binding="{Binding Memo}"
ElementStyle="{StaticResource DataGridTextStyle}"
Header="备注"
HeaderStyle="{StaticResource HeaderStyle}" />
<DataGridTextColumn
Width="0.4*"
Binding="{Binding PrintState, Converter={StaticResource PrintStateToStrConverter}}"
ElementStyle="{StaticResource DataGridTextStyle}"
Header="打印状态"
HeaderStyle="{StaticResource HeaderStyle}" />
<DataGridTextColumn
Width="0.8*"
Binding="{Binding PrintTime, Converter={StaticResource DateTimeConverter}}"
ElementStyle="{StaticResource DataGridTextStyle}"
Header="自动打印时间"
HeaderStyle="{StaticResource HeaderStyle}" />
<DataGridTextColumn
Width="0.8*"
Binding="{Binding CreationTime, Converter={StaticResource DateTimeConverter}}"
ElementStyle="{StaticResource DataGridTextStyle}"
Header="创建时间"
HeaderStyle="{StaticResource HeaderStyle}" />
<DataGridTemplateColumn
x:Name="Operation"
Width="0.4*"
Header="操作"
HeaderStyle="{StaticResource HeaderStyle}">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<Button
Height="45"
Width="100"
FontSize="20"
Background="#6893f7"
Command="{Binding DataContext.IHandPrintCmd, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
Content="打印标签"
Style="{StaticResource ButtonSuccess}"
Tag="{Binding Operation}" />
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<customercontrols:TurnPage
Grid.Row="3"
Grid.ColumnSpan="3"
Margin="0,8,0,0"
Background="Transparent" />
<Button
Grid.Row="0"
Width="200"
Height="50"
Margin="3,9,0,9"
HorizontalAlignment="Left"
Command="{Binding IAtuoPrintCmd}"
Content="新卷标签自动打印"
FontSize="20"
Style="{StaticResource MenuButton}" />
</Grid>
</UserControl>
@@ -0,0 +1,50 @@
using Prism.Events;
using System.Windows;
using System.Windows.Controls;
using Prism.Ioc;
using static JSMachine.WMS.Common.EventBus.GlobalEventBus;
namespace JSMachine.WMS.Storage.BusinessModules.Views
{
/// <summary>
/// PaperStorageView.xaml 的交互逻辑
/// </summary>
public partial class PaperStorageView : UserControl
{
IEventAggregator eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
public PaperStorageView()
{
InitializeComponent();
}
private void DateTimePickerStart_SelectedDateTimeChanged(object sender, HandyControl.Data.FunctionEventArgs<DateTime?> e)
{
eventAggregator.GetEvent<SearchStorageEvent>().Publish();
}
private void DateTimePickerEnd_SelectedDateTimeChanged(object sender, HandyControl.Data.FunctionEventArgs<DateTime?> e)
{
eventAggregator.GetEvent<SearchStorageEvent>().Publish();
}
private void TxtPaperLabel_SelectionChanged(object sender, RoutedEventArgs e)
{
eventAggregator.GetEvent<SearchStorageEvent>().Publish();
}
private void TxtSupplier_SelectionChanged(object sender, RoutedEventArgs e)
{
eventAggregator.GetEvent<SearchStorageEvent>().Publish();
}
private void TxtPaperCode_SelectionChanged(object sender, RoutedEventArgs e)
{
eventAggregator.GetEvent<SearchStorageEvent>().Publish();
}
private void TxtPaperWidth_SelectionChanged(object sender, RoutedEventArgs e)
{
eventAggregator.GetEvent<SearchStorageEvent>().Publish();
}
}
}
@@ -0,0 +1,51 @@
<Window
x:Class="JSMachine.WMS.Storage.BusinessModules.Views.PrintLabelWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:JSMachine.WMS.Storage.BusinessModules.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="标签打印"
Width="1000"
Height="600"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="860" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid Width="900" HorizontalAlignment="Left">
<WrapPanel HorizontalAlignment="Right">
<Label Content="打印机:" />
<ComboBox
x:Name="cbPrinters"
Width="230"
Height="23"
Margin="5"
HorizontalAlignment="Left"
VerticalAlignment="Top" />
<Button
x:Name="ButtonDesigner"
Click="ButtonDesigner_Click"
Content="模板编辑"
FontSize="15"
Style="{StaticResource ToolButton}" />
<Button
x:Name="ButtonClose"
Click="ButtonClose_Click"
Content="关闭窗体"
FontSize="15"
Style="{StaticResource ToolButton}" />
</WrapPanel>
</Grid>
</Grid>
<Grid Grid.Row="1">
<WindowsFormsHost x:Name="WindowsFornsHostDesignerControl" />
<WindowsFormsHost x:Name="WindowsFornsHostPreviewControl" />
</Grid>
<!--<Grid Grid.Row="2">
<WindowsFormsHost x:Name="WindowsFornsHostPreviewControl" />
</Grid>-->
</Grid>
</Window>
@@ -0,0 +1,243 @@
using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MessageBox = System.Windows.MessageBox;
using System.Windows.Threading;
using JSMachine.WMS.Infrastructure.AppConfiguration;
using JSMachine.WMS.Common;
using JSMachine.WMS.App.Dto;
using JSMachine.WMS.Infrastructure.Helper;
using JSMachine.WMS.App.Dto.Enum;
using static JSMachine.WMS.Common.EventBus.GlobalEventBus;
using Prism.Events;
using Prism.Ioc;
namespace JSMachine.WMS.Storage.BusinessModules.Views
{
/// <summary>
/// 标签打印window ,不使用prism
/// </summary>
public partial class PrintLabelWindow : System.Windows.Window
{
FastReport.Design.StandardDesigner.DesignerControl designerControl = new FastReport.Design.StandardDesigner.DesignerControl();
FastReport.Preview.PreviewControl prewControl = new FastReport.Preview.PreviewControl();
FastReport.Report fDesignerReport = new FastReport.Report(); //报表设计
FastReport.Report fPrewControlReport = new FastReport.Report();//报表预览
private string companyName = Global.AppSettings.CompanyName;
private IEventAggregator eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
private PrintType _printType;
public PrintType PrintType
{
get { return _printType; }
set { _printType = value; }
}
private PaperNewStockInDto _selectedPaperNewStockIn;
/// <summary>
/// 当前选中新卷入库信息
/// </summary>
public PaperNewStockInDto SelectedPaperNewStockIn
{
get { return _selectedPaperNewStockIn; }
set { _selectedPaperNewStockIn = value; }
}
/// <summary>
/// 当前选中进纸信息
/// </summary>
private PaperStockOutDto _selectePpaperStockOut;
public PaperStockOutDto SelectePpaperStockOut
{
get { return _selectePpaperStockOut; }
set { _selectePpaperStockOut = value; }
}
private PaperReStockInDto _selectedPaperReStockIn;
/// <summary>
/// 当前选中残卷入库信息
/// </summary>
public PaperReStockInDto SelectedPaperReStockIn
{
get { return _selectedPaperReStockIn ;}
set { _selectedPaperReStockIn = value;}
}
public PrintLabelWindow()
{
InitializeComponent();
GetPrinters(); //添加打印机下拉选项
eventAggregator.GetEvent<PrintLabelEvent>().Subscribe(PrinteLable);
}
/// <summary>
/// 添加打印机下拉选项
/// </summary>
private void GetPrinters()
{
var fPrinters = GetLocalPrinters();
if (fPrinters != null && fPrinters.Any())
{
foreach (var f in fPrinters)
{
cbPrinters.Items.Add(f);
}
cbPrinters.SelectedIndex = 0;
}
}
/// <summary>
/// 编辑模板
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonDesigner_Click(object sender, RoutedEventArgs e)
{
LoadFrxAndData(fDesignerReport, Environment.CurrentDirectory + Global.AppSettings.LabelReportFilePathStr);
designerControl.Report = fDesignerReport;//编辑模板
ControlVisibility(true, false);
}
/// <summary>
/// 打印选中标签
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonClose_Click(object sender, RoutedEventArgs e)
{
//PrinteLable(PrintType);
this.Close();
}
/// <summary>
/// 标签打印
/// </summary>
private void PrinteLable(PrintType printType)
{
try
{
PrintType= printType;
LoadFrxAndData(fPrewControlReport, Environment.CurrentDirectory + Global.AppSettings.LabelReportFilePathStr);
if (printType == PrintType.NewStock)
{
var paperCode = string.IsNullOrEmpty(SelectedPaperNewStockIn.PaperCode) ? "" : SelectedPaperNewStockIn.PaperCode.Replace("-", "");
fPrewControlReport.SetParameterValue("companyname", companyName);
fPrewControlReport.SetParameterValue("papercode", paperCode);
fPrewControlReport.SetParameterValue("supplier", SelectedPaperNewStockIn.Supplier);
fPrewControlReport.SetParameterValue("paperwidth", SelectedPaperNewStockIn.PaperWidth);
fPrewControlReport.SetParameterValue("weight", Convert.ToInt32(SelectedPaperNewStockIn.InWeight));
fPrewControlReport.SetParameterValue("paperlabel", SelectedPaperNewStockIn.PaperLabel);
fPrewControlReport.SetParameterValue("paperlength", Convert.ToInt32(SelectedPaperNewStockIn.MeterLength));
fPrewControlReport.SetParameterValue("unitweight", SelectedPaperNewStockIn.PaperUnitWeight);
}
else if (printType == PrintType.ReStock)
{
var paperCode = string.IsNullOrEmpty(SelectedPaperReStockIn.PaperCode) ? "" : SelectedPaperReStockIn.PaperCode.Replace("-", "");
fPrewControlReport.SetParameterValue("companyname", companyName);
fPrewControlReport.SetParameterValue("papercode", paperCode);
fPrewControlReport.SetParameterValue("supplier", SelectedPaperReStockIn.Supplier);
fPrewControlReport.SetParameterValue("paperwidth", SelectedPaperReStockIn.PaperWidth);
fPrewControlReport.SetParameterValue("weight", Convert.ToInt32(SelectedPaperReStockIn.InWeight));
fPrewControlReport.SetParameterValue("paperlabel", SelectedPaperReStockIn.PaperLabel);
fPrewControlReport.SetParameterValue("paperlength", Convert.ToInt32(SelectedPaperReStockIn.MeterLength));
fPrewControlReport.SetParameterValue("unitweight", SelectedPaperReStockIn.PaperUnitWeight);
}
else if (printType == PrintType.StockOut)
{
var paperCode = string.IsNullOrEmpty(SelectePpaperStockOut.PaperCode) ? "" : SelectePpaperStockOut.PaperCode.Replace("-", "");
fPrewControlReport.SetParameterValue("companyname", companyName);
fPrewControlReport.SetParameterValue("papercode", paperCode);
fPrewControlReport.SetParameterValue("supplier", SelectePpaperStockOut.Supplier);
fPrewControlReport.SetParameterValue("paperwidth", SelectePpaperStockOut.PaperWidth);
fPrewControlReport.SetParameterValue("weight", Convert.ToInt32(SelectePpaperStockOut.OutWeight));
fPrewControlReport.SetParameterValue("paperlabel", SelectePpaperStockOut.PaperLabel);
fPrewControlReport.SetParameterValue("paperlength", Convert.ToInt32(SelectePpaperStockOut.MeterLength));
fPrewControlReport.SetParameterValue("unitweight", SelectePpaperStockOut.PaperUnitWeight);
}
PrepareReprot(fPrewControlReport, prewControl);
ControlVisibility(false, true);
}
catch (Exception ex)
{
LogHelper.Error($"新卷入库:手动打印标签出错: {ex.Message} \n {ex.StackTrace}");
}
}
/// <summary>
/// 预览报表
/// </summary>
private void PrepareReprot(FastReport.Report report, FastReport.Preview.PreviewControl prewControl)
{
report.Preview = prewControl;
report.Prepare();
report.ShowPrepared();
}
/// <summary>
/// 载入报表路径和报表数据
/// </summary>
private void LoadFrxAndData(FastReport.Report report, string filePathStr)
{
//1 编辑指定路径下的frx,先load frx
report.Load(filePathStr);
}
/// <summary>
/// 报表设计与预览显示在同一个区域,每次只显示一个
/// </summary>
/// <param name="designerControlVisibility"></param>
/// <param name="designerControlVisibility"></param>
private void ControlVisibility(bool designerControlVisibility, bool previewControlVisibility)
{
if (designerControlVisibility == true && previewControlVisibility == false)
{
WindowsFornsHostPreviewControl.Visibility = Visibility.Collapsed;
WindowsFornsHostDesignerControl.Visibility = Visibility.Visible;
WindowsFornsHostDesignerControl.Child = designerControl;
}
else if (designerControlVisibility == false && previewControlVisibility == true)
{
WindowsFornsHostDesignerControl.Visibility = Visibility.Collapsed;
WindowsFornsHostPreviewControl.Visibility = Visibility.Visible;
WindowsFornsHostPreviewControl.Child = prewControl;
}
}
private static PrintDocument fPrintDocument = new PrintDocument();
private static string DefaultPrinter
{
get { return fPrintDocument.PrinterSettings.PrinterName; }
}
/// <summary>
/// 获取打印机列表
/// </summary>
private static List<string> GetLocalPrinters()
{
List<string> fPrinters = new List<string>();
fPrinters.Add(DefaultPrinter);
foreach (string fPrinterName in PrinterSettings.InstalledPrinters)
{
if (!fPrinters.Contains(fPrinterName))
fPrinters.Add(fPrinterName);
}
return fPrinters;
}
}
}