From 838ed2eabcac0a0f5daa13bb4f0e46b745edca0a Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期四, 31 八月 2023 10:49:45 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WarM/条码打印/Kf_WeighToBarCode.cs |  325 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 309 insertions(+), 16 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 986de11..cbb25c7 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"
@@ -21,7 +21,6 @@
             InitializeComponent();
         }
         public frmBillQueryCondition_New frmCondition;
-        public string ViewName = "Sc_ICMOBillStatus_Tmp";
         public string ModCaption = "绉伴噸鍏ュ簱";
         public const string ModName = "85";
         public Int64 HInterID = 0;
@@ -36,7 +35,10 @@
         public Int64 HSourceEntryID = 0;
         public string HSourceBillNo = "";
         public string HSourceBillType = "";
+        public Int64 ProcessExchangeInterID = 0;
+        public Int64 HSupID = 0;
         public double HSourceQty = 0;
+        public double HMaterWeight = 0;         //鐗╂枡鍏嬮噸
         public string HMaker = DBUtility.ClsPub.CurUserName;
         public Int64 HStockOrgID = DBUtility.ClsPub.HOrgID;
         public DateTime HDate = DateTime.Today;
@@ -56,8 +58,10 @@
             cmbHBarCodeType.Items.Clear();
             cmbHBarCodeType.Items.Add("鍞竴鏉$爜");
             DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
+            txtHBarCode.Text = "";
             grdMain.DataSource = null;
             grdSub.DataSource = null;
+            chkHDYFlag.Checked = true;
         }
 
         //绐椾綋鍔犺浇
@@ -65,7 +69,6 @@
         {
             frmCondition = new frmBillQueryCondition_New();
             this.Text = ModCaption;
-            initGrid();
             Sub_GetSystemParameter();
         }
 
@@ -106,6 +109,11 @@
                 HInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo);           //寰楀埌鏂板崟鎹甀D
                 HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);    //寰楀埌鏂板崟鎹彿
             }
+            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);    //寰楀埌鏂板崟鎹彿
+            }
             else
             {
                 HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
@@ -130,14 +138,18 @@
             GraphicsGrid();
         }
 
-        private void grdSub_Paint(object sender, PaintEventArgs e)
-        {
-            GraphicsGrid();
-        }
-
         private void GraphicsGrid()
         {
             DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain);
+        }
+
+        private void grdSub_Paint(object sender, PaintEventArgs e)
+        {
+            GraphicsGridSub();
+        }
+
+        private void GraphicsGridSub()
+        {
             DBUtility.Xt_BaseBillFun.GraphicsGrid(grdSub);
         }
 
@@ -298,6 +310,19 @@
 
         private bool Sub_SaveBill()
         {
+            //绉伴噸璁板綍鍒楄〃鏄惁鏈夎褰曞垽鏂�
+            bool b = false;
+            for (int i = 0; i < grdMain.RowCount; i++)
+            {
+                b = true;
+                break;
+            }
+            if (b == false)
+            {
+                MessageBox.Show("褰撳墠绉伴噸璁板綍鍒楄〃鏃犳暟鎹紝涓嶅厑璁告崲鐝敓鎴愬崟鎹紒", "鎻愮ず");
+                return false;
+            }
+
             //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
             string s = "";
             int sYear = 0;
@@ -313,7 +338,16 @@
                 oCn.BeginTran();
                 //鐢熸垚鍑哄叆搴撳崟鎹�
                 //鎻掑叆瀛愯〃
-                oCn.RunProc("EXEC h_p_Kf_ProductInBillSub_Insert_New " + HInterID.ToString() + ",'" + HBillNo + "','" + HSourceBillType + "'");
+                DataSet ds = oCn.RunProcReturn("EXEC h_p_Kf_ProductInBillSub_Insert_New " + HInterID.ToString() + ",'" + HBillNo + "','" + HSourceBillType + "'", "h_p_Kf_ProductInBillSub_Insert_New");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                }
+                else if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0][0]) != "OK")
+                {
+                    oCn.RollBack();
+                    MessageBox.Show("鐢熸垚鍏ュ簱鍗曞け璐ワ紝褰撳墠绉伴噸璁板綍鍒楄〃鏃犳暟鎹紝涓嶅厑璁告崲鐝敓鎴愬崟鎹紒", "鎻愮ず");
+                    return false;
+                }
                 //鎻掑叆涓昏〃
                 oCn.RunProc("Insert Into Kf_ICStockBillMain " +
                     "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMainSourceBillType" +
@@ -451,15 +485,36 @@
             BarCode_Display();
             grdMain.Rows[0].Selected = true;
 
-            //鎵撳嵃鏉$爜
             sBarCodeItemID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[0].Index].Cells[Fun_GetCol("HItemID")].Value).ToString();
-            Sub_SetReport("鐗╂枡鏉$爜");
-            Report.Print(false);
-            Thread.Sleep(1000);
+            //鑷姩鎵撳嵃
+            if (chkHDYFlag.Checked == true)
+            {
+                //鎵撳嵃鏉$爜
+                Sub_SetReport("鐗╂枡鏉$爜");
+                Report.Print(false);
+                Thread.Sleep(1000);
+            }
+            else
+            {
+                //閫夋嫨鎵撳嵃妯℃澘
+                BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
+                oFrm.sBillName = ModName;
+                oFrm.sBillModel = ModCaption;
+                oFrm.ShowDialog();
+                if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
+                {
+                    Sub_SetReport(oFrm.sOpenTmp);
+                    Report.Print(false);
+                    Thread.Sleep(1000);
+                }
+            }
 
             txtHQty.Text = "";
             txtHWeightQyt.Text = "";
             txtHKDQty.Text = "";
+            txtHBarcodeNo.Text = "";
+            txtHRemark.Text = "";
+            txtHRemark.Tag = 0;
             txtHQty.Focus();
         }
 
@@ -481,6 +536,11 @@
                 MessageBox.Show("璇疯緭鍏ユ纭噸閲忥紒", "鎻愮ず");
                 return false;
             }
+            else if (DBUtility.ClsPub.isInt(txtHBarcodeNo.Text) == 0)
+            {
+                MessageBox.Show("璇疯緭鍏ュ寘鍙凤紒", "鎻愮ず");
+                return false;
+            }
             else if (HWhID==0)
             {
                 MessageBox.Show("鐗╂枡鏈缃粯璁や粨搴擄紝鑾峰彇浠撳簱淇℃伅澶辫触锛岃鍏堣缃墿鏂欓粯璁や粨搴擄紒", "鎻愮ず");
@@ -490,6 +550,22 @@
             {
                 MessageBox.Show("鐗╂枡榛樿浠撳簱鍚敤浜嗕粨浣嶏紝浣嗘湭璁剧疆浠撲綅锛岃幏鍙栦粨浣嶄俊鎭け璐ワ紝璇峰厛璁剧疆鐗╂枡榛樿浠撲綅锛�", "鎻愮ず");
                 return false;
+            }
+
+            //瀹為檯鍏嬮噸=閲嶉噺/绫虫暟*1000锛屽疄闄呭厠閲嶈秴鍑虹墿鏂欑淮鎶ゅ厠閲嶇殑鐧惧垎涔嬩簩鍗佹垨涓嶈冻鐗╂枡缁存姢鍏嬮噸鐨勭櫨鍒嗕箣鍏崄锛岄璀︽彁绀�
+            double sQty = 0;    //瀹為檯鍏嬮噸
+            sQty = DBUtility.ClsPub.isDoule(txtHWeightQyt.Text) / DBUtility.ClsPub.isDoule(txtHQty.Text) * 1000;
+
+            if (sQty > HMaterWeight * 1.2 || sQty < HMaterWeight * 0.8)
+            {
+                if (MessageBox.Show("鐗╂枡缁存姢鍏嬮噸涓猴細"+HMaterWeight.ToString()+ "锛屽疄闄呭厠閲嶄负锛�" + sQty.ToString() + "锛屾墍杈撳叆瀹為檯鍏嬮噸瓒呭嚭鐗╂枡缁存姢鍏嬮噸鐨勭櫨鍒嗕箣浜屽崄鎴栦笉瓒崇墿鏂欑淮鎶ゅ厠閲嶇殑鐧惧垎涔嬪叓鍗侊紝璇锋鏌ヨ緭鍏ョ殑鏁版嵁鏄惁姝g‘锛�", "鎻愮ず", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
+                {
+                    return true;
+                }
+                else
+                {
+                    return false;
+                }
             }
             return true;
         }
@@ -557,6 +633,11 @@
             string HRemark = "";
             string HMaterName = "";
             string HMaterModel = "";
+            string ProcessExchangeBillNo = "";
+            Int64 HBarcodeNo = 0;       //鍖呮暟
+            Int64 HBadReasonID = 0;     //涓嶈壇鍘熷洜ID
+            string HCusMaterName = "";  //瀹㈡埛鐗╂枡鍚嶇О
+            string HCusModel = "";      //瀹㈡埛瑙勬牸鍨嬪彿
 
             HBarCode = TM;
             HBarCodeType = DBUtility.ClsPub.isStrNull(cmbHBarCodeType.Text);
@@ -567,11 +648,16 @@
             HRemark = DBUtility.ClsPub.isStrNull(txtHRemark.Text);
             HMaterName = DBUtility.ClsPub.isStrNull(txtHMaterName.Text);
             HMaterModel = DBUtility.ClsPub.isStrNull(txtHMaterModel.Text);
+            ProcessExchangeBillNo = DBUtility.ClsPub.isStrNull(txtHBillNo.Text);
+            HBarcodeNo = DBUtility.ClsPub.isLong(txtHBarcodeNo.Text);
+            HBadReasonID = DBUtility.ClsPub.isLong(txtHRemark.Tag);
+            HCusMaterName = DBUtility.ClsPub.isStrNull(txtHCusMaterName.Text);
+            HCusModel = DBUtility.ClsPub.isStrNull(txtHCusModel.Text);
 
             try
             {
                 oCn.BeginTran();
-                //鍐欏叆鏉$爜妗f
+                //鍐欏叆鏉$爜妗f    (瀹㈡埛鐗╂枡鍚嶇ОHCusMaterName瀛樺叆HMaterialModel瀛楁锛屽鎴疯鏍煎瀷鍙稨CusModel瀛樺叆HCusModel瀛楁
                 oCn.RunProc("Insert into Gy_BarCodeBill " +
                 "(HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
                 ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
@@ -579,18 +665,23 @@
                 ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
                 ",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate,HMaterialJQty,HMaterialMQty " +
                 ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HGiveAwayFlag " +
+                ",HOrderInterID,HOrderEntryID,HOrderBillNo,HCustomQty1,HMaterialModel,HCusModel " +
                 ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " +
                 ") Values ("
                 + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
-                + ",'" + HBatchNo + "',0,0,'" + HMaker + "',getdate(),0," + HQty.ToString()
+                + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + HMaker + "',getdate(),0," + HQty.ToString()
                 + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "',''"
-                + ", 1,1," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'"
+                + ", 1," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'"
                 + ", 0,'',getdate(),'','" + sDate + "'," + HMaterialJQty.ToString() + "," + HMaterialMQty.ToString()
                 + ", " + HStockOrgID.ToString() + "," + HStockOrgID.ToString() + ",''," + HInterID.ToString() + ",0"
+                + ", " + ProcessExchangeInterID.ToString() + ",0,'" + ProcessExchangeBillNo + "'," + HBadReasonID.ToString() + ",'" + HCusMaterName + "','" + HCusModel + "'"
                 + ",'" + HMaterName + "','" + HMaterModel + "',''," + HAuxPropID.ToString() + ",'','')");
 
                 //鍥炲~鏈�澶ф祦姘村彿
                 oCn.RunProc("exec h_p_WMS_SetMaxNo_QTY '" + sTMNumber + "',1 ");
+
+                //鍥炲~婧愬崟涓存椂琛℉InterID
+                oCn.RunProc("update a set a.HInterID=" + HInterID.ToString() + ",a.HBillNo='" + HBillNo + "' from KF_WeighSource_Temp a where a.HInterID<>" + HInterID.ToString() + " and a.HMaker='" + HMaker + "' and convert(varchar(10),a.HMakeDate,120)=convert(varchar(10),getdate(),120)");
 
                 //鍐欏叆鏉$爜鍑哄叆搴撲复鏃惰〃
                 oCn.RunProc("Insert into KF_PonderationBillMain_Temp " +
@@ -606,7 +697,7 @@
                     + "," + HWhID.ToString() + ",0," + HSPID.ToString() + ",0,0,''"
                     +",0," + HQty.ToString() + ",1,'" + HBatchNo + "','" + HBarCode + "',''"
                     +",'" + HMaker + "',getdate()," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillType + "','" + HSourceBillNo + "'"
-                    +",0,0,'0',0,'',0"
+                    +",0,0,'',0,'',0"
                     +"," + HStockOrgID.ToString() + "," + HStockOrgID.ToString() + "," + HStockOrgID.ToString() + ",'','绉伴噸鍏ュ簱鐢熸垚','2'"
                     +",0,0,'',0)");
 
@@ -634,6 +725,8 @@
             txtHMaterName.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("鐗╂枡鍚嶇О")].Value);
             txtHMaterModel.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("瑙勬牸鍨嬪彿")].Value);
             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);
             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);
@@ -644,6 +737,9 @@
             HSourceBillNo = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("鐢熶骇璁㈠崟")].Value);
             HSourceBillType = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSourceBillType")].Value);
             HSourceQty = DBUtility.ClsPub.isDoule(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("鏁伴噺")].Value);
+            ProcessExchangeInterID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("ProcessExchangeInterID")].Value);
+            HSupID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSupID")].Value);
+            HMaterWeight = DBUtility.ClsPub.isDoule(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HMaterWeight")].Value);
         }
 
         //杩斿洖婧愬崟鍒楄〃淇℃伅
@@ -689,5 +785,202 @@
 
         #endregion
 
+        #region  //浣滃簾
+        private void cmdZF_Click(object sender, EventArgs e)
+        {
+            if (grdMain.CurrentRow == null)
+            {
+                MessageBox.Show("璇峰厛閫夋嫨闇�瑕佷綔搴熺殑鏉$爜锛�", "鎻愮ず");
+                return;
+            }
+            else
+            {
+                if (MessageBox.Show("纭畾瑕佷綔搴熸墍閫夋潯鐮侊紵", "鎻愮ず", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
+                {
+                    return;
+                }
+                else
+                {
+                    string HRemark = "";
+                    string HItemID = "";
+                    string HBarCode = "";
+                    string HBarCode2 = "";
+                    for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
+                    {
+                        HItemID = HItemID + "," + DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("hmainid")].Value.ToString());
+                        HBarCode = HBarCode + ",'" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value) + "'";
+                        if (i != 0 && i % 100 == 0)
+                        {
+                            HBarCode2 = HBarCode2 + "#" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
+                        }
+                        else
+                        {
+                            HBarCode2 = HBarCode2 + "," + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
+                        }
+                        if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("浣滃簾鏍囪")].Value) != "")
+                        {
+                            HRemark = HRemark + "銆�" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
+                        }
+                    }
+                    if (HRemark != "")
+                    {
+                        MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細"+ HRemark.Remove(0, 1)+" 宸蹭綔搴燂紝涓嶅厑璁搁噸澶嶄綔搴燂紒", "鎻愮ず");
+                        return;
+                    }
+                    HItemID = HItemID.Remove(0, 1);     //鍘绘帀瀛楃涓茬涓�涓瓧绗�
+                    HBarCode = HBarCode.Remove(0, 1);
+                    HBarCode2 = HBarCode2.Remove(0, 1);
+
+                    try
+                    {
+                        oCn.BeginTran();
+                        string[] NewBarCode;
+                        NewBarCode = HBarCode2.Split(Convert.ToChar("#"));
+
+                        //浣滃簾鏉$爜
+                        oCn.RunProc("update Gy_BarCodeBill set HStopflag=1,HDeleteMan='" + DBUtility.ClsPub.CurUserName + "',HDeleteDate=getdate() where HItemID in (" + HItemID + ")", ref DBUtility.ClsPub.sExeReturnInfo);
+                        //鍒犻櫎鏉$爜鍑哄叆搴撲复鏃惰〃璁板綍
+                        oCn.RunProc("delete from KF_PonderationBillMain_Temp where HInterID=" + HInterID.ToString() + " and HBillType='" + HBillType + "' and HBarCode in (" + HBarCode + ")", ref DBUtility.ClsPub.sExeReturnInfo);
+                        //鍐欏叆绯荤粺鏃ュ織
+                        for (int i = 0; i <= NewBarCode.Length - 1; i++)
+                        {
+                            oCn.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.ComputerName + "','浣滃簾鏉$爜锛�" + NewBarCode[i] + "','绉伴噸鍏ュ簱妯″潡','" + DBUtility.ClsPub.IPAddress + "','浣滃簾'", ref DBUtility.ClsPub.sExeReturnInfo);
+                        }
+                        oCn.Commit();
+                    }
+                    catch (Exception e2)
+                    {
+                        oCn.RollBack();
+                        MessageBox.Show("浣滃簾鏉$爜澶辫触锛�" + e2.Message, "鎻愮ず");
+                        return;
+                    }
+                    //鍒锋柊绉伴噸璁板綍鍒楄〃淇℃伅
+                    BarCode_Display();
+                    MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細" + HBarCode.Remove(0, 1) + " 浣滃簾鎴愬姛锛�", "鎻愮ず");
+                }
+            }
+        }
+
+        #endregion
+
+        #region  //鍙嶄綔搴�
+        private void cmdFZF_Click(object sender, EventArgs e)
+        {
+            if (grdMain.CurrentRow == null)
+            {
+                MessageBox.Show("璇峰厛閫夋嫨闇�瑕佸弽浣滃簾鐨勬潯鐮侊紒", "鎻愮ず");
+                return;
+            }
+            else
+            {
+                if (MessageBox.Show("纭畾瑕佸弽浣滃簾鎵�閫夋潯鐮侊紵", "鎻愮ず", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
+                {
+                    return;
+                }
+                else
+                {
+                    string HRemark = "";
+                    string HItemID = "";
+                    string HBarCode = "";
+                    string HBarCode2 = "";
+                    for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
+                    {
+                        HItemID = HItemID + "," + DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("hmainid")].Value.ToString());
+                        HBarCode = HBarCode + ",'" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value) + "'";
+                        if (i != 0 && i % 100 == 0)
+                        {
+                            HBarCode2 = HBarCode2 + "#" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
+                        }
+                        else
+                        {
+                            HBarCode2 = HBarCode2 + "," + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
+                        }
+                        if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("浣滃簾鏍囪")].Value) == "")
+                        {
+                            HRemark = HRemark + "銆�" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value);
+                        }
+                    }
+                    if (HRemark != "")
+                    {
+                        MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細" + HRemark.Remove(0, 1) + " 鏈綔搴燂紝涓嶅厑璁稿弽浣滃簾锛�", "鎻愮ず");
+                        return;
+                    }
+                    HItemID = HItemID.Remove(0, 1);     //鍘绘帀瀛楃涓茬涓�涓瓧绗�
+                    HBarCode = HBarCode.Remove(0, 1);
+                    HBarCode2 = HBarCode2.Remove(0, 1);
+
+                    try
+                    {
+                        oCn.BeginTran();
+                        string[] NewBarCode;
+                        NewBarCode = HBarCode2.Split(Convert.ToChar("#"));
+
+                        //鍙嶄綔搴熸潯鐮�
+                        oCn.RunProc("update Gy_BarCodeBill set HStopflag=0,HDeleteMan='',HDeleteDate=null where HItemID in (" + HItemID + ")", ref DBUtility.ClsPub.sExeReturnInfo);
+
+                        //鍒犻櫎鏉$爜鍑哄叆搴撲复鏃惰〃璁板綍
+                        oCn.RunProc("delete from KF_PonderationBillMain_Temp where HInterID=" + HInterID.ToString() + " and HBillType='" + HBillType + "' and HBarCode in (" + HBarCode + ")", ref DBUtility.ClsPub.sExeReturnInfo);
+
+                        //鍐欏叆鏉$爜鍑哄叆搴撲复鏃惰〃
+                        oCn.RunProc("Insert into KF_PonderationBillMain_Temp " +
+                        "(HInterID,HBillNo,HBillType,HMaterID,HAuxPropID,HProcID" +
+                        ",HWhID,HSCWHID,HStockPlaceID,HOutStockPlaceID,HGroupID,HAddr" +
+                        ",HQtyMust,HQty,HPieceQty,HBatchNo,HBarCode,HBarCode_Pack" +
+                        ",HMaker,HMakeDate,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
+                        ",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag,HMTONo,HPlanMode" +
+                        ",HSTOCKORGID,HOtherOrgID,HOWNERID,HOWNERTYPEID,HExpressNumber,HSubBillType" +
+                        ",HCusID,HDeptID,HCusBarCode,HMulSourceBill) " +
+                        " select " + HInterID.ToString() + ",'" + HBillNo + "','" + HBillType + "',HMaterID,HAuxPropID,0" +
+                        ",HWhID,0,HSPID,0,0,''" +
+                        ",0,HQty,1,HBatchNo,HBarCode,''" +
+                        ",'" + HMaker + "',getdate(),HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
+                        ",0,0,'',0,'',0" +
+                        ",HSTOCKORGID,HSTOCKORGID,HSTOCKORGID,'','绉伴噸鍏ュ簱鐢熸垚-鍙嶄綔搴�','2'" +
+                        ",0,0,'',0" +
+                        "from Gy_BarCodeBill with(nolock) where HItemID in (" + HItemID + ")"
+                        );
+
+                        //鍐欏叆绯荤粺鏃ュ織
+                        for (int i = 0; i <= NewBarCode.Length - 1; i++)
+                        {
+                            oCn.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.ComputerName + "','鍙嶄綔搴熸潯鐮侊細" + NewBarCode[i] + "','绉伴噸鍏ュ簱妯″潡','" + DBUtility.ClsPub.IPAddress + "','鍙嶄綔搴�'", ref DBUtility.ClsPub.sExeReturnInfo);
+                        }
+                        oCn.Commit();
+                    }
+                    catch (Exception e2)
+                    {
+                        oCn.RollBack();
+                        MessageBox.Show("鍙嶄綔搴熸潯鐮佸け璐ワ紒" + e2.Message, "鎻愮ず");
+                        return;
+                    }
+                    //鍒锋柊绉伴噸璁板綍鍒楄〃淇℃伅
+                    BarCode_Display();
+                    MessageBox.Show("鎵�閫夋潯鐮佺紪鍙凤細" + HBarCode.Remove(0, 1) + " 鍙嶄綔搴熸垚鍔燂紒", "鎻愮ず");
+                }
+            }
+        }
+
+
+        #endregion
+
+        #region  //澶囨敞   涓嶈壇鍘熷洜閫夋嫨
+        private void cmdHBadReasonID_Click(object sender, EventArgs e)
+        {
+            DAL.ClsGy_BadReason_View oBadReason = new DAL.ClsGy_BadReason_View();
+            if (oBadReason.RefreshView())
+            {
+                this.txtHRemark.Text = oBadReason.oModel.HName;
+                this.txtHRemark.Tag = oBadReason.oModel.HItemID.ToString();
+            }
+        }
+
+        #endregion
+
+
+
+
+
+
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1