From d54613ce0b6960dafcbd28454172f21a2d0bb6d1 Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期二, 08 四月 2025 08:48:07 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WarM/条码打印/Gy_PackBarCodeBill_automaticallyByPLC.cs |  141 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 133 insertions(+), 8 deletions(-)

diff --git "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_PackBarCodeBill_automaticallyByPLC.cs" "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_PackBarCodeBill_automaticallyByPLC.cs"
index a53a36e..b7698c4 100644
--- "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_PackBarCodeBill_automaticallyByPLC.cs"
+++ "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_PackBarCodeBill_automaticallyByPLC.cs"
@@ -10,6 +10,7 @@
 using System.Linq;
 using System.Text;
 using System.Windows.Forms;
+using Microsoft.VisualBasic;
 
 namespace WarM.鏉$爜鎵撳嵃
 {
@@ -71,6 +72,10 @@
         public bool BillChange;   //
         public bool grdStatus;
         public int selectRow = 0;
+
+        //璁板綍褰撳墠缁勬墭鐨勬潯鐮佺殑婧愬崟ID銆佸瓙ID锛岀敤浜庝繚璇佸綋鍓嶆墭涓墍鏈夊瓙鏉$爜涓哄悓涓�涓伐鍗曠敓鎴�
+        public int HSourceInterID_ICMO = 0;
+        public int HSourceEntryID_ICMO = 0;
 
         private void Gy_PackBarCodeBill_automaticallyByPLC_Load(object sender, EventArgs e)
         {
@@ -181,6 +186,11 @@
             DBUtility.Xt_BaseBillFun.initGridList(grdSub, this.Name + "grdSub");
 
             getDisplay_GrdMain();
+
+            if (grdMain.Rows.Count > 0 && grdMain.Rows[0].Cells[4].Value!=null)
+            {
+                getPackQty(grdMain.Rows[0].Cells[4].Value.ToString());
+            }
         }
 
 
@@ -355,7 +365,11 @@
                     return;
                 }
                 this.Sub_SaveBill();
-            }catch(Exception ex)
+
+                //缁勬墭鎴愬姛鍚庯紝娓呯┖缁勬墭鏁伴噺涓庢簮鍗曚俊鎭�
+                set_clearPackQtyAndSourceInfo();
+            }
+            catch(Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
@@ -364,11 +378,11 @@
         //鑷姩缁勬墭 
         private void button_startListen_Click(object sender, EventArgs e)
         {
-            if (DBUtility.ClsPub.isLong(textBox_PackQty.Text) == 0)
-            {
-                MessageBox.Show("璇疯缃墭鏉$爜鐨勬渶灏忓寘瑁呮暟锛�");
-                return;
-            }
+            //if (DBUtility.ClsPub.isLong(textBox_PackQty.Text) == 0)
+            //{
+            //    MessageBox.Show("璇疯缃墭鏉$爜鐨勬渶灏忓寘瑁呮暟锛�");
+            //    return;
+            //}
 
             isStartListen = 1;
 
@@ -432,6 +446,9 @@
                             Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(榛樿)", "");
                         }
                         Report.Print(false);
+
+                        //缁勬墭鎴愬姛鍚庯紝娓呯┖缁勬墭鏁伴噺涓庢簮鍗曚俊鎭�
+                        set_clearPackQtyAndSourceInfo();
                     }
                 }catch(Exception ex)
                 {
@@ -464,6 +481,8 @@
                 return true;
             }catch(Exception ex)
             {
+                string sql = "exec h_p_WMS_PackBarCodeBill_dealDataWhenError '" + textBox_HPackBarCode + "'";
+                oCn.RunProc(sql);
                 throw new Exception(ex.Message);
             }
             
@@ -746,11 +765,23 @@
             {
                 if (e.KeyChar == (char)Keys.Return)
                 {
+                    //闃查敊鍒ゆ柇
+                    if(!judgeIsSameSourceBill(textBox_HBarCode.Text.Trim()))
+                    {
+                        textBox_HBarCode.Text = "";
+                        return;
+                    }
+
                     SetBarCode_Webs();
                     textBox_HBarCode.Text = "";
                     textBox_HBarCode.Focus();
 
                     autoProducePackBarCode();
+
+                    if (grdMain.Rows.Count ==1 )
+                    {
+                        getPackQty(grdMain.Rows[0].Cells[4].Value.ToString());
+                    }
                 }
             }
             catch (Exception e2)
@@ -1135,6 +1166,11 @@
         private void toolStripButton_Delete_Click(object sender, EventArgs e)
         {
             deleteGrdMainNote();
+
+            if (grdMain.Rows.Count== 0)
+            {
+                set_clearPackQtyAndSourceInfo();
+            }
         }
         #endregion
 
@@ -1145,14 +1181,29 @@
         {
             if (grdMain.SelectedRows != null && grdMain.SelectedRows.Count==1)
             {
-                if (MessageBox.Show("纭畾瑕佸垹闄わ紵", "鎻愮ず", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Cancel)
+                //if (MessageBox.Show("纭畾瑕佸垹闄わ紵", "鎻愮ず", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Cancel)
+                //{
+                //    return;
+                //}
+                //if (MessageBox.Show("鍒犻櫎鍚庡皢涓嶅彲鎭㈠锛岀‘瀹氳缁х画鎿嶄綔锛�", "鎻愮ず", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Cancel)
+                //{
+                //    return;
+                //}
+
+                string pwd = Interaction.InputBox("璇疯緭鍏ュ瘑鐮�", "鍒犻櫎纭锛�", "", 100, 100);
+
+                //鐐瑰嚮鍙栨秷
+                if(pwd == "")
                 {
                     return;
                 }
-                if (MessageBox.Show("鍒犻櫎鍚庡皢涓嶅彲鎭㈠锛岀‘瀹氳缁х画鎿嶄綔锛�", "鎻愮ず", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Cancel)
+
+                if(pwd != "123456")
                 {
+                    MessageBox.Show("瀵嗙爜閿欒锛�");
                     return;
                 }
+
                 Delete();
             }
             else
@@ -1228,6 +1279,9 @@
                 Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(榛樿)", "");
             }
             Report.Print(false);
+
+            //缁勬墭鎴愬姛鍚庯紝娓呯┖缁勬墭鏁伴噺涓庢簮鍗曚俊鎭�
+            set_clearPackQtyAndSourceInfo();
         }
         #endregion
 
@@ -1367,6 +1421,7 @@
 
                 //鑾峰彇缂撳瓨鍒楄〃涓� 鎵樻潯鐮� 瀵瑰簲鐨� 缁勬墭璁板綍
                 sql = "select top(1) a.* from Sc_PackUnionBill_Temp as a inner join Gy_BarCodeBill as b on a.HBarCode = b.HBarCode where a.HBarCode_Pack = '" + HPackBarCode + "' and b.HSourceID = " + HSourceID + " and a.HStockorgID = " + HOrgID;
+                //sql = "select top(1) a.* from Sc_PackUnionBill_Temp as a where a.HBarCode_Pack = '" + HPackBarCode + "' and a.HStockorgID = " + HOrgID;
                 ds = oCn.RunProcReturn(sql, "Sc_PackUnionBill_Temp");
                 if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
@@ -1384,13 +1439,83 @@
                     textBox_sBillNo.Text = HBillNo;
 
                     getDisplay_GrdMain();
+
+                    if (grdMain.Rows.Count > 0 && grdMain.Rows[0].Cells[4].Value != null)
+                    {
+                        getPackQty(grdMain.Rows[0].Cells[4].Value.ToString());
+                    }
                 }
+
+
             }
         }
         #endregion
         #endregion
 
 
+        #region 鏍规嵁鏉$爜缂栧彿锛岃幏鍙栨潯鐮佷腑鐗╂枡鎵�瀵瑰簲鐨勭粍鎵樻暟閲忥紝鍚屾椂璁板綍婧愬崟涓籌D銆佸瓙ID
+        private void getPackQty(string HBarCode)
+        {
+            string sql = "select * from h_v_IF_BarCodeBillList_getPackQty where 鏉$爜缂栧彿 = '" + HBarCode + "'";
+            DataSet ds_getPackQty = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList_getPackQty");
+            if (ds_getPackQty == null || ds_getPackQty.Tables[0].Rows.Count <= 0)
+            {
+                HSourceInterID_ICMO = 0;
+                HSourceEntryID_ICMO = 0;
+
+                textBox_PackQty.Text = "";
+                return;
+            }
+
+            HSourceInterID_ICMO = int.Parse(ds_getPackQty.Tables[0].Rows[0]["HSourceInterID"].ToString());
+            HSourceEntryID_ICMO = int.Parse(ds_getPackQty.Tables[0].Rows[0]["HSourceEntryID"].ToString());
+            textBox_PackQty.Text = Double.Parse(ds_getPackQty.Tables[0].Rows[0]["缁勬墭鏁伴噺"].ToString()).ToString();
+        }
+        #endregion
+
+        #region 鍒ゆ柇褰撳墠鎵弿鐨勬潯鐮佹槸鍚︿笌宸茬粡鎵弿杩囩殑鏉$爜涓哄悓涓�宸ュ崟鐢熸垚鐨�
+        private bool judgeIsSameSourceBill(string HBarCode)
+        {
+            if (grdMain.Rows.Count == 0)
+            {
+                return true;
+            }
+            else
+            {
+                string sql = "select * from h_v_IF_BarCodeBillList_getPackQty where 鏉$爜缂栧彿 = '" + HBarCode + "'";
+                DataSet ds_getPackQty = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList_getPackQty");
+                if (ds_getPackQty == null || ds_getPackQty.Tables[0].Rows.Count <= 0)
+                {
+                    MessageBox.Show("褰撳墠鏉$爜涓嶅瓨鍦紒");
+                    return false;
+                }
+                else
+                {
+                    int HSourceInterID_ICMO_Bak = int.Parse(ds_getPackQty.Tables[0].Rows[0]["HSourceInterID"].ToString());
+                    int HSourceEntryID_ICMO_Bak = int.Parse(ds_getPackQty.Tables[0].Rows[0]["HSourceEntryID"].ToString());
+                    if (HSourceInterID_ICMO != HSourceInterID_ICMO_Bak || HSourceEntryID_ICMO != HSourceEntryID_ICMO_Bak)
+                    {
+                        MessageBox.Show("褰撳墠鎵弿鐨勬潯鐮佷笌涔嬪墠鎵�鎵弿鐨勬潯鐮佸伐鍗曚笉涓�鑷达紒");
+                        return false;
+                    }
+                    else
+                    {
+                        return true;
+                    }
+                }
+            }
+        }
+        #endregion
+
+        #region 娓呯┖ 缁勬墭鏁伴噺 涓庤褰曠殑婧愬崟涓籌D銆佸瓙ID
+        private void set_clearPackQtyAndSourceInfo()
+        {
+            textBox_PackQty.Text = "";
+            HSourceInterID_ICMO = 0;
+            HSourceEntryID_ICMO = 0;
+        }
+        #endregion
+
     }
 }
 

--
Gitblit v1.9.1