From 8e82aa3bf721908fdb44d9fb06eb4772e4f126d7 Mon Sep 17 00:00:00 2001
From: jhz <jinghz@oceic.com>
Date: 星期二, 26 七月 2022 09:59:30 +0800
Subject: [PATCH] 1

---
 WarM/条码打印/Sc_ICMOToBarCode.cs |  494 +++++++++++++++++++++++++++---------------------------
 1 files changed, 251 insertions(+), 243 deletions(-)

diff --git "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Sc_ICMOToBarCode.cs" "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Sc_ICMOToBarCode.cs"
index 0129631..225d43b 100644
--- "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Sc_ICMOToBarCode.cs"
+++ "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Sc_ICMOToBarCode.cs"
@@ -107,6 +107,7 @@
             DSet = SubCn.RunProcReturn("exec h_p_KSTMSC '" + HSeOrderBillNo + "' ,'" + HICMOBillNo + "' , '" + HMaterName + "' , '" + HSourceName + "' ,'" + HEmpName + "' ,'" + HBeginDate + "'", "h_p_KSTMSC", ref DBUtility.ClsPub.sExeReturnInfo);
             //鐢熸垚棣栬鏍囬
             if (DSet == null)
+                //if (DSet == null|| DSet.Tables[0].Rows.Count == 0)
             {
                 MessageBox.Show("娌℃湁杩斿洖浠讳綍缁撴灉,璇峰湪杩囨护妗嗕腑鐐瑰嚮銆愭仮澶嶃�戞寜閽�,灏濊瘯鍐嶆鏌ヨ锛�" + DBUtility.ClsPub.sExeReturnInfo);
                 return;
@@ -118,6 +119,7 @@
                 if (DSet.Tables[0].Rows.Count > 0)
                 {
                     txtHMaterID.Tag = DBUtility.ClsPub.isInt(grdMain.Rows[0].Cells["HInterID"].Value);
+                    txtHMiniQty.Text = DBUtility.ClsPub.isStrNull(grdMain.Rows[0].Cells["鏍囧噯瑁呯"].Value);
                 }
                 else
                 {
@@ -219,6 +221,38 @@
             initGrid();
             cmbHBarCodeType.SelectedIndex = 0;
             dtpHBeginDate.Value = DateTime.Today;
+            string HUserName = "";
+            HUserName = ClsPub.isStrNull(DBUtility.ClsPub.CurUserName);
+            Int64 HUserID = 0;
+            HUserID = ClsPub.isInt(DBUtility.ClsPub.CurUserID);
+
+            DataSet DSet;
+
+            DSet = oCn.RunProcReturn("Select HEmpID from gy_czygl Where czymc='" + HUserName + "'", "gy_czygl", ref DBUtility.ClsPub.sExeReturnInfo);
+            
+            if (DSet == null)
+            //if (DSet == null|| DSet.Tables[0].Rows.Count == 0)
+            {
+                MessageBox.Show("娌℃湁杩斿洖浠讳綍缁撴灉,璇峰湪杩囨护妗嗕腑鐐瑰嚮銆愭仮澶嶃�戞寜閽�,灏濊瘯鍐嶆鏌ヨ锛�" + DBUtility.ClsPub.sExeReturnInfo);
+                return;
+            }
+            else
+            {
+                //grdMain.DataSource = DSet.Tables[0].DefaultView;
+                //鎶婂綋鍓嶅崟鎹甀D 瀛樺埌涓�涓寜閽噷闈�   鍒锋柊鏃舵瘡娆″瓨涓�閬�
+                if (DSet.Tables[0].Rows.Count > 0)
+                {
+
+
+                    txtHEmpID.Tag = DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[0]["HEmpID"]);
+                }
+                else
+                {
+
+                }
+            }
+
+
         }
 
         private void grdMain_DblClick(object sender, EventArgs e)
@@ -495,14 +529,14 @@
         private void Sub_SetReport(string sOpenTmp)
         {
             //鍒ゆ柇琛屾暟
-            for (int i = 0; i < grdList.Rows.Count; i++)
-            {
-                grdList.Rows[i].Cells[0].Value = "";
-            }
-            for (int i = 0; i < grdList.SelectedRows.Count; i++)
-            {
-                grdList.Rows[grdMain.SelectedRows[i].Index].Cells[0].Value = "*";
-            }
+            //for (int i = 0; i < grdList.Rows.Count; i++)
+            //{
+            //    grdList.Rows[i].Cells[0].Value = "";
+            //}
+            //for (int i = 0; i < grdList.SelectedRows.Count; i++)
+            //{
+            //    grdList.Rows[grdMain.SelectedRows[i].Index].Cells[0].Value = "*";
+            //}
             //
             Report = new GridppReport();
             Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf");  //here .
@@ -714,62 +748,6 @@
             }
         }
 
-        private void zf_Click(object sender, EventArgs e)
-        {
-            //Sub_AbandonCheck();
-            if (!ClsPub.Security_Log(ModRightNameDelete, 1, true, DBUtility.ClsPub.CurUserName))
-            {
-                return;
-            }
-            if (grdMain.CurrentRow == null)
-                return;
-            DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
-            if (MessageBox.Show("纭畾瑕佷綔搴熸墍閫夋潯鐮侊紵", "鎻愮ず", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
-            {
-                return;
-            }
-            for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
-            {
-                if (DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("HMaterID")].Value) != 0)
-                {
-                    if (!oBar.Cancelltion(DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value)))
-                    {
-                        MessageBox.Show("浣滃簾澶辫触锛�", "鎻愮ず");
-                        return;
-                    }
-                }
-            }
-            MessageBox.Show("浣滃簾鎴愬姛锛�", "鎻愮ず");
-        }
-
-        private void fzf_Click(object sender, EventArgs e)
-        {
-            //this.Sub_CheckBill();
-            if (!ClsPub.Security_Log(ModRightNameDelete, 1, true, DBUtility.ClsPub.CurUserName))
-            {
-                return;
-            }
-            if (grdMain.CurrentRow == null)
-                return;
-            DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
-            if (MessageBox.Show("纭畾瑕佸弽浣滃簾鎵�閫夋潯鐮侊紵", "鎻愮ず", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
-            {
-                return;
-            }
-            for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
-            {
-                if (DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("HMaterID")].Value) != 0)
-                {
-                    if (!oBar.UnCancelltion(DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("鏉$爜缂栧彿")].Value)))
-                    {
-                        MessageBox.Show("鍙嶄綔搴熷け璐ワ紒", "鎻愮ず");
-                        return;
-                    }
-                }
-            }
-            MessageBox.Show("鍙嶄綔搴熸垚鍔燂紒", "鎻愮ず");
-        }
-
         private void cmdHSaveBill_Click(object sender, EventArgs e)
         {
 
@@ -810,7 +788,7 @@
                 int LSHlen = 6;             //娴佹按鍙烽暱搴�
                 string TM = "";             //鏉$爜
 
-                HDate = DateTime.Now.ToShortDateString();
+                HDate = dtpHBeginDate.Value.ToShortDateString();
                 HYear = ClsPub.isDate(HDate).Year.ToString().Substring(2, 2);
                 HPeriod = "0" + ClsPub.isDate(HDate).Month.ToString();
                 HPeriod = HPeriod.Substring(HPeriod.Length - 2, 2);
@@ -829,7 +807,9 @@
                 //00 鍏堢敓鎴� 鍞竴鐨� 鎵樻潯鐮�
 
                 //鐢熸垚涓�涓绠辩爜
-                string sPackStr = "ZXM" + HYear + HPeriod + HDay; //澶栫鐮� 鍓嶇紑
+                long HTMaterID = 0;
+                HTMaterID = ClsPub.isLong(grdMain.Rows[0].Cells[Fun_GetCol("HMaterID")].Value);
+                string sPackStr = "ZXM" + HYear + HPeriod + HDay + HTMaterID; //澶栫鐮� 鍓嶇紑
                 DataSet  DsTM = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sPackStr + "'", "h_p_WMS_GetMaxNo");    //鑾峰彇鏈�澶ф祦姘村彿                                                                                          //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                 Int64 TTM_LSH = ClsPub.isInt(DsTM.Tables[0].Rows[0][0]) + 1;
                 string sPackBarCode = sPackStr + TTM_LSH.ToString();
@@ -910,6 +890,11 @@
                         string HWorkLineName = "";
                         string HSeOrderBillNo = "";
                         string HInnerBillNo = "";
+                        Int64 HSourceID = 0;
+                        //姣涢噸
+                        Double HMZQty = 0;
+                        HMZQty = HZXQty * ClsPub.isDoule(grdMain.Rows[j].Cells[Fun_GetCol("鍏嬮噸")].Value)/1000;
+
                         HWei = WeiShu;
                         HBarCode = TM;
                         HBarCodeType = ClsPub.isStrNull(cmbHBarCodeType.Text);
@@ -939,20 +924,21 @@
                         HWorkLineName = "";
                         HSeOrderBillNo = "";
                         HInnerBillNo = sPackBarCode;
-                        oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
+                        HSourceID = ClsPub.isInt(txtHSourceID.Tag);
+                        oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HMaterialMQty" +
                                             ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
                                             ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
                                             ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
                                             ",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate " +
-                                            ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID " +
+                                            ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HSourceID,HInterID " +
                                             ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " +
                                             ") values ("
-                                            + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID1.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString()
+                                            + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID1.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString() + ", " + HMZQty.ToString()
                                             + ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() + "," + HQty2.ToString()
                                             + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "'"
                                             + ", " + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'"
                                             + ", " + HCusID.ToString() + ",'" + HCusType + "','" + HEndDate.ToShortDateString() + "','" + HWorkLineName + "','" + HDate + "'"
-                                            + ", " + ClsPub.HOrgID.ToString() + "," + ClsPub.HOrgID.ToString() + ",'" + HSeOrderBillNo + "'," + HInterID.ToString()
+                                            + ", " + ClsPub.HOrgID.ToString() + "," + ClsPub.HOrgID.ToString() + ",'" + HSeOrderBillNo + "'," + HSourceID.ToString() + "," + HInterID.ToString()
                                             + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HInnerBillNo + "')");
 
                         oCn.RunProc("exec h_p_WMS_SetMaxNo '" + HTMNumber + "'");
@@ -968,7 +954,7 @@
 
 
                 sPackBarCode = "";
-                DataSet DSet = oCn.RunProcReturn("select * from h_v_IF_BarCodeBillList Where HinterID=" + HInterID.ToString() + " and 鏉$爜绫诲瀷 = '鎵樼洏鏉$爜' order by HItemID", "h_v_IF_BarCodeBillList", ref DBUtility.ClsPub.sExeReturnInfo);
+                DataSet DSet = oCn.RunProcReturn("select * from h_v_IF_BarCodeBillList_CS Where HInterID=" + HInterID.ToString() + " and 鏉$爜绫诲瀷 = '鎵樼洏鏉$爜'", "h_v_IF_BarCodeBillList_CS", ref DBUtility.ClsPub.sExeReturnInfo);
                 //鐢熸垚棣栬鏍囬
                 if (DSet == null)
                 {
@@ -977,6 +963,7 @@
                 }
                 //
                 grdList.DataSource = DSet.Tables[0].DefaultView;
+                txtHZXQty.Text = "";
                 //鍐荤粨
                 int FrCol = 0;
                 string s = "鏄�";
@@ -995,7 +982,7 @@
                 //0缁撴潫浜嬪姟
 
                 //
-                Display();
+                //Display();
                
 
             }
@@ -1010,177 +997,95 @@
 
         private void button4_Click(object sender, EventArgs e)
         {
-            
-            //鏍规嵁鏈鏁伴噺 鏉� 鍒嗛厤鍒� 姣忎釜鐢熶骇璁㈠崟涓婏紙鍒嗛厤鏃� 瑕佽�冭檻 璁㈠崟鍓╀綑鏁伴噺宸茬粡鏄� 璐熸暟鐨勬儏鍐碉級
-            //1.鍒ゆ柇鏈鏁伴噺 蹇呴』澶т簬0
-            double HZXQty = 0;//鏁寸鏁伴噺
-            HZXQty = ClsPub.isDoule(txtHZXQty.Text);
-            if (HZXQty <= 0)
-            {
-                MessageBox.Show("璇疯緭鍏ユ暣绠辨暟閲忥紒");
-                return;
-            }
-            //2.鍒锋柊缃戞牸
-            Display();
-            //3.鎶婃暣绠辨暟閲� 鍒嗛厤鍒� 缃戞牸涓嬮潰鐨勬瘡涓�涓� 鐢熶骇璁㈠崟涓婂幓銆�  寰幆缃戞牸
-            for(int i =0;i<grdMain.Rows.Count;i++)
-            {
-                if(HZXQty>0)
-                {
-                    if(HZXQty>DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["鐢熶骇璁㈠崟鏁伴噺"].Value))
-                    {
-                        HZXQty = HZXQty - DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["鐢熶骇璁㈠崟鏁伴噺"].Value);
-                        grdMain.Rows[i].Cells["鏈鏁伴噺"].Value = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["鐢熶骇璁㈠崟鏁伴噺"].Value);
-                    }
-                    else
-                    {
-                        grdMain.Rows[i].Cells["鏈鏁伴噺"].Value = HZXQty;
-                        break;
-                    }
-                }
-                else
-                {
-                    break;
-                }
-            }
-            Sub_SaveBarCode();
-            //
 
-
-
-
-
-            ////1.鑾峰彇鐣岄潰涓婇潰鏁寸鏁伴噺妗嗚緭鍏ョ殑鏁伴噺 璧嬪�肩粰鍙橀噺  骞跺埛鏂扮綉鏍�
-            //double HBarCodeQty = 0;
-            //double HZXQty = 0;
-            //HZXQty = ClsPub.isDoule(txtHZXQty.Text);
-            //if (HZXQty ==0)
+            ////鏍规嵁鏈鏁伴噺 鏉� 鍒嗛厤鍒� 姣忎釜鐢熶骇璁㈠崟涓婏紙鍒嗛厤鏃� 瑕佽�冭檻 璁㈠崟鍓╀綑鏁伴噺宸茬粡鏄� 璐熸暟鐨勬儏鍐碉級
+            ////濡傛灉鏈夋爣鍑嗚绠辨暟閲� 鍏堥粯璁ゅ彇鏍囧噯瑁呯鏁伴噺  娌℃湁鍐嶅彇鎵嬭緭鐨勬湰绠辨暟閲�
+            ////1.鍒ゆ柇鏈鏁伴噺 蹇呴』澶т簬0   
+            //double HZXQty = 0;//鏁寸鏁伴噺
+            //if (txtHZXQty.Text.Trim() != "")
+            //{
+            //    HZXQty = ClsPub.isDoule(txtHZXQty.Text);
+            //}
+            //else
+            //{
+            //    HZXQty = ClsPub.isDoule(txtHMiniQty.Text);
+            //}
+            //if (HZXQty <= 0)
             //{
             //    MessageBox.Show("璇疯緭鍏ユ暣绠辨暟閲忥紒");
             //    return;
             //}
-            //Display();
-            ////2.鑾峰彇缃戞牸閫変腑琛岀墿鏂橧D
-            ////int a = grdMain.CurrentRow.Index;
-            ////long HMaterID = 0;
-            //////HMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[a].Cells[Fun_GetCol("HMaterID")].Value);
-            ////    if (HMaterID == 0)
-            ////    {
-            ////        MessageBox.Show("娌℃湁閫変腑浠讳綍璁板綍锛�");
-            ////        return;
-            ////    }
-            ////3.瀹氫箟鏄惁缁勬墭鐨勫彉閲�
-            //int Mul = 0;
-            ////4.鏍规嵁鍗曟嵁绫诲瀷鑾峰彇鏈鏉$爜涓诲唴鐮丠InterID
-            //HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
-
-
-            //for (int i = 0; i < grdMain.Rows.Count; i++)
+            ////2.鍒锋柊缃戞牸
+            ////Display();
+            ////3.鎶婃暣绠辨暟閲� 鍒嗛厤鍒� 缃戞牸涓嬮潰鐨勬瘡涓�涓� 鐢熶骇璁㈠崟涓婂幓銆�  寰幆缃戞牸
+            //for(int i =0;i<grdMain.Rows.Count;i++)
             //{
-
-            //    //鑾峰彇缃戞牸閲岄潰姣忎竴琛岃鍗曞搴旂殑璁㈠崟鏁伴噺
-            //    double HDDQty = 0;
-            //    HDDQty = DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.Rows[i].Index].Cells[Fun_GetCol("璁㈠崟鏁伴噺")].Value);
-
-
-            //    //鑾峰彇褰撳墠绯荤粺鐧婚檰缁勭粐浠g爜
-            //    HOrgNumber = ClsPub.HOrgNumber;
-
-
-
-
-            //    //鑷姩鍖归厤閫昏緫  鍒ゆ柇璁㈠崟鏁伴噺鏄惁澶т簬鏁寸鏁伴噺   濡傛灉璁㈠崟鏁伴噺澶т簬鏁寸鏁伴噺  鐩存帴鐢熸垚鍞竴鐮�
-            //    //濡傛灉璁㈠崟鏁伴噺灏忎簬鏁寸鏁伴噺  鍒欏惊鐜敓鎴愬敮涓�鐮�   鐢熸垚瀵瑰簲鐨勬墭鏉$爜
-            //        if (HDDQty >= HZXQty)
+            //    if (HZXQty > 0)
+            //    {
+            //        if (HZXQty > DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["鐢熶骇璁㈠崟鏁伴噺"].Value))
             //        {
-            //            HBarCodeQty = HZXQty;
-            //            this.Sub_SaveBill_TTM();
-            //            Display();
-            //            Mul = Mul + 1;
-            //            break;
+            //            HZXQty = HZXQty - DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["鐢熶骇璁㈠崟鏁伴噺"].Value);
+            //            grdMain.Rows[i].Cells["鏈鏁伴噺"].Value = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["鐢熶骇璁㈠崟鏁伴噺"].Value);
+
+            //            //MessageBox.Show("璇风偣鍑昏秴棰濈敓浜ф寜閽敓鎴愭潯鐮侊紒");
+            //            //return;
             //        }
-            //        else if(HDDQty < HZXQty)
+            //        else if (HZXQty == 0)
             //        {
-            //            HBarCodeQty = HDDQty;
-            //            HZXQty = HZXQty - HDDQty;
-            //            this.Sub_SaveBill_TTM();
-            //            Mul = Mul + 1;
-            //            continue;
+            //            return;
             //        }
+            //        else
+            //        {
+            //            grdMain.Rows[i].Cells["鏈鏁伴噺"].Value = HZXQty;
+            //            //
 
-            //    //濡傛灉Mul>1 鏂板缁勬墭鍗曚富琛�
-
+            //            //HZXQty = HZXQty - DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["鐢熶骇璁㈠崟鏁伴噺"].Value);
+            //            //grdMain.Rows[i].Cells["鏈鏁伴噺"].Value = DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells["鐢熶骇璁㈠崟鏁伴噺"].Value);
+            //        }
+            //    }
+            //    else
+            //    {
+            //        break;
+            //    }
             //}
+            //Sub_SaveBarCode();
+            ////
 
-            //if (Mul > 1)
-            //{
-            //    //HICMOBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("鐢熶骇璁㈠崟鍙�")].Value);
-            //    DataSet DS1;
-            //    HTTMNumber = HOrgNumber + HICMOBillNo;
-            //    DS1 = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + HTTMNumber + "'", "h_p_WMS_GetMaxNo");    //鑾峰彇鏈�澶ф祦姘村彿
-            //    TLSH = ClsPub.isInt(DS1.Tables[0].Rows[0][0]);
-            //    TLSH2 = TLSH.ToString();
-            //    TTM = HTTMNumber + TLSH2;
-            //    HInterID_TTM = DBUtility.ClsPub.CreateBillID_Prod(ModName1, ref DBUtility.ClsPub.sExeReturnInfo);
-            //    HBillNo_TTM = DBUtility.ClsPub.CreateBillCode_Prod(ModName1, ref DBUtility.ClsPub.sExeReturnInfo, true);//寰楀埌鏂板崟鍙�
-
-            //    string HDate = "";
-            //    string HYear = "";
-            //    string HPeriod = "";
-            //    string HDay = "";
-            //    HDate = DateTime.Now.ToShortDateString();
-            //    HYear = ClsPub.isDate(HDate).Year.ToString().Substring(2, 2);
-            //    HPeriod = "0" + ClsPub.isDate(HDate).Month.ToString();
-            //    HPeriod = HPeriod.Substring(HPeriod.Length - 2, 2);
-            //    HDay = "0" + ClsPub.isDate(HDate).Day.ToString();
-            //    HDay = HDay.Substring(HDay.Length - 2, 2);
-
-            //    oCn.RunProc("insert into Sc_PackUnionBillMain (HYear,HPeriod,HBillType,HInterID,HDate" +
-            //                       ",HBillNo,HBillStatus,HICMOBillNo,HBarCode_Pack,HMaterID,HUnitID,HWeight" +
-            //                       ",HPWeight,HProdOrgID,HDeptID,HEmpID,HSNum,HPackNum,HBarCode_Cus,HBatchNo " +
-            //                       ") values ("
-            //                       + HYear + "," + HPeriod + ",'3783'," + HInterID_TTM + ",'" + HDate + "'"
-            //                       + ", " + HBillNo_TTM.ToString() + ",1,''," + TTM.ToString() + ",0,0,0"
-            //                       + ",0,1,0,0,0,0,'','')");
-            //}
-
-
-            ////3.鍏堝垽鏂墿鏂欐槸鍚︿竴鑷�  濡傛灉涓�鑷村紑濮嬪惊鐜綉鏍�
-            //for (int i = 0; i < grdMain.Rows.Count; i++)
-            //{
-            //    //long HGrdMaterID = 0;
-            //    //HGrdMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.Rows[i].Index].Cells[Fun_GetCol("HMaterID")].Value);
-            //    //if (HGrdMaterID == HMaterID)
-            //    //{
-            //    //    double HDDQty = 0;
-            //    //    HDDQty = DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.Rows[i].Index].Cells[Fun_GetCol("璁㈠崟鏁伴噺")].Value);
-            //    //    //濡傛灉寰幆鐨勮琛岃褰曠殑璁㈠崟鏁伴噺宸茬粡澶т簬绛変簬鏈瑁呯鏁伴噺  鍒欑洿鎺ョ敓鎴愬敮涓�鐮�  骞朵笖鍒锋柊缃戞牸  鍒锋柊鏉$爜淇℃伅椤�
-            //    //    if (HDDQty >= HZXQty)
-            //    //    {
-            //    //        double HBarCodeQty = 0;
-            //    //        HBarCodeQty = HZXQty;
-            //    //        this.Sub_SaveBill();
-            //    //        Display();
-            //    //    }
-            //    //    //濡傛灉鏀硅璁板綍璁㈠崟鏁伴噺灏忎簬鏈瑁呯鏁伴噺 鍒欑户缁惊鐜�  璧扮敓鎴愭墭鏉$爜鏂规硶
-            //    //    else  
-            //    //    {
-            //    //        //鏌ュ嚭绗﹀悎鏉′欢鐨勯�変腑杩欐潯鏁伴噺璺熻绠辨暟閲忕殑宸紓鍊�
-            //    //        double HCYQty = 0;
-            //    //        HCYQty = HZXQty - DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.Rows[i].Index].Cells[Fun_GetCol("璁㈠崟鏁伴噺")].Value);
-
-            //    //    }
-
-            //    //}
-            //    //else
-            //    //{
-
-            //    //}
-            //}
-
-
-
-
+            bool flag = this.txtHZXQty.Text.Trim() != "";
+            double num;
+            if (flag)
+            {
+                num = Pub_Class.ClsPub.isDoule(this.txtHZXQty.Text);
+            }
+            else
+            {
+                num = Pub_Class.ClsPub.isDoule(this.txtHMiniQty.Text);
+            }
+            bool flag2 = num <= 0.0;
+            if (flag2)
+            {
+                MessageBox.Show("璇疯緭鍏ユ暣绠辨暟閲忥紒");
+            }
+            else
+            {
+                for (int i = 0; i < this.grdMain.Rows.Count; i++)
+                {
+                    bool flag3 = num > 0.0;
+                    if (!flag3)
+                    {
+                        break;
+                    }
+                    bool flag4 = num > Pub_Class.ClsPub.isDoule(this.grdMain.Rows[i].Cells["鐢熶骇璁㈠崟鏁伴噺"].Value);
+                    if (!flag4)
+                    {
+                        this.grdMain.Rows[i].Cells["鏈鏁伴噺"].Value = num;
+                        break;
+                    }
+                    num -= Pub_Class.ClsPub.isDoule(this.grdMain.Rows[i].Cells["鐢熶骇璁㈠崟鏁伴噺"].Value);
+                    this.grdMain.Rows[i].Cells["鏈鏁伴噺"].Value = Pub_Class.ClsPub.isDoule(this.grdMain.Rows[i].Cells["鐢熶骇璁㈠崟鏁伴噺"].Value);
+                }
+                this.Sub_SaveBarCode();
+            }
         }
 
         private void Sub_SaveBill()
@@ -1701,18 +1606,51 @@
 
         private void cmdHSourceID_Click(object sender, EventArgs e)
         {
+            Int64 HEmpID = 0;
+            HEmpID = Convert.ToInt64(txtHEmpID.Tag);
+
+           
+            //MessageBox.Show(ClsPub.isStrNull(HEmpID));
+            //string HEmpName = "";
+            //HEmpName = ClsPub.isStrNull(txtHEmpID.Text);
+
             DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View();
-            if (oSource.RefreshView())
+            if (HEmpID != 0)
             {
-                this.txtHSourceID.Text = oSource.oModel.HName;
-                this.txtHSourceID.Tag = oSource.oModel.HItemID.ToString();
-                //
-                Display();
+                if (oSource.GetInfoByID_AoBang(HEmpID))
+                {
+                    this.txtHSourceID.Text = oSource.oModel.HName;
+                    this.txtHSourceID.Tag = oSource.oModel.HItemID.ToString();
+                    //
+                    Display();
+                }
+                else
+                {
+                    this.txtHSourceID.Text = "";
+                }
             }
             else
             {
-                this.txtHSourceID.Text = "";
+
+                if (oSource.RefreshView())
+                {
+                    this.txtHSourceID.Text = oSource.oModel.HName;
+                    this.txtHSourceID.Tag = oSource.oModel.HItemID.ToString();
+                    //
+                    Display();
+                }
+                else
+                {
+                    this.txtHSourceID.Text = "";
+                }
             }
+            //if (oSource.RefreshView())
+            //{
+            //    this.txtHSourceID.Text = oSource.oModel.HName;
+            //    this.txtHSourceID.Tag = oSource.oModel.HItemID.ToString();
+            //    //
+            //    Display();
+            //}
 
             //DAL.ClsGy_WorkCenter_View oWork = new DAL.ClsGy_WorkCenter_View();
             //if (oWork.RefreshView())
@@ -1897,6 +1835,7 @@
             grdList.DataSource = null;
             grdSub.DataSource = null;
             grdMain.DataSource = null;
+            txtHEmpID.Tag = 0;
         }
 
         private void button2_Click(object sender, EventArgs e)
@@ -1907,14 +1846,29 @@
             DataSet DSBefore;
             DSBefore =  SubCn.RunProcReturn("exec h_p_PreviousMater "+ HInterID, "h_p_PreviousMater", ref DBUtility.ClsPub.sExeReturnInfo);
             grdMain.DataSource = DSBefore.Tables[0].DefaultView;
-            if (DSBefore.Tables[0].Rows.Count > 0)
+            //if (DSBefore.Tables[0].Rows.Count > 0)
+            //{
+            //    txtHMaterID.Tag = DBUtility.ClsPub.isInt(grdMain.Rows[0].Cells["HInterID"].Value);
+            //}
+            //else
+            //{
+
+            //}
+            if (DSBefore == null || DSBefore.Tables[0].Rows.Count == 0)
+            //if (DSet == null|| DSet.Tables[0].Rows.Count == 0)
             {
-                txtHMaterID.Tag = DBUtility.ClsPub.isInt(grdMain.Rows[0].Cells["HInterID"].Value);
+                MessageBox.Show("娌℃湁涓婁竴涓墿鏂�,濡傛灉闇�瑕佽鎵炬満淇紒" + DBUtility.ClsPub.sExeReturnInfo);
+                return;
             }
             else
             {
-
+                grdMain.DataSource = DSBefore.Tables[0].DefaultView;
+                txtHMaterID.Tag = DBUtility.ClsPub.isInt(grdMain.Rows[0].Cells["HInterID"].Value);
+                txtHMiniQty.Text = DBUtility.ClsPub.isStrNull(grdMain.Rows[0].Cells["鏍囧噯瑁呯"].Value);
             }
+
+
+
         }
 
         private void button3_Click(object sender, EventArgs e)
@@ -1925,9 +1879,19 @@
             HInterID = DBUtility.ClsPub.isInt(txtHMaterID.Tag);
             DataSet DSBefore;
             DSBefore = SubCn.RunProcReturn("exec h_p_NextMater " + HInterID, "h_p_NextMater", ref DBUtility.ClsPub.sExeReturnInfo);
-            grdMain.DataSource = DSBefore.Tables[0].DefaultView;
-            txtHMaterID.Tag = DBUtility.ClsPub.isInt(grdMain.Rows[0].Cells["HInterID"].Value);
-            txtHMaterID.Text = DBUtility.ClsPub.isStrNull(grdMain.Rows[0].Cells["HInterID"].Value);
+            if (DSBefore == null || DSBefore.Tables[0].Rows.Count == 0)
+            //if (DSet == null|| DSet.Tables[0].Rows.Count == 0)
+            {
+                MessageBox.Show("娌℃湁涓嬩竴涓墿鏂�,濡傛灉闇�瑕佽鎵炬満淇紒" + DBUtility.ClsPub.sExeReturnInfo);
+                return;
+            }
+            else
+            {
+                grdMain.DataSource = DSBefore.Tables[0].DefaultView;
+                txtHMaterID.Tag = DBUtility.ClsPub.isInt(grdMain.Rows[0].Cells["HInterID"].Value);
+                txtHMiniQty.Text = DBUtility.ClsPub.isStrNull(grdMain.Rows[0].Cells["鏍囧噯瑁呯"].Value);
+            }
+            //txtHMaterID.Text = DBUtility.ClsPub.isStrNull(grdMain.Rows[0].Cells["HInterID"].Value);
         }
 
         //瓒呴鎵撳嵃
@@ -1943,7 +1907,7 @@
                 return;
             }
             //2.鍒锋柊缃戞牸
-            Display();
+            //Display();
             //3.寰幆缃戞牸锛岀疮璁″叏閮ㄥ墿浣欐暟閲忥紝鍒ゆ柇鏄惁 鍓╀綑鏁伴噺 灏忎簬 鏈鏁伴噺锛涘鏋� 澶т簬鍒欐姤閿� 閫�鍑恒��
             double sumLeftQty = 0;
             for (int i = 0; i < grdMain.Rows.Count; i++)
@@ -1985,5 +1949,49 @@
             Sub_SaveBarCode();
             //
         }
+
+        private void cmdESOP_Click(object sender, EventArgs e)
+        { 
+            Sc_MESNowWorkBill_Fast oSc_MESNowWorkBill_Fast = new Sc_MESNowWorkBill_Fast();
+            oSc_MESNowWorkBill_Fast.txtHICMOBillNo.Text = "";
+            oSc_MESNowWorkBill_Fast.txtHMaterID.Text =txtHMaterID.Text;
+            oSc_MESNowWorkBill_Fast.txtHName.Text = ClsPub.isStrNull(grdMain.Rows[0].Cells[Fun_GetCol("鐗╂枡鍚嶇О")].Value);
+            oSc_MESNowWorkBill_Fast.txtHModel.Text = ClsPub.isStrNull(grdMain.Rows[0].Cells[Fun_GetCol("瑙勬牸鍨嬪彿")].Value);
+            oSc_MESNowWorkBill_Fast.Show();
+
+        }
+
+        private void txtHBarCode_KeyDown(object sender, KeyEventArgs e)
+        {
+            if(e.KeyCode==Keys.Enter)
+            {
+                //
+                //鑾峰彇绗竴琛屾潯褰㈢爜杩涜鎵撳嵃
+                DataSet DSet = oCn.RunProcReturn("select * from h_v_IF_BarCodeBillList_CS Where  鏉$爜缂栧彿='"+ txtHBarCode.Text +"' and 鏉$爜绫诲瀷 = '鎵樼洏鏉$爜'", "h_v_IF_BarCodeBillList_CS", ref DBUtility.ClsPub.sExeReturnInfo);
+                //鐢熸垚棣栬鏍囬
+                if (DSet == null)
+                {
+                    MessageBox.Show("娌℃湁杩斿洖浠讳綍缁撴灉,鏉$爜涓嶅瓨鍦紒" + DBUtility.ClsPub.sExeReturnInfo);
+                    return;
+                }
+                //
+                grdList.DataSource = DSet.Tables[0].DefaultView; 
+                //鍐荤粨
+                int FrCol = 0;
+                string s = "鏄�";
+                DBUtility.Xt_BaseBillFun.DisplayGrid(grdList, this.Name + "grdList", s, FrCol);
+                //
+                //鍒ゆ柇鏄惁宸茬粡鐢熸垚鏉$爜
+                if (DBUtility.ClsPub.isStrNull(grdList.Rows[0].Cells[Fun_GetColList("鏉$爜缂栧彿")].Value) == "")
+                {
+                    MessageBox.Show("鏉$爜鏈敓鎴愶紝璇峰厛鐢熸垚鏉$爜鍚庡啀棰勮锛�");
+                    return;
+                }
+                //閫夋嫨鎵撳嵃妯℃澘 
+                Sub_SetReport("娉ㄥ鐗╂枡鏍囩");
+                Report.Print(false);
+                Thread.Sleep(1000); 
+            }
+        }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1