From 9c7972d018cc98fc6adf4d57e18084255db103c1 Mon Sep 17 00:00:00 2001
From: llj <132905093+newwwwwwtree@users.noreply.github.com>
Date: 星期三, 24 九月 2025 17:23:21 +0800
Subject: [PATCH] PDA库存转移模块

---
 WarM/条码打印/Gy_BarCodeBill_automaticallyByPLC_New.cs |   99 ++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 72 insertions(+), 27 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 e9bd5a0..daf7c8f 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"
@@ -426,19 +426,22 @@
             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();
         }
         //淇濆瓨鍗曟嵁
@@ -843,6 +846,7 @@
                         HWhID = ClsPub.isLong(grdSub.Rows[i].Cells[HWhID2Col].Value);
                         HSPID = ClsPub.isLong(grdSub.Rows[i].Cells[HSPID2Col].Value);
                         HRemark = ClsPub.isStrNull(grdSub.Rows[i].Cells[HRemark2Col].Value);
+                        HRemark = "PLC鑷姩鐢熸垚";
                         HMaterName = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMaterName2Col].Value);
                         HMaterModel = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMaterModel2Col].Value);
                         HPinfan = ClsPub.isStrNull(grdSub.Rows[i].Cells[HPinfan2Col].Value);
@@ -949,14 +953,14 @@
                 string LIU = "";
                 int LEN = 4;
                 DataSet ds;
-                string sql = "select * from h_v_IF_BarCodeBillList Where HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),鏉$爜鏃ユ湡, 23) = '" + HDate + "' order by 鎵瑰彿 desc";
+                string sql = "select * from h_v_IF_BarCodeBillList Where HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),鏉$爜鏃ユ湡, 23) = '" + HDate + "' and 澶囨敞 = 'PLC鑷姩鐢熸垚' order by 鎵瑰彿 desc";
                 ds = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList");
                 if (ds != null)
                 {
                     long count = 0;
                     if (ds.Tables[0].Rows.Count > 0)
                     {
-                        count = ClsPub.isLong(ds.Tables[0].Rows[0]["鎵瑰彿"].ToString().Replace(sYear + sPeriod + sDay, ""));
+                        count = ClsPub.isLong(ds.Tables[0].Rows[0]["鎵瑰彿"].ToString().Replace(sYear + sPeriod + sDay+" ", ""));
                     }
                     LIU += count + 1;
                     while (LIU.Length < LEN)  //濡傛灉娴佹按鍙峰皬浜�6浣嶆暟鍓嶉潰琛�0
@@ -970,7 +974,7 @@
                 }
 
                 //鎷兼帴鎵瑰彿
-                HBatchNo = sYear + sPeriod + sDay + LIU;
+                HBatchNo = sYear + sPeriod + sDay+" " + LIU;
             }
 
 
@@ -1035,7 +1039,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
 
@@ -1205,7 +1231,7 @@
                 if (!clearPrinterTask(ref msg))
                 {
                     MessageBox.Show(msg);
-                    return;
+                    produceQty = 0;
                 }
             }
 
@@ -1217,18 +1243,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)
                 {
@@ -2215,6 +2244,7 @@
                 {
                     sMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value) / ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMinQtyCol].Value);
                 }
+                sMoney = Math.Round(sMoney, 10);    // 淇濈暀10浣嶅皬鏁拌繘琛屽洓鑸嶄簲鍏�
                 sMoney = Math.Ceiling(sMoney);
                 grdMain.Rows[sRow].Cells[HBQtyCol].Value = sMoney;
             }
@@ -2514,6 +2544,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