private void btnSavePo_Click(object sender, EventArgs e) { try { MesRkwPo rkwPo = new MesRkwPo { ManNo = txtManNo.Text, SupplierNo = txtSupplierNo.Text, CusName = txtCUSName.Text, PartNo = txtPartNo.Text, MoNo = txtMoNo.Text, Supplier = txtSupplier.Text, Qty = int.Parse(txtQty.Text), MinicutPoNo = txtMinicutPoNo.Text, PartName = txtPartName.Text, HeatNo = txtHeatNo.Text, RecaroPoNo = txtRecaroPoNo.Text, BoxSize = int.Parse(txtBoxSize.Text), BoxLabelQty = int.Parse(cbbBoxLabelQty.Text) }; ConsoleWriteToLabelMsg("数据保存中...."); using (var context = Carlzhu.Iooin.Business.BaseUtility.ContextFactory.ContextHelper) { var po = context.MesRkwPos.Find(rkwPo.ManNo); if (po == null) { context.MesRkwPos.Add(rkwPo); context.SaveChanges(); ConsoleWriteToLabelMsg("数据已保存,可以列印数据...."); } else { po.BoxSize = rkwPo.BoxSize; po.Qty = rkwPo.Qty; po.PartNo = rkwPo.PartNo; po.PartName = rkwPo.PartName; po.MoNo = rkwPo.MoNo; po.HeatNo = rkwPo.HeatNo; po.Supplier = rkwPo.Supplier; po.RecaroPoNo = rkwPo.RecaroPoNo; po.BoxLabelQty = rkwPo.BoxLabelQty; context.Set <MesRkwPo>().Attach(po); context.Entry <MesRkwPo>(po).State = EntityState.Modified; context.SaveChanges(); ConsoleWriteToLabelMsg("工单已被修改,可以列印数据...."); txtManNo.ReadOnly = false; } } } catch (Exception) { ConsoleWriteToLabelMsg("请确认数据信息是否正确!!!"); } }
public void PrintBoxLabel(MesRkwPo mespo, MesRkwBox mesbox, string qty) { if (mespo.BoxLabelQty == 1) { PrintPackageLabel(mespo, mesbox, qty, 1); } else { PrintTraceableTagsLabel(mespo, qty); PrintShippingLabel(mespo, qty); } }
/// <summary> /// 打印Shipping /// </summary> /// <param name="mespo"></param> /// <param name="qty"></param> void PrintShippingLabel(MesRkwPo mespo, string qty) { Dictionary <string, string> shipping = new Dictionary <string, string>() { { "cusname", mespo.CusName }, { "partno", mespo.PartNo }, { "partname", mespo.PartName }, { "recaropono", mespo.RecaroPoNo }, { "bacthno", mespo.MoNo }, { "supplierno", mespo.SupplierNo }, { "date", DateTime.Now.ToString("yyyy/MM") }, { "qty", qty }, }; ConsoleWriteToLabelMsg($"正在打印shipping标签..."); Print(LocalPrint.DefaultPrinter(), Parameters.ShippingLabel, shipping, 1); ConsoleWriteToLabelMsg($"shipping标签打印完成!"); }
void PrintPackageLabel(MesRkwPo mespo, MesRkwBox mesbox, string qty, int PrintQty = 1) { Dictionary <string, string> packageDictionary = new Dictionary <string, string>() { { "PartNo", mespo.PartNo }, { "Partname", mespo.PartName }, { "RecaroPONO", mespo.RecaroPoNo }, { "MONO", mespo.MoNo }, { "HeatNO", mespo.HeatNo }, { "SupplierCode", "16253" }, { "Date", DateTime.Now.ToString("yyyy/MM") }, { "CTNNO", mesbox.BoxId }, { "Qty", qty }, }; ConsoleWriteToLabelMsg($"正在打印PackageBox标签,箱号:{mesbox.BoxId}"); //列印大标签1 Print(LocalPrint.DefaultPrinter(), Parameters.PackageLabel, packageDictionary, PrintQty); ConsoleWriteToLabelMsg($"PackageBox标签打印完成!"); }
void PrintTraceableTagsLabel(MesRkwPo mespo, string qty) { Dictionary <string, string> traceable = new Dictionary <string, string>() { { "supplier", mespo.Supplier }, { "partno", mespo.PartNo }, { "partname", mespo.PartName }, { "minicutpono", mespo.MinicutPoNo }, { "recaropono", mespo.RecaroPoNo }, { "mono", mespo.MoNo }, { "heatno", mespo.HeatNo }, { "bacthno", mespo.MoNo }, { "Date", DateTime.Now.ToString("yyyy/MM") }, { "Qty", qty }, }; ConsoleWriteToLabelMsg($"正在打印traceable标签"); //列印大标签1 Print(LocalPrint.DefaultPrinter(), Parameters.TraceableTagsLabel, traceable, 1); ConsoleWriteToLabelMsg($"traceable标签打印完成"); }