using grproLib; using InjectionPC; using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PunchingMistake { public class Printer { /// /// 小件总成装配打印总成条码 /// public static void PrintPunchAssembleBarCode( string barCode, string partNo1, string partName, string serialNo,string carType) { string filename = GetPrintFileName(); DataTable headTable = new DataTable(); headTable.Columns.Add("BarCode"); headTable.Columns.Add("PartName"); headTable.Columns.Add("PartNo"); headTable.Columns.Add("BatchNo"); headTable.Columns.Add("SerialNo"); headTable.Columns.Add("Line"); headTable.Columns.Add("Operater"); headTable.Columns.Add("CarType"); DataRow row = headTable.NewRow(); row["BarCode"] = barCode; row["PartNo"] = partNo1; row["PartName"] = partName; row["BatchNo"] = DateTime.Now.ToString("yyMMdd"); row["SerialNo"] = serialNo; row["Line"] = ConfigurationManager.AppSettings["Line"]; row["Operater"] = Program.UserName; row["CarType"] = carType; string printBoxName = "Printer1"; string reportName = ConfigurationManager.AppSettings[printBoxName].ToString(); headTable.Rows.Add(row); ReportHelper rp = new ReportHelper(filename, headTable, null, (int)GRPaperOrientation.grpoLandscape, 1, reportName); rp.Report.Print(false); } static string GetPrintFileName() { string templateName = ConfigurationManager.AppSettings["BarCodeFormat"].ToString(); if(templateName == "MI") { return System.AppDomain.CurrentDomain.BaseDirectory + $"Report\\总成条码MI.grf"; } else { return System.AppDomain.CurrentDomain.BaseDirectory + $"Report\\总成条码Hyundai.grf"; } } } }