From 3fe3da69ed76cc71d92198c6f0aea9f5bb4b6e77 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期五, 27 十二月 2024 10:16:19 +0800
Subject: [PATCH] 1
---
WarM/条码打印/Gy_BarCodeBill_automaticallyByPLC_New.cs | 139 ++++++++++++++++++++++++++++++++++++++-------
1 files changed, 116 insertions(+), 23 deletions(-)
diff --git "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_automaticallyByPLC_New.cs" "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_automaticallyByPLC_New.cs"
index eeab9df..6627b0f 100644
--- "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_automaticallyByPLC_New.cs"
+++ "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_automaticallyByPLC_New.cs"
@@ -14,6 +14,7 @@
using System.IO;
using System.Management;
using System.Net.NetworkInformation;
+using System.Printing;
namespace WarM
{
@@ -407,22 +408,40 @@
#region 鐢熸垚鎸夐挳
private void bc_Click(object sender, EventArgs e)
{
+ //瀹℃牳鏉冮檺
+ if (!DBUtility.ClsPub.Security_Log_second("Gy_BarCodeBill_automaticallyByPLC_ProduceByHand", 1, false, DBUtility.ClsPub.CurUserName))
+ {
+ MessageBox.Show("鐢熸垚澶辫触锛屾棤鏉冮檺锛�");
+ return;
+ }
+
+ //娓呴櫎鎵撳嵃浠诲姟
+ string msg = "";
+ if (!clearPrinterTask(ref msg))
+ {
+ MessageBox.Show(msg);
+ return;
+ }
+
this.Sub_SaveBill();
Display();
- //璁剧疆鎵撳嵃妯℃澘锛屾墦鍗�
- grdList.Rows[0].Cells[0].Value = "*";
- Report = new GridppReport();
- Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + textBox_PrintModelParams.Text + ".grf"); //here .
- Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
- Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
- Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
- if (comboBox_PrinterParams.Text != "")
+ if (radioButton_IsPrint_Yes.Checked == true)
{
- Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(榛樿)", "");
+ //璁剧疆鎵撳嵃妯℃澘锛屾墦鍗�
+ grdList.Rows[0].Cells[0].Value = "*";
+ Report = new GridppReport();
+ Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + textBox_PrintModelParams.Text + ".grf"); //here .
+ Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
+ Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
+ Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
+ if (comboBox_PrinterParams.Text != "")
+ {
+ Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(榛樿)", "");
+ }
+ Report.Print(false);
}
- Report.Print(false);
-
+
Display4();
}
//淇濆瓨鍗曟嵁
@@ -1019,7 +1038,29 @@
//鎷兼帴鎵瑰彿
HBarCode_MaxNo = sYear + sPeriod + sDay + LIU;
- return HBarCode_MaxNo;
+ long HBarCode_MaxNo_long = long.Parse(HBarCode_MaxNo);
+
+ while (true)
+ {
+ int HCount_BarCodeBillList = 0;
+ int HCount_SubBarCodeBill = 0;
+ string sql_confirm = "select * from h_v_IF_BarCodeBillList where 鏉$爜缂栧彿 = '" + (ClsPub.isStrNull(grdSub.Rows[0].Cells[HMaterModel2Col].Value) + HBarCode_MaxNo_long.ToString()) + "' and 鏉$爜绫诲瀷 = '鍞竴鏉$爜'" + " and CONVERT(varchar(100),鏉$爜鏃ユ湡, 23) = '" + HDate + "'";
+ ds = oCn.RunProcReturn(sql_confirm, "h_v_IF_BarCodeBillList");
+ HCount_BarCodeBillList = ds.Tables[0].Rows.Count;
+ sql_confirm = "select * from Gy_BarCodeBill_SWELL_SubBarCodeBill Where HBarCode = '" + (ClsPub.isStrNull(grdSub.Rows[0].Cells[HMaterModel2Col].Value) + HBarCode_MaxNo_long.ToString()) + "' and HBarCodeType = '鍞竴鏉$爜'" + " and CONVERT(varchar(100),HMakeDate, 23) = '" + HDate + "'";
+ ds = oCn.RunProcReturn(sql_confirm, "Gy_BarCodeBill_SWELL_SubBarCodeBill");
+ HCount_SubBarCodeBill = ds.Tables[0].Rows.Count;
+ if (HCount_BarCodeBillList + HCount_SubBarCodeBill > 0)
+ {
+ HBarCode_MaxNo_long += 1;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return HBarCode_MaxNo_long.ToString();
}
#endregion
@@ -1156,9 +1197,43 @@
return false;
}
+ //娓呴櫎鎸囧畾鎵撳嵃鏈轰换鍔�
+ private bool clearPrinterTask(ref string msg)
+ {
+ try
+ {
+ PrintServer localPrintServer = new LocalPrintServer();
+ PrintQueue pq = localPrintServer.GetPrintQueue(comboBox_PrinterParams.Text.Replace("(榛樿)", "").ToLower());
+ pq.Refresh();
+ PrintJobInfoCollection allPrintJobs = pq.GetPrintJobInfoCollection();
+ foreach (PrintSystemJobInfo printJob in allPrintJobs)
+ {
+ printJob.Cancel();
+
+ }
+ return true;
+ }
+ catch(Exception ex)
+ {
+ msg = ex.Message;
+ return false;
+ }
+ }
+
//鏍规嵁閫氳淇℃伅鐢熸垚鏉$爜骞舵墦鍗�
private void timer2_Tick(object sender, EventArgs e)
{
+ if (produceQty > 0)
+ {
+ //娓呴櫎鎵撳嵃浠诲姟
+ string msg = "";
+ if (!clearPrinterTask(ref msg))
+ {
+ MessageBox.Show(msg);
+ produceQty = 0;
+ }
+ }
+
for (int i = 0; i < produceQty; i++)
{
//鐢熸垚鏉$爜
@@ -1167,18 +1242,21 @@
//鑾峰彇闇�瑕佹墦鍗扮殑鏁版嵁
Display();
- //璁剧疆鎵撳嵃妯℃澘锛屾墦鍗�
- grdList.Rows[0].Cells[0].Value = "*";
- Report = new GridppReport();
- Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + textBox_PrintModelParams.Text + ".grf"); //here .
- Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
- Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
- Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
- if (comboBox_PrinterParams.Text != "")
+ if (radioButton_IsPrint_Yes.Checked == true)
{
- Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(榛樿)", "");
+ //璁剧疆鎵撳嵃妯℃澘锛屾墦鍗�
+ grdList.Rows[0].Cells[0].Value = "*";
+ Report = new GridppReport();
+ Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + textBox_PrintModelParams.Text + ".grf"); //here .
+ Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
+ Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
+ Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
+ if (comboBox_PrinterParams.Text != "")
+ {
+ Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(榛樿)", "");
+ }
+ Report.Print(false);
}
- Report.Print(false);
if (i == produceQty - 1)
{
@@ -2464,6 +2542,21 @@
#endregion
#endregion
-
+ #region 寤虹珛閫氳鍚庯紝涓嶆柇鍚戞湇鍔″櫒鍙戦�佹暟鎹紝鐢ㄤ簬甯姪鏈嶅姟绔‘瀹氳繛鎺ョ姸鎬�
+ private void timer4_Tick(object sender, EventArgs e)
+ {
+ if (getTargetInternetStatus()&& socket!=null && socket.Connected)
+ {
+ try
+ {
+ socket.Send(Encoding.ASCII.GetBytes("1"));
+ }
+ catch (Exception ex)
+ {
+
+ }
+ }
+ }
+ #endregion
}
}
\ No newline at end of file
--
Gitblit v1.9.1