/// <summary> /// 打印标签 /// </summary> public override TPCResult <bool> PrintLabel1() { TPCResult <bool> result = null; List <CItem> items = null; PrinterSettings setting = GetPrinterSetting(); if (setting == null) { return(new TPCResult <bool>()); } items = GetPackingItems(); result = Database.CompletedPallet(items); if (result.State == RESULT_STATE.NG) { return(result); } //打印第一页信息 TPCPrintLabel labelFrist = LabelPrintGlobal.g_LabelCreator.GetPrintLabel("pallet"); List <string> parametersFrist = MakePrintParameters(PACK_MODE.Pallet, GetLabelData(true)); labelFrist.Print(setting, parametersFrist); labelFrist.Print(setting, parametersFrist); labelFrist.Print(setting, parametersFrist); labelFrist.Print(setting, parametersFrist); //打印第二页信息 TPCPrintLabel labelSecond = LabelPrintGlobal.g_LabelCreator.GetPrintLabel("pallet_pega"); List <string> parametersSecond = MakePrintParameters(PACK_MODE.Pallet, GetLabelData(false)); labelSecond.Print(setting, parametersSecond); labelSecond.Print(setting, parametersSecond); labelSecond.Print(setting, parametersSecond); labelSecond.Print(setting, parametersSecond); //这里需要写入pnt_mng表 result = Database.SetManagerData(PACK_MODE.Pallet, Parent.PNoEdit.Text, Program.LoginUser, Convert.ToInt32(Parent.QTYEdit.Text), PACK_ACTION.Register, PACK_STATUS.Completed); return(result); }
/// <summary> /// 修改日期20180517 /// </summary> public override TPCResult <bool> PrintLabel2() { TPCResult <bool> result = null; List <CItem> items = null; result = new TPCResult <bool>(); PrinterSettings setting = GetPrinterSetting(); if (setting == null) { return(result); } items = GetPackingItems(); //写数据库文件 result = Database.CompletedCarton(items); if (result.State == RESULT_STATE.NG) { return(result); } //打印第一页信息 TPCPrintLabel labelFristPage = LabelPrintGlobal.g_LabelCreator.GetPrintLabel("carton_fxzz"); List <string> parametersFristPage = MakePrintParameters(PACK_MODE.Carton, GetLabelData(false)); labelFristPage.Print(setting, parametersFristPage); labelFristPage.Print(setting, parametersFristPage); //选择性打印第二页信息 setting = GetPrinterSetting(); if (setting != null) { TPCPrintLabel labelSecond = LabelPrintGlobal.g_LabelCreator.GetPrintLabel("fxzz_additional"); List <string> parametersSecond = MakePrintParameters(PACK_MODE.Carton, GetLabelData(false)); #region 修改打印参数 #region lotNo string lotNo = parametersSecond[14]; parametersSecond[14] = lotNo.Substring(0, lotNo.Length - 1); #endregion #region dateCode //将时间格式9013改成2019-01-03 string outputTime = ""; string dateCode = parametersSecond[14].Substring(3); string[] code = { dateCode.Substring(0, 1), dateCode.Substring(1, 2), dateCode.Substring(3, 1) }; //确定年 string today = DateTime.Today.ToString("yyyy"); for (int i = 0; i < 10; i++) { if (today.Substring(3, 1).Equals(code[0])) { outputTime = today; } else { today = (Convert.ToInt16(today) - 1).ToString(); } } //确定月份和日 DateTime dtTemp = Convert.ToDateTime(outputTime + "-01-01"); GregorianCalendar gc = new GregorianCalendar(); for (int i = 0; i < 365; i++) { int weekOfYear = gc.GetWeekOfYear(dtTemp, CalendarWeekRule.FirstDay, DayOfWeek.Sunday); int dayOfWeek = (int)dtTemp.DayOfWeek + 1; if (weekOfYear == Convert.ToInt16(code[1]) && dayOfWeek == Convert.ToInt16(code[2])) { outputTime = dtTemp.ToString("yyyy-MM-dd"); break; } else { dtTemp = dtTemp.AddDays(1); } } parametersSecond[5] = outputTime; #endregion #endregion labelSecond.Print(setting, parametersSecond); labelSecond.Print(setting, parametersSecond); } //这里需要写入pnt_mng表 result = Database.SetManagerData(PACK_MODE.Carton, Parent.PNoEdit.Text, Program.LoginUser, Convert.ToInt32(Parent.QTYEdit.Text), PACK_ACTION.Register, PACK_STATUS.Completed); return(result); }
/// <summary> /// 修改日期20180517 /// </summary> public override TPCResult <bool> PrintLabel2() { TPCResult <bool> result = null; List <CItem> items = null; result = new TPCResult <bool>(); PrinterSettings setting = GetPrinterSetting(); if (setting == null) { return(result); } items = GetPackingItems(); //写数据库文件 result = Database.CompletedPallet(items); if (result.State == RESULT_STATE.NG) { return(result); } //打印第一页信息 TPCPrintLabel labelFrist = LabelPrintGlobal.g_LabelCreator.GetPrintLabel("pallet_fxzz"); List <string> parametersFrist = MakePrintParameters(PACK_MODE.Pallet, GetLabelData(false)); labelFrist.Print(setting, parametersFrist); labelFrist.Print(setting, parametersFrist); labelFrist.Print(setting, parametersFrist); labelFrist.Print(setting, parametersFrist); //选择性打印第二页信息 TPCPrintLabel labelSecond = LabelPrintGlobal.g_LabelCreator.GetPrintLabel("fxzz_additional"); List <string> parametersSecond = MakePrintParameters(PACK_MODE.Pallet, GetLabelData(false)); #region 修改打印参数 #region lotNo string lotNo = parametersSecond[14]; parametersSecond[14] = lotNo.Substring(0, lotNo.Length - 1); #endregion #region dateCode //将时间格式9013改成2019-01-03 string outputTime = ""; string dateCode = parametersSecond[14].Substring(3); string[] code = { dateCode.Substring(0, 1), dateCode.Substring(1, 2), dateCode.Substring(3, 1) }; //确定年 string today = DateTime.Today.ToString("yyyy"); for (int i = 0; i < 10; i++) { if (today.Substring(3, 1).Equals(code[0])) { outputTime = today; } else { today = (Convert.ToInt16(today) - 1).ToString(); } } //确定月份和日 DateTime dtTemp = Convert.ToDateTime(outputTime + "-01-01"); GregorianCalendar gc = new GregorianCalendar(); for (int i = 0; i < 365; i++) { int weekOfYear = gc.GetWeekOfYear(dtTemp, CalendarWeekRule.FirstDay, DayOfWeek.Sunday); int dayOfWeek = (int)dtTemp.DayOfWeek + 1; if (weekOfYear == Convert.ToInt16(code[1]) && dayOfWeek == Convert.ToInt16(code[2])) { outputTime = dtTemp.ToString("yyyy-MM-dd"); break; } else { dtTemp = dtTemp.AddDays(1); } } parametersSecond[5] = outputTime; #endregion #endregion setting = GetPrinterSetting(); if (setting != null) { labelSecond.Print(setting, parametersSecond); labelSecond.Print(setting, parametersSecond); labelSecond.Print(setting, parametersSecond); labelSecond.Print(setting, parametersSecond); } #region 富士康卡板A4纸张 //设置新纸张大小 PrinterSettings setting2 = GetPrinterSetting(); if (setting2 == null) { return(result); } Print2 print2 = new Print2(Parent.PNoEdit.Text, parametersSecond[7], outputTime, parametersSecond[14]); DataTable dt = new DataTable(); dt.Columns.Add("No."); dt.Columns.Add("箱号"); dt.Columns.Add("料号"); dt.Columns.Add("数量"); int ii = 0; //每行写上被包括的子标签数量等 TPCResult <List <List <string> > > items2 = null; bool queryInfo(string ID) { items2 = null; items2 = Database.GetFXZZ_Data(ID); if (items2.State == RESULT_STATE.NG) { MessageBox.Show(items2.Message); return(false); } return(true); } foreach (ListViewItem var in Parent.ItemsListView.Items) { string id = var.SubItems[1].Text; if (!queryInfo(id)) { return(result); } if (items2.Value.Count == 0) { continue; } DataRow dr = dt.NewRow(); dr["No."] = (++ii).ToString(); dr["箱号"] = id; dr["料号"] = LabelPrintGlobal.g_Config.APN; dr["数量"] = items2.Value[0][0].ToString(); dt.Rows.Add(dr); } print2.ImportDataTable(dt); print2.BtnPrint_Click(setting2); print2.Dispose(); #endregion //这里需要写入pnt_mng表 result = Database.SetManagerData(PACK_MODE.Pallet, Parent.PNoEdit.Text, Program.LoginUser, Convert.ToInt32(Parent.QTYEdit.Text), PACK_ACTION.Register, PACK_STATUS.Completed); return(result); }
private void reprint3() { if (lstItems.Items.Count < Convert.ToInt32(txtTotal.Text)) { MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("NOT_FULL_QUANTITY_ERROR"), "ERROR", MessageBoxButtons.OK); return; } PrintDialog dlg = new PrintDialog(); if (dlg.ShowDialog() != DialogResult.OK) { return; } PrinterSettings setting = dlg.PrinterSettings; PrintLabelData data = new PrintLabelData(); data.PCode = txtCode.Text; data.DataCode = GetCodeDate(); data.Total = Convert.ToInt32(txtTotal.Text); data.Date = GetDate(); TPCResult <int> result = Database.GetModuleCount(m_Mode, txtCode.Text); if (result.State == RESULT_STATE.NG) { MessageBox.Show(result.Message); return; } data.Quantity = result.Value; string label_nameFrist = ""; string label_nameSecond = ""; switch (m_Mode) { case PACK_MODE.Pack: label_nameFrist = "pack_fxzz"; label_nameSecond = "pack_wks"; break; case PACK_MODE.Carton: label_nameFrist = "carton_fxzz"; label_nameSecond = "carton_wks"; break; case PACK_MODE.Pallet: label_nameFrist = "pallet_fxzz"; label_nameSecond = "pallet_wks"; break; } //打印第一页信息 TPCPrintLabel labelFrist = LabelPrintGlobal.g_LabelCreator.GetPrintLabel(label_nameFrist); List <string> parametersFrist = MakePrintParameters(m_Mode, data); //打印第二页信息 TPCPrintLabel labelSecond = LabelPrintGlobal.g_LabelCreator.GetPrintLabel(label_nameSecond); List <string> parametersSecond = MakePrintParameters(m_Mode, data); switch (m_Mode) { case PACK_MODE.Pack: labelFrist.Print(setting, parametersFrist); labelSecond.Print(setting, parametersSecond); break; case PACK_MODE.Carton: labelFrist.Print(setting, parametersFrist); labelFrist.Print(setting, parametersFrist); labelSecond.Print(setting, parametersSecond); labelSecond.Print(setting, parametersSecond); break; case PACK_MODE.Pallet: labelFrist.Print(setting, parametersFrist); labelFrist.Print(setting, parametersFrist); labelFrist.Print(setting, parametersFrist); labelFrist.Print(setting, parametersFrist); labelSecond.Print(setting, parametersSecond); labelSecond.Print(setting, parametersSecond); labelSecond.Print(setting, parametersSecond); labelSecond.Print(setting, parametersSecond); break; } //这里需要写入pnt_mng表 TPCResult <bool> ret = Database.SetManagerData(m_Mode, data.PCode, Program.LoginUser, Convert.ToInt32(data.Total), PACK_ACTION.Register, PACK_STATUS.Completed); if (ret.State == RESULT_STATE.NG) { MessageBox.Show(ret.Message); return; } }
private void reprint2() { if (lstItems.Items.Count < Convert.ToInt32(txtTotal.Text)) { MessageBox.Show(LabelPrintGlobal.ShowWarningMessage("NOT_FULL_QUANTITY_ERROR"), "ERROR", MessageBoxButtons.OK); return; } PrintDialog dlg = new PrintDialog(); if (dlg.ShowDialog() != DialogResult.OK) { return; } PrinterSettings setting = dlg.PrinterSettings; PrintLabelData data = new PrintLabelData(); data.PCode = txtCode.Text; data.DataCode = GetCodeDate(); data.Date = GetDate(); data.Total = Convert.ToInt32(txtTotal.Text); TPCResult <int> result = Database.GetModuleCount(m_Mode, txtCode.Text); if (result.State == RESULT_STATE.NG) { MessageBox.Show(result.Message); return; } data.Quantity = result.Value; string label_nameFrist = ""; string label_nameSecond = "fxzz_additional"; switch (m_Mode) { case PACK_MODE.Pack: label_nameFrist = "pack_fxzz"; break; case PACK_MODE.Carton: label_nameFrist = "carton_fxzz"; break; case PACK_MODE.Pallet: label_nameFrist = "pallet_fxzz"; break; } //打印第一页信息 TPCPrintLabel labelFrist = LabelPrintGlobal.g_LabelCreator.GetPrintLabel(label_nameFrist); List <string> parametersFrist = MakePrintParameters(m_Mode, data); //打印第二页信息 TPCPrintLabel labelSecond = LabelPrintGlobal.g_LabelCreator.GetPrintLabel(label_nameSecond); List <string> parametersSecond = MakePrintParameters(m_Mode, data); #region 修改打印参数 #region lotNo string lotNo = parametersSecond[14]; parametersSecond[14] = lotNo.Substring(0, lotNo.Length - 1); #endregion parametersSecond[5] = changeDateFormat(parametersSecond[14].Substring(3)); ///将时间格式9013改成2019-01-03 string changeDateFormat(string dateCode) { string outputTime = ""; string[] code = { dateCode.Substring(0, 1), dateCode.Substring(1, 2), dateCode.Substring(3, 1) }; #region 确定年月日 //确定年 string today = DateTime.Today.ToString("yyyy"); for (int i = 0; i < 10; i++) { if (today.Substring(3, 1).Equals(code[0])) { outputTime = today; } else { today = (Convert.ToInt16(today) - 1).ToString(); } } //确定月份和日 DateTime dtTemp = Convert.ToDateTime(outputTime + "-01-01"); GregorianCalendar gc = new GregorianCalendar(); for (int i = 0; i < 365; i++) { int weekOfYear = gc.GetWeekOfYear(dtTemp, CalendarWeekRule.FirstDay, DayOfWeek.Sunday); int dayOfWeek = (int)dtTemp.DayOfWeek + 1; if (weekOfYear == Convert.ToInt16(code[1]) && dayOfWeek == Convert.ToInt16(code[2])) { outputTime = dtTemp.ToString("yyyy-MM-dd"); break; } else { dtTemp = dtTemp.AddDays(1); } } #endregion return(outputTime); } #endregion switch (m_Mode) { case PACK_MODE.Pack: labelFrist.Print(setting, parametersFrist); dlg = new PrintDialog(); if (dlg.ShowDialog() != DialogResult.OK) { return; } setting = dlg.PrinterSettings; labelSecond.Print(setting, parametersSecond); break; case PACK_MODE.Carton: labelFrist.Print(setting, parametersFrist); labelFrist.Print(setting, parametersFrist); dlg = new PrintDialog(); if (dlg.ShowDialog() != DialogResult.OK) { return; } setting = dlg.PrinterSettings; labelSecond.Print(setting, parametersSecond); labelSecond.Print(setting, parametersSecond); break; case PACK_MODE.Pallet: labelFrist.Print(setting, parametersFrist); labelFrist.Print(setting, parametersFrist); labelFrist.Print(setting, parametersFrist); labelFrist.Print(setting, parametersFrist); dlg = new PrintDialog(); if (dlg.ShowDialog() != DialogResult.OK) { return; } setting = dlg.PrinterSettings; labelSecond.Print(setting, parametersSecond); labelSecond.Print(setting, parametersSecond); labelSecond.Print(setting, parametersSecond); labelSecond.Print(setting, parametersSecond); #region 富士康卡板A4纸张 //设置新纸张大小 dlg = new PrintDialog(); if (dlg.ShowDialog() != DialogResult.OK) { return; } setting = dlg.PrinterSettings; Print2 print2 = new Print2(txtCode.Text, parametersSecond[7], parametersSecond[5], parametersSecond[14]); DataTable dt = new DataTable(); dt.Columns.Add("No."); dt.Columns.Add("箱号"); dt.Columns.Add("料号"); dt.Columns.Add("数量"); int i = 0; //每行写上被包括的子标签数量等 TPCResult <List <List <string> > > items = null; bool queryInfo(string ID) { items = null; //m_Mode = PACK_MODE.Pack; items = Database.GetFXZZ_Data(ID); if (items.State == RESULT_STATE.NG) { MessageBox.Show(items.Message); return(false); } return(true); } foreach (ListViewItem var in lstItems.Items) { string id = var.SubItems[1].Text; if (!queryInfo(id)) { return; } if (items.Value.Count == 0) { continue; } DataRow dr = dt.NewRow(); dr["No."] = (++i).ToString(); dr["箱号"] = id; dr["料号"] = LabelPrintGlobal.g_Config.APN; dr["数量"] = items.Value[0][0].ToString(); dt.Rows.Add(dr); } print2.ImportDataTable(dt); if (print2.BtnPrint_Click(setting)) { print2.Dispose(); return; } print2.Dispose(); #endregion break; } //这里需要写入pnt_mng表 TPCResult <bool> ret = Database.SetManagerData(m_Mode, data.PCode, Program.LoginUser, Convert.ToInt32(data.Total), PACK_ACTION.Register, PACK_STATUS.Completed); if (ret.State == RESULT_STATE.NG) { MessageBox.Show(ret.Message); return; } }