|
|
|
using BarcodeLib;
|
|
|
|
using BBWY.Client.APIServices;
|
|
|
|
using BBWY.Client.Helpers;
|
|
|
|
using BBWY.Client.Models;
|
|
|
|
using BBWY.Client.ViewModels;
|
|
|
|
using BBWY.Client.ViewModels.PackTask;
|
|
|
|
using BBWY.Controls;
|
|
|
|
using HandyControl.Controls;
|
|
|
|
using Org.BouncyCastle.Asn1.Ocsp;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Drawing.Printing;
|
|
|
|
using System.IO;
|
|
|
|
using System.Printing;
|
|
|
|
using System.Reflection;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
using System.Runtime.InteropServices.WindowsRuntime;
|
|
|
|
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.Input;
|
|
|
|
using System.Windows.Media;
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
|
|
|
namespace BBWY.Client.Views.PackTask
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// ServiceWindow.xaml 的交互逻辑
|
|
|
|
/// </summary>
|
|
|
|
public partial class ServiceWindow : BWindow
|
|
|
|
{
|
|
|
|
public ServiceWindow(PackTaskModel model,Action reflashWindow)
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
var serviceViewModel= this.DataContext as PackServiceViewModel;
|
|
|
|
//加载数据
|
|
|
|
|
|
|
|
if (model.BarCodeModel!=null)
|
|
|
|
{
|
|
|
|
model.BarCodeModel.ShopName= model.ShopName;
|
|
|
|
}
|
|
|
|
|
|
|
|
serviceViewModel.PackTaskModel = model;
|
|
|
|
serviceViewModel.PackTaskList = new System.Collections.ObjectModel.ObservableCollection<PackTaskModel> { model };
|
|
|
|
serviceViewModel.FloorDragNumber = model.FloorDragNumber;
|
|
|
|
serviceViewModel.TaskCount = model.SkuCount;
|
|
|
|
serviceViewModel.TaskId = model. TaskId;
|
|
|
|
serviceViewModel.OrderId = model. OrderId;
|
|
|
|
serviceViewModel.SkuId = model. SkuId;
|
|
|
|
serviceViewModel.PackUserName = model.PackUser?.Replace("\r\n", ",")?.Replace("\n", ",")?.Replace("\r", ",");
|
|
|
|
serviceViewModel.LoadPackDatas();
|
|
|
|
if (reflashWindow != null)
|
|
|
|
serviceViewModel.ReflashWindow = reflashWindow;
|
|
|
|
}
|
|
|
|
private void BButton_Click(object sender, RoutedEventArgs e)
|
|
|
|
{
|
|
|
|
var localPrintServer = new LocalPrintServer();
|
|
|
|
string printName = cbPrintName.Text.Trim();
|
|
|
|
if (string.IsNullOrEmpty(printName))
|
|
|
|
{
|
|
|
|
System.Windows.MessageBox.Show("选择打印机");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var printQueue = localPrintServer.GetPrintQueue(printName);
|
|
|
|
if (printQueue.IsInError)
|
|
|
|
{
|
|
|
|
System.Windows.MessageBox.Show("打印机处于错误状态");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MyPrintHelper.SetDefaultPrint(printName);//设置默认打印机
|
|
|
|
this.printArea.Arrange(new Rect(new Point(0, 0), new Size(printArea.ActualWidth, printArea.ActualHeight)));
|
|
|
|
|
|
|
|
System.Windows.Controls.PrintDialog printDialog = new PrintDialog();
|
|
|
|
|
|
|
|
//设置纸张大小
|
|
|
|
var pageWidth = (int)Math.Ceiling(printDialog.PrintableAreaWidth);
|
|
|
|
var pageHeight = (int)Math.Ceiling(printDialog.PrintableAreaHeight);
|
|
|
|
printDialog.PrintTicket.PageMediaSize = new PageMediaSize(pageWidth, pageHeight);
|
|
|
|
|
|
|
|
|
|
|
|
printDialog.PrintVisual(this.printArea, "打印任务");
|
|
|
|
|
|
|
|
var applicationPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
|
|
string printNames = System.IO.Path.Combine(applicationPath, "printName.init");
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (File.Exists(printNames))
|
|
|
|
{
|
|
|
|
File.Delete(printNames);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
File.WriteAllText(printNames, cbPrintName.Text);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|