From fd2d833bf010d0be1bb308d9c431eee1dfd931ff Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期五, 20 十二月 2024 16:46:53 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WarM/条码打印/Kf_WeighToBarCode.cs |  285 ++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 233 insertions(+), 52 deletions(-)

diff --git "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Kf_WeighToBarCode.cs" "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Kf_WeighToBarCode.cs"
index 06a734f..8cb2d8a 100644
--- "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Kf_WeighToBarCode.cs"
+++ "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Kf_WeighToBarCode.cs"
@@ -28,6 +28,8 @@
         public Int64 HInterID = 0;
         public string HBillNo = "";
         public string HBillType = "1202";
+        public Int64 HMaterID = 0;
+        public string HBatchNo = "";
         public Int64 HAuxPropID = 0;
         public Int64 HUnitID = 0;
         public Int64 HWhID = 0;
@@ -48,6 +50,8 @@
         public string PrintQtyCtl = "";         //鏉$爜鎵撳嵃娆℃暟鎺у埗
         public string UpdatePrintQtyCtl = "";   //鏉$爜鎵撳嵃娆℃暟鏇存柊
         public string sBarCodeItemID = "";      //鏉$爜鑷鍒�
+        public string HBarCode_Pack = "";       //鎵樻潯鐮�
+        public long HSNo = 0;                   //缁勬墭璁℃暟鐢�
         public DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
         public DBUtility.ClsPub.Enum_BillStatus BillStatus;
         SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
@@ -113,11 +117,15 @@
             {
                 HInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo);           //寰楀埌鏂板崟鎹甀D
                 HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);    //寰楀埌鏂板崟鎹彿
+                HSNo = 0;
+                this.lblSNo.Text = "";
             }
             else if (DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HBack"]) == 1)
             {
                 HInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo);           //寰楀埌鏂板崟鎹甀D
                 HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);    //寰楀埌鏂板崟鎹彿
+                HSNo = 0;
+                this.lblSNo.Text = "";
             }
             else
             {
@@ -129,7 +137,7 @@
             if (grdSub.Rows.Count > 0)
             {
                 grdSub.Rows[0].Selected = true;
-                SourceBill();
+                SourceBill(1);
                 txtHQty.Focus();
             }
             else
@@ -328,6 +336,12 @@
                 return false;
             }
 
+            if (DBUtility.ClsPub.isStrNull(txtHBarCode_Pack.Text) != "")
+            {
+                MessageBox.Show("褰撳墠缁勬墭鏈粨鏉燂紝璇风粨鏉熺粍鎵樺悗鍐嶇偣鍑绘崲鐝紒", "鎻愮ず");
+                return false;
+            }
+
             //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
             string s = "";
             int sYear = 0;
@@ -413,8 +427,7 @@
                 }
                 Source_Display();
                 grdSub.Rows[0].Selected = true;
-                DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
-                SourceBill();
+                SourceBill(2);
                 txtHBarCode.Text = "";
                 txtHQty.Focus();
             }
@@ -430,8 +443,7 @@
             }
             Source_Display();
             grdSub.Rows[0].Selected = true;
-            DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
-            SourceBill();
+            SourceBill(2);
             txtHBarCode.Text = "";
             txtHQty.Focus();
         }
@@ -462,11 +474,6 @@
 
         private void cmdSourceBillNo_Click(object sender, EventArgs e)
         {
-            //鍒濆鍖栧彸杈硅〃澶翠俊鎭�
-            cmbHBarCodeType.Items.Clear();
-            cmbHBarCodeType.Items.Add("鍞竴鏉$爜");
-            DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
-
             if (grdSub.CurrentRow == null)
             {
                 MessageBox.Show("璇峰湪宸﹁竟鍗曟嵁鍒楄〃涓�夋嫨涓�琛屽崟鎹紒", "鎻愮ず");
@@ -479,7 +486,7 @@
             }
             else
             {
-                SourceBill();
+                SourceBill(3);
                 txtHQty.Focus();
             }
         }
@@ -496,6 +503,10 @@
             }
             SaveBarCode();
             BarCode_Display();
+            if (DBUtility.ClsPub.isStrNull(txtHBarCode_Pack.Text) != "")
+            {
+                this.lblSNo.Text = "褰撳墠宸茬粍 " + HSNo + " 浠�";
+            }
             grdMain.Rows[0].Selected = true;
 
             sBarCodeItemID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[0].Index].Cells[Fun_GetCol("HItemID")].Value).ToString();
@@ -703,7 +714,6 @@
             Int64 HBadReasonID = 0;     //涓嶈壇鍘熷洜ID
             string HCusMaterName = "";  //瀹㈡埛鐗╂枡鍚嶇О
             string HCusModel = "";      //瀹㈡埛瑙勬牸鍨嬪彿
-            string HBarCode_Pack = "";  //鎵樼洏鏉$爜
 
             HBarCode = TM;
             HBarCodeType = DBUtility.ClsPub.isStrNull(cmbHBarCodeType.Text);
@@ -720,7 +730,10 @@
             HBadReasonID = DBUtility.ClsPub.isLong(txtHRemark.Tag);
             HCusMaterName = DBUtility.ClsPub.isStrNull(txtHCusMaterName.Text);
             HCusModel = DBUtility.ClsPub.isStrNull(txtHCusModel.Text);
-            HBarCode_Pack = DBUtility.ClsPub.isStrNull(txtHBarCode_Pack.Text);
+            if (HBarCode_Pack != "")
+            {
+                HSNo = HSNo + 1;
+            }
 
             try
             {
@@ -734,7 +747,7 @@
                 ",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate,HMaterialJQty,HMaterialMQty,HNowQty " +
                 ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HGiveAwayFlag,HBarCode_Pack " +
                 ",HOrderInterID,HOrderEntryID,HOrderBillNo,HCustomQty1,HMaterialModel,HCusModel " +
-                ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HLogo " +
+                ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HLogo,HPackflag " +
                 ") Values ("
                 + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
                 + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + HMaker + "',getdate(),0," + HQty.ToString()
@@ -743,7 +756,7 @@
                 + ", 0,'',getdate(),'','" + sDate + "'," + HMaterialJQty.ToString() + "," + HMaterialMQty.ToString() + "," + HNowQty.ToString()
                 + ", " + HStockOrgID.ToString() + "," + HStockOrgID.ToString() + ",''," + HInterID.ToString() + ",0,'" + HBarCode_Pack + "'"
                 + ", " + HProcessExchangeInterID.ToString() + ",0,'" + HProcessExchangeBillNo + "'," + HBadReasonID.ToString() + ",'" + HCusMaterName + "','" + HCusModel + "'"
-                + ",'" + HMaterName + "','" + HMaterModel + "',''," + HAuxPropID.ToString() + ",'','','1')");
+                + ",'" + HMaterName + "','" + HMaterModel + "',''," + HAuxPropID.ToString() + ",'','','1',0)");
 
                 //鍥炲~鏈�澶ф祦姘村彿
                 oCn.RunProc("exec h_p_WMS_SetMaxNo_QTY '" + sTMNumber + "',1 ");
@@ -782,9 +795,53 @@
 
         #region  //杩斿洖淇℃伅
 
-        //杩斿洖婧愬崟鍒楄〃淇℃伅
-        private void SourceBill()
+        //杩斿洖婧愬崟鍒楄〃淇℃伅(num=1锛屾墦寮�妯″潡鏃跺姞杞芥樉绀猴紱num=2锛屾壂娴佽浆鍗℃樉绀猴紱num=3锛岄�夊崟鎸夐挳鏄剧ず)
+        private void SourceBill(int num)
         {
+            //鎵撳紑妯″潡鏃跺姞杞芥樉绀�
+            if (num == 1)
+            {
+                txtHBarCode_Pack.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HBarCode_Pack")].Value);
+                HBarCode_Pack = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HBarCode_Pack")].Value);
+                HSNo = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSNo")].Value);
+                if (HBarCode_Pack == "")
+                {
+                    this.lblSNo.Text = "";
+                }
+                else
+                {
+                    this.lblSNo.Text = "褰撳墠宸茬粍 " + HSNo + " 浠�";
+                    cmdHBPack.Enabled = false;
+                }
+            }
+            //鎵祦杞崱鏄剧ず
+            if (num == 2)
+            {
+                //鍒濆鍖栧彸杈硅〃澶翠俊鎭�
+                DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
+                if (HBarCode_Pack != "")
+                {
+                    txtHBarCode_Pack.Text = HBarCode_Pack;
+                    this.lblSNo.Text = "褰撳墠宸茬粍 " + HSNo + " 浠�";
+                }
+            }
+            //閫夊崟鎸夐挳鏄剧ず
+            if (num == 3)
+            {
+                if (HBarCode_Pack != "" && (HMaterID != DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HMaterID")].Value)
+                    || HBatchNo != DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("鎵瑰彿")].Value)))
+                {
+                    MessageBox.Show("鎵�鎵弿娴佽浆鍗″搴旂墿鏂欍�佹壒鍙蜂笌褰撳墠姝e湪缁勬墭鐗╂枡銆佹壒鍙蜂笉涓�鑷达紝涓嶅悓鐗╂枡銆佹壒鍙蜂笉鍏佽缁勬墭鍦ㄥ悓涓�鎵樹笂锛屽闇�鎹㈢墿鏂欑敓鎴愭潯鐮佽鍏堢粨鏉熷綋鍓嶇粍鎵橈紒", "鎻愮ず");
+                    return;
+                }
+                //鍒濆鍖栧彸杈硅〃澶翠俊鎭�
+                DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
+                if (HBarCode_Pack != "")
+                {
+                    txtHBarCode_Pack.Text = HBarCode_Pack;
+                    this.lblSNo.Text = "褰撳墠宸茬粍 " + HSNo + " 浠�";
+                }
+            }
             txtHBillNo.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("鍗曟嵁鍙�")].Value);
             txtHDeptName.Tag = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HDeptID")].Value);
             txtHDeptName.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("杞﹂棿")].Value);
@@ -795,6 +852,8 @@
             txtHBatchNo.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("鎵瑰彿")].Value);
             txtHCusMaterName.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HCusMaterName")].Value);
             txtHCusModel.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HCusModel")].Value);
+            HMaterID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HMaterID")].Value);
+            HBatchNo = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("鎵瑰彿")].Value);
             HAuxPropID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HAuxPropID")].Value);
             HUnitID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HUnitID")].Value);
             HWhID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HWhID")].Value);
@@ -874,6 +933,7 @@
                     string HItemID = "";
                     string HBarCode = "";
                     string HBarCode2 = "";
+                    long HSNo_Temp = HSNo;
                     for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
                     {
                         HItemID = HItemID + "," + DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("hmainid")].Value.ToString());
@@ -890,14 +950,35 @@
                         {
                             HRemark = HRemark + "銆�" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
                         }
+                        //鏇存柊褰撳墠宸茬粍鎵樹欢鏁�
+                        if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("HBarCode_Pack")].Value) != ""
+                            && DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("HBarCode_Pack")].Value) == HBarCode_Pack
+                            && DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜绫诲瀷")].Value) != "鎵樼洏鏉$爜")
+                        {
+                            HSNo = HSNo - 1;
+                        }
                         if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜绫诲瀷")].Value) == "鎵樼洏鏉$爜")
                         {
-                            MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value) + " 涓烘墭鐩樻潯鐮侊紝涓嶅厑璁镐綔搴燂紒", "鎻愮ず");
-                            return;
+                            if (DBUtility.ClsPub.isBool(grdMain.SelectedRows[i].Cells[Fun_GetCol("HPackflag")].Value))
+                            {
+                                MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value) + " 涓烘墭鐩樻潯鐮侊紝涓斿凡缁勬墭鐢熸垚瀵瑰簲缁勬墭鍗曪紝涓嶅厑璁镐綔搴燂紒", "鎻愮ず");
+                                return;
+                            }
+                            else if (HSNo > 0)
+                            {
+                                MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value) + " 涓烘墭鐩樻潯鐮侊紝涓斿綋鍓嶆墭鐩樻潯鐮佷笅宸茬敓鎴愬搴旀潯鐮侊紝涓嶅厑璁镐綔搴燂紒", "鎻愮ず");
+                                return;
+                            }
+                            else
+                            {
+                                HBarCode_Pack = "";
+                            }
                         }
                     }
                     if (HRemark != "")
                     {
+                        HSNo = HSNo_Temp;
+                        HBarCode_Pack = DBUtility.ClsPub.isStrNull(txtHBarCode_Pack.Text);
                         MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細"+ HRemark.Remove(0, 1)+" 宸蹭綔搴燂紝涓嶅厑璁搁噸澶嶄綔搴燂紒", "鎻愮ず");
                         return;
                     }
@@ -925,11 +1006,23 @@
                     catch (Exception e2)
                     {
                         oCn.RollBack();
+                        HSNo = HSNo_Temp;
+                        HBarCode_Pack = DBUtility.ClsPub.isStrNull(txtHBarCode_Pack.Text);
                         MessageBox.Show("浣滃簾鏉$爜澶辫触锛�" + e2.Message, "鎻愮ず");
                         return;
                     }
                     //鍒锋柊绉伴噸璁板綍鍒楄〃淇℃伅
                     BarCode_Display();
+                    if (HBarCode_Pack != "")
+                    {
+                        this.lblSNo.Text = "褰撳墠宸茬粍 " + HSNo + " 浠�";
+                    }
+                    else
+                    {
+                        txtHBarCode_Pack.Text = "";
+                        this.lblSNo.Text = "";
+                        cmdHBPack.Enabled = true;
+                    }
                     MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細" + HBarCode.Remove(0, 1) + " 浣滃簾鎴愬姛锛�", "鎻愮ず");
                 }
             }
@@ -957,7 +1050,27 @@
                     string HItemID = "";
                     string HBarCode = "";
                     string HBarCode2 = "";
-                    string HBarCode_Pack = DBUtility.ClsPub.isStrNull(txtHBarCode_Pack.Text);
+                    long HSNo_Temp = HSNo;
+                    bool HFlag = false;
+
+                    //鐣岄潰涓婁负鏈惎鐢ㄧ粍鎵樼姸鎬�
+                    if (HBarCode_Pack == "")
+                    {
+                        for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
+                        {
+                            //鍒ゆ柇鏉$爜鏄惁涓烘墭鐩樻潯鐮侊紝鏈敓鎴愮粍鎵樺崟锛屽凡浣滃簾鐘舵�侊紝鐣岄潰涓婁负鏈粍鎵樼姸鎬�
+                            if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜绫诲瀷")].Value) == "鎵樼洏鏉$爜"
+                                && DBUtility.ClsPub.isBool(grdMain.SelectedRows[i].Cells[Fun_GetCol("HPackflag")].Value) == false
+                                && DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("浣滃簾鏍囪")].Value) != ""
+                                )
+                            {
+                                HFlag = true;
+                                HBarCode_Pack = DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("HBarCode_Pack")].Value);
+                                break;
+                            }
+                        }
+                    }
+
                     for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
                     {
                         HItemID = HItemID + "," + DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("hmainid")].Value.ToString());
@@ -974,20 +1087,44 @@
                         {
                             HRemark = HRemark + "銆�" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
                         }
-                        if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜绫诲瀷")].Value) == "鎵樼洏鏉$爜")
+
+                        //鏉$爜涓虹粍鎵樻潯鐮�
+                        if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("HBarCode_Pack")].Value) != "")
                         {
-                            MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value) + " 涓烘墭鐩樻潯鐮侊紝涓嶅厑璁稿弽浣滃簾锛�", "鎻愮ず");
-                            return;
-                        }
-                        if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("HBarCode_Pack")].Value) != ""
-                            && DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("HBarCode_Pack")].Value) != HBarCode_Pack)
-                        {
-                            MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value) + " 宸茬敓鎴愬搴旂粍鎵樺崟锛屼笉鍏佽鍙嶄綔搴燂紒", "鎻愮ず");
-                            return;
+                            //宸蹭笂浼犵敓鎴愮粍鎵樺崟
+                            if (DBUtility.ClsPub.isBool(grdMain.SelectedRows[i].Cells[Fun_GetCol("HPackflag")].Value))
+                            {
+
+                            }
+                            //鏈笂浼犵敓鎴愮粍鎵樺崟
+                            else
+                            {
+                                //鏉$爜瀵瑰簲鎵樻潯鐮佸拰鐣岄潰涓婄殑鎵樻潯鐮佷竴鑷�
+                                if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("HBarCode_Pack")].Value) == HBarCode_Pack)
+                                {
+                                    //鏇存柊褰撳墠宸茬粍鎵樹欢鏁�
+                                    if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜绫诲瀷")].Value) != "鎵樼洏鏉$爜")
+                                    {
+                                        HSNo = HSNo + 1;
+                                    }
+
+                                }
+                                //鏉$爜瀵瑰簲鎵樻潯鐮佸拰鐣岄潰涓婄殑鎵樻潯鐮佷笉涓�鑷�
+                                else
+                                {
+                                    MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value) + " 瀵瑰簲鎵樻潯鐮侊細" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("HBarCode_Pack")].Value) + " 宸茬敓鎴愮粍鎵樺崟锛屾垨宸蹭綔搴燂紝涓嶅厑璁稿弽浣滃簾锛�", "鎻愮ず");
+                                    return;
+                                }
+                            }
                         }
                     }
                     if (HRemark != "")
                     {
+                        HSNo = HSNo_Temp;
+                        if(HFlag)
+                        {
+                            HBarCode_Pack = "";
+                        }
                         MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細" + HRemark.Remove(0, 1) + " 鏈綔搴燂紝涓嶅厑璁稿弽浣滃簾锛�", "鎻愮ず");
                         return;
                     }
@@ -1023,7 +1160,7 @@
                         ",0,0,'',0,'',0" +
                         ",HSTOCKORGID,HSTOCKORGID,HSTOCKORGID,'','绉伴噸鍏ュ簱鐢熸垚-鍙嶄綔搴�','2'" +
                         ",0,0,'',0" +
-                        "from Gy_BarCodeBill with(nolock) where HItemID in (" + HItemID + ")"
+                        "from Gy_BarCodeBill with(nolock) where HItemID in (" + HItemID + ") and HBarCodeType='鍞竴鏉$爜' "
                         );
 
                         //鍐欏叆绯荤粺鏃ュ織
@@ -1036,11 +1173,28 @@
                     catch (Exception e2)
                     {
                         oCn.RollBack();
+                        HSNo = HSNo_Temp;
+                        if (HFlag)
+                        {
+                            HBarCode_Pack = "";
+                        }
                         MessageBox.Show("鍙嶄綔搴熸潯鐮佸け璐ワ紒" + e2.Message, "鎻愮ず");
                         return;
                     }
                     //鍒锋柊绉伴噸璁板綍鍒楄〃淇℃伅
                     BarCode_Display();
+                    if (HBarCode_Pack != "")
+                    {
+                        txtHBarCode_Pack.Text = HBarCode_Pack;
+                        this.lblSNo.Text = "褰撳墠宸茬粍 " + HSNo + " 浠�";
+                        cmdHBPack.Enabled = false;
+                    }
+                    else
+                    {
+                        txtHBarCode_Pack.Text = "";
+                        this.lblSNo.Text = "";
+                        cmdHBPack.Enabled = true;
+                    }
                     MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細" + HBarCode.Remove(0, 1) + " 鍙嶄綔搴熸垚鍔燂紒", "鎻愮ず");
                 }
             }
@@ -1069,23 +1223,25 @@
             {
                 return;
             }
+            HSNo = 0;
             SavePackBarCode();
             BarCode_Display();
+            this.lblSNo.Text = "褰撳墠宸茬粍 " + HSNo + " 浠�";
             grdMain.Rows[0].Selected = true;
-
             txtHBarCode_Pack.Text = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.SelectedRows[0].Index].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
+            HBarCode_Pack = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.SelectedRows[0].Index].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
             cmdHBPack.Enabled = false;
 
             sBarCodeItemID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[0].Index].Cells[Fun_GetCol("HItemID")].Value).ToString();
             //鑷姩鎵撳嵃
-            if (chkHDYFlag.Checked == true)
-            {
-                //鎵撳嵃鏉$爜
-                Sub_SetReport("鎵樼洏鏉$爜");
-                Report.Print(false);
-                Thread.Sleep(1000);
-            }
-            else
+            //if (chkHDYFlag.Checked == true)
+            //{
+            //    //鎵撳嵃鏉$爜
+            //    Sub_SetReport("鎵樼洏鏉$爜");
+            //    Report.Print(false);
+            //    Thread.Sleep(1000);
+            //}
+            //else
             {
                 //閫夋嫨鎵撳嵃妯℃澘
                 BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
@@ -1118,6 +1274,11 @@
             if (HInterID == 0 || HBillNo == "")
             {
                 MessageBox.Show("鑾峰彇鏉$爜瀵瑰簲鍗曟嵁ID鎴栧崟鎹彿澶辫触锛岃閲嶆柊鍒锋柊鐣岄潰锛�", "鎻愮ず");
+                return false;
+            }
+            if (HProcessExchangeInterID == 0)
+            {
+                MessageBox.Show("璇峰厛鎵弿娴佽浆鍗″彿锛�", "鎻愮ず");
                 return false;
             }
             return true;
@@ -1158,10 +1319,24 @@
             TM = sTMNumber + LSH2;
 
             string HBarCode = "";
-            string HBarCodeType = "鎵樼洏鏉$爜";
+            string HBarCodeType = "";
+            string HMaterID = "";       //鐗╂枡鍐呯爜
+            string HBatchNo = "";       //鎵规
+            string HMaterName = "";
+            string HMaterModel = "";
+            string HProcessExchangeBillNo = "";
+            string HCusMaterName = "";  //瀹㈡埛鐗╂枡鍚嶇О
+            string HCusModel = "";      //瀹㈡埛瑙勬牸鍨嬪彿
 
             HBarCode = TM;
-            HBarCodeType = "";
+            HBarCodeType = "鎵樼洏鏉$爜";
+            HMaterID = DBUtility.ClsPub.isStrNull(txtHMaterNumber.Tag);
+            HBatchNo = DBUtility.ClsPub.isStrNull(txtHBatchNo.Text);
+            HMaterName = DBUtility.ClsPub.isStrNull(txtHMaterName.Text);
+            HMaterModel = DBUtility.ClsPub.isStrNull(txtHMaterModel.Text);
+            HProcessExchangeBillNo = DBUtility.ClsPub.isStrNull(txtHBillNo.Text);
+            HCusMaterName = DBUtility.ClsPub.isStrNull(txtHCusMaterName.Text);
+            HCusModel = DBUtility.ClsPub.isStrNull(txtHCusModel.Text);
 
             try
             {
@@ -1175,16 +1350,16 @@
                 ",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate,HMaterialJQty,HMaterialMQty,HNowQty " +
                 ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HGiveAwayFlag " +
                 ",HOrderInterID,HOrderEntryID,HOrderBillNo,HCustomQty1,HMaterialModel,HCusModel " +
-                ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HLogo " +
+                ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HLogo,HPackflag " +
                 ") Values ("
-                + "'" + HBarCode + "','" + HBarCodeType + "',0,0,1,'" + HBarCode + "'"
-                + ",'',0,0,'" + HMaker + "',getdate(),0,1"
-                + ",0,0,'','',''"
+                + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + ",1,'" + HBarCode + "'"
+                + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + HMaker + "',getdate(),0,1"
+                + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "',''"
                 + ",1,0,0,0,0,''"
                 + ", 0,'',getdate(),'','" + sDate + "',0,0,0"
                 + ", " + HStockOrgID.ToString() + "," + HStockOrgID.ToString() + ",''," + HInterID.ToString() + ",0"
-                + ", " + HProcessExchangeInterID.ToString() + ",0,'',0,'',''"
-                + ",'','','',0,'','','1')");
+                + ", " + HProcessExchangeInterID.ToString() + ",0,'" + HProcessExchangeBillNo + "',0,'" + HCusMaterName + "','" + HCusModel + "'"
+                + ",'" + HMaterName + "','" + HMaterModel + "',''," + HAuxPropID.ToString() + ",'','','1',0)");
 
                 //鍥炲~鏈�澶ф祦姘村彿
                 oCn.RunProc("exec h_p_WMS_SetMaxNo_QTY '" + sTMNumber + "',1 ");
@@ -1203,8 +1378,6 @@
         #region  //缁撴潫缁勬墭
         private void cmdHEPack_Click(object sender, EventArgs e)
         {
-            string HBarCode_Pack = DBUtility.ClsPub.isStrNull(txtHBarCode_Pack.Text);
-
             //鐢熸垚缁勬墭鍗曞墠鍒ゆ柇
             if(HBarCode_Pack=="")
             {
@@ -1215,7 +1388,8 @@
             for (int i = 0; i < grdMain.RowCount; i++)
             {
                 if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("鏉$爜绫诲瀷")].Value) == "鍞竴鏉$爜"
-                    && DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("HBarCode_Pack")].Value) == HBarCode_Pack)
+                    && DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("HBarCode_Pack")].Value) == HBarCode_Pack
+                    && DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("浣滃簾鏍囪")].Value) == "")
                 {
                     b = true;
                     break;
@@ -1261,18 +1435,25 @@
                 ",HAuxPropID,HBatchNo,HMTONo" +
                 ",HSourceID,HEquipID,HGroupID,HWorkerID,HStatus" +
                 ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType) " +
-                " select " + HPUInterID.ToString() + ",HItemID,'0,0,''" +
+                " select " + HPUInterID.ToString() + ",HItemID,0,0,''" +
                 ",HMaterID,HUnitID,HQty,HBarCode,HBarCode_Pack,getdate()" +
                 ",HAuxPropID,HBatchNo,HMTONo" +
                 ",0,0,0,0,0" +
                 ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" +
-                "from Gy_BarCodeBill with(nolock) where HInterID=" + HInterID.ToString() + " and HBarCode_Pack='" + HBarCode_Pack + "' and HStopflag=0"
+                " from Gy_BarCodeBill with(nolock) where HInterID=" + HInterID.ToString() + " and HBarCode_Pack='" + HBarCode_Pack + "' and HStopflag=0 and HBarCodeType='鍞竴鏉$爜' "
                 );
+
+                //鍥炲~鏉$爜妗f缁勬墭鏍囪
+                oCn.RunProc("update Gy_BarCodeBill set HPackflag=1 where HInterID=" + HInterID.ToString() + " and HBarCode_Pack='" + HBarCode_Pack + "' and HStopflag=0", ref DBUtility.ClsPub.sExeReturnInfo);
 
                 MessageBox.Show("鐢熸垚鐢熶骇缁勬墭鍗曪細" + HPUBillNo + " 鎴愬姛锛�", "鎻愮ず");
 
                 txtHBarCode_Pack.Text = "";
+                HBarCode_Pack = "";
                 cmdHBPack.Enabled = true;
+                HSNo = 0;
+                this.lblSNo.Text = "";
+                BarCode_Display();
                 oCn.Commit();
                 return;
             }

--
Gitblit v1.9.1