From 36ac7452cd5345809df4fe27f24ea83f70cd0919 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期二, 18 十月 2022 14:27:13 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WarM/条码打印/Sc_ICMOToBarCode.cs |  494 +++++++++++++++++++++++++++++++++---------------------
 1 files changed, 305 insertions(+), 189 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 710979b..4d74421 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"
@@ -41,6 +41,7 @@
         public Int64 HInterID_TTM = 0;
         public string HBillNo_TTM = "";
         ClsCN SubCn = new ClsCN();
+        Pub_Class.ClsGridViewSum oSumGrid = new Pub_Class.ClsGridViewSum();
         //
         private void initGrid()
         {
@@ -216,6 +217,7 @@
         {
             //
             //frmCondition = new frmBillQueryCondition_New();
+            oSumGrid.ogrdMain = grdMain;
             this.Text = ModCaption;
             //lblCaption.Text = ModCaption;
             initGrid();
@@ -750,7 +752,6 @@
 
         private void cmdHSaveBill_Click(object sender, EventArgs e)
         {
-
             Display();
         }
 
@@ -779,6 +780,8 @@
                 DataSet Ds;
                 int LSH = 0;                //娴佹按鍙�
                 string LSH2 = "";           //娴佹按鍙疯浆鎹㈡垚瀛楃
+
+
                 double HZXQty = 0;         //瑁呯鏁伴噺
                 double HDDQty = 0;         //璁㈠崟鏁伴噺
                 double HBQty = 0;         //绠辨暟
@@ -787,13 +790,160 @@
                 string WeiShu = "";         //灏炬暟
                 int LSHlen = 6;             //娴佹按鍙烽暱搴�
                 string TM = "";             //鏉$爜
+                string sPackBarCode = "";
+                string HPrdDate = "";
+                string HBC = "";
+                string HDate1 = "";
+                DataSet Ds99;
 
-                HDate = dtpHBeginDate.Value.ToShortDateString();
-                HYear = ClsPub.isDate(HDate).Year.ToString().Substring(2, 2);
-                HPeriod = "0" + ClsPub.isDate(HDate).Month.ToString();
+                //绠卞彿
+                string HXH = "";
+                //绠卞彿娴佹按鍙�
+                int LSH3 = 0;                //娴佹按鍙�
+                string LSH4 = "";           //娴佹按鍙疯浆鎹㈡垚瀛楃
+                //鏈哄彴
+                string HJT = "";
+
+                HDate = DateTime.Now.ToString();
+
+                //鍒ゆ柇褰撳墠鏃堕棿鏄惁鍦ㄥ伐浣滄椂闂存鍐�
+                string _strWorkingDayAM = "07:30";//宸ヤ綔鏃堕棿涓婂崍08:30
+                string _strWorkingDayPM = "19:30";
+                string _strWorkingDayTM = "00:00";
+                string _strWorkingDaySM = "23:59";
+                TimeSpan dspWorkingDayAM = DateTime.Parse(_strWorkingDayAM).TimeOfDay;
+                TimeSpan dspWorkingDayPM = DateTime.Parse(_strWorkingDayPM).TimeOfDay;
+                TimeSpan dspWorkingDayTM = DateTime.Parse(_strWorkingDayTM).TimeOfDay;
+                TimeSpan dspWorkingDaySM = DateTime.Parse(_strWorkingDaySM).TimeOfDay;
+
+                //string time1 = "2017-2-17 8:10:00";
+                DateTime t1 = Convert.ToDateTime(HDate);
+
+                TimeSpan dspNow = t1.TimeOfDay;
+                HDate1 = Convert.ToDateTime(HDate).ToShortDateString();
+                //1.姝e父涓婄彮鏃堕棿 灏辨槸鐧界彮  濡傛灉涓嶆槸绀兼嫓澶� 灏卞線鍓嶆彁鍓嶄竴澶�
+                if (dspNow > dspWorkingDayAM && dspNow < dspWorkingDayPM)
+                {
+                    HBC = "鐧界彮";
+
+                    DataSet DSet2 = oCn.RunProcReturn("select * from Gy_FactoryDayOff Where HFactoryDayOffDate='" + HDate1.ToString() + "'", "Gy_FactoryDayOff", ref DBUtility.ClsPub.sExeReturnInfo);
+                    if (DSet2 == null || DSet2.Tables[0].Rows.Count == 0)
+                    {
+                        HPrdDate = HDate;
+                    }
+                    else
+                    {
+                        HPrdDate = DBUtility.ClsPub.isStrNull(DSet2.Tables[0].Rows[0]["HNoFactoryDayOffDate"]);
+                    }
+                }
+                //2.澶т簬19锛�30  灏忎簬24锛�00  澶滅彮
+                if (dspNow > dspWorkingDayPM && dspNow < dspWorkingDaySM)
+                {
+                    HBC = "澶滅彮";
+                    DataSet DSet2 = oCn.RunProcReturn("select * from Gy_FactoryDayOff Where HFactoryDayOffDate='" + HDate1.ToString() + "'", "Gy_FactoryDayOff", ref DBUtility.ClsPub.sExeReturnInfo);
+                    if (DSet2 == null || DSet2.Tables[0].Rows.Count == 0)
+                    {
+                        HPrdDate = HDate;
+                    }
+                    else
+                    {
+                        HPrdDate = DBUtility.ClsPub.isStrNull(DSet2.Tables[0].Rows[0]["HNoFactoryDayOffDate"]);
+                    }
+                }
+                //3.澶т簬00锛�00  灏忎簬7锛�30  鐧界彮  鍏堝噺涓�澶�  鍐嶅垽鏂噺浜嗕竴澶╃殑鏃ユ湡鏄笉鏄巶浼戞棩鏈�
+                if (dspNow > dspWorkingDayTM && dspNow < dspWorkingDayAM)
+                {
+                    HBC = "澶滅彮";
+                    HDate = DBUtility.ClsPub.isStrNull(DBUtility.ClsPub.isDate(HDate).AddDays(-1));
+                    HDate = DBUtility.ClsPub.isDate(HDate).ToShortDateString();
+                    DataSet DSet2 = oCn.RunProcReturn("select * from Gy_FactoryDayOff Where HFactoryDayOffDate='" + HDate.ToString() + "'", "Gy_FactoryDayOff", ref DBUtility.ClsPub.sExeReturnInfo);
+                    if (DSet2 == null || DSet2.Tables[0].Rows.Count == 0)
+                    {
+                        HPrdDate = HDate;
+                    }
+                    else
+                    {
+                        HPrdDate = DBUtility.ClsPub.isStrNull(DSet2.Tables[0].Rows[0]["HNoFactoryDayOffDate"]);
+                    }
+                }
+                HYear = ClsPub.isDate(HPrdDate).Year.ToString().Substring(2, 2);
+                HPeriod = "0" + ClsPub.isDate(HPrdDate).Month.ToString();
                 HPeriod = HPeriod.Substring(HPeriod.Length - 2, 2);
-                HDay = "0" + ClsPub.isDate(HDate).Day.ToString();
+                HDay = "0" + ClsPub.isDate(HPrdDate).Day.ToString();
                 HDay = HDay.Substring(HDay.Length - 2, 2);
+                long HTMaterID = 0;
+                HTMaterID = ClsPub.isLong(grdMain.Rows[0].Cells[Fun_GetCol("HMaterID")].Value);
+                string sPackStr = "ZXM" + HYear + HPeriod + HDay + HTMaterID; //澶栫鐮� 鍓嶇紑
+
+
+                //鑾峰彇澶勭悊杩囩殑鏃ユ湡璺熶粖澶╁樊鍑犲ぉ  鐒跺悗鍔犲嚑涓�+鍙�
+                TimeSpan HCY = Convert.ToDateTime(HPrdDate) - Convert.ToDateTime(DateTime.Now.ToString());
+                int a = 1;
+                while (a <= HCY.Days)  //褰揳 灏忎簬 宸紓澶╂暟  寰幆鍔犱笂 + 鍙�
+                {
+                    HPrdDate = HPrdDate + "+";
+                    a = a + 1;
+                }
+                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;
+
+
+                sPackBarCode = sPackStr + TTM_LSH.ToString();
+                //DataSet DSet3 = oCn.RunProcReturn("select * from Gy_FactoryDayOff Where HFactoryDayOffDate='" + HDate1.ToString() + "'", "Gy_FactoryDayOff", ref DBUtility.ClsPub.sExeReturnInfo);
+                //if (DSet3 == null || DSet3.Tables[0].Rows.Count == 0)
+                //{
+                //    sPackBarCode = sPackStr + TTM_LSH.ToString() ;
+                //}
+                //else
+                //{
+                //    sPackBarCode = sPackStr + TTM_LSH.ToString() + "+";
+                //}
+
+
+                oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sPackStr + "'");
+
+
+                //DataSet DSet1 = oCn.RunProcReturn("select * from Gy_FactoryDayOff Where HFactoryDayOffDate='" + HDate.ToString() + "'", "Gy_FactoryDayOff", ref DBUtility.ClsPub.sExeReturnInfo);
+
+
+                //    //鐢熸垚棣栬鏍囬
+                //    if (DSet1 == null || DSet1.Tables[0].Rows.Count == 0)
+                //    {
+
+                //        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);
+                //        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;
+                //        sPackBarCode = sPackStr + TTM_LSH.ToString();
+                //        oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sPackStr + "'");
+                //    }
+
+                //    else
+                //    {
+
+                //        HDate = DBUtility.ClsPub.isStrNull(DSet1.Tables[0].Rows[0]["HNoFactoryDayOffDate"]);
+
+
+                //        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);
+                //        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;
+                //        sPackBarCode = sPackStr + TTM_LSH.ToString() + "+" ;
+                //        oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sPackStr + "'");
+                //    }
 
                 //=============鏍规嵁鐣岄潰涓婂凡缁忓垎閰嶇殑鏁版嵁杩涜鏉$爜鐢熸垚鍜屾墦鍗般��
                 //鑾峰彇鏈鐢熸垚鐨� 涓诲唴鐮� 
@@ -807,13 +957,13 @@
                 //00 鍏堢敓鎴� 鍞竴鐨� 鎵樻潯鐮�
 
                 //鐢熸垚涓�涓绠辩爜
-                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();
-                oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sPackStr + "'");
+                //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();
+                //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sPackStr + "'");
 
 
                 //MessageBox.Show("11");
@@ -836,6 +986,15 @@
                         HBatchNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[Fun_GetCol("鎵规")].Value);
                         
                         HOrgNumber = ClsPub.HOrgNumber;
+
+
+                        //绠卞彿鐢熸垚瑙勫垯  鏃ユ湡 +  鏈哄彴 + 鐝 +  鐗╂枡   鍙鑾峰彇鏈�澶х殑娴佹按鍙�
+                        HJT = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[Fun_GetCol("璁惧")].Value);
+                        HXH = HYear + HPeriod + HDay + HBC + HJT + HMaterNumber;
+                        Ds99 = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + HXH + "'", "h_p_WMS_GetMaxNo");    //鑾峰彇鏈�澶ф祦姘村彿
+                        LSH3 = ClsPub.isInt(Ds99.Tables[0].Rows[0][0]) + 1;
+                        LSH4 = LSH3.ToString();
+
 
 
                         //HBQty = HBQty + ClsPub.isInt(txtHBQty.Text);
@@ -931,7 +1090,7 @@
                                             ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
                                             ",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate " +
                                             ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HSourceID,HInterID " +
-                                            ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " +
+                                            ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HPrdDate,HBC,HXH,HInnerBillNo " +
                                             ") values ("
                                             + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID1.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString() + ", " + HMZQty.ToString()
                                             + ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() + "," + HQty2.ToString()
@@ -939,22 +1098,23 @@
                                             + ", " + 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 + "'," + HSourceID.ToString() + "," + HInterID.ToString()
-                                            + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HInnerBillNo + "')");
+                                            + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HPrdDate + "','" + HBC + "','" + LSH4 + "','" + HInnerBillNo + "')");
 
                         oCn.RunProc("exec h_p_WMS_SetMaxNo '" + HTMNumber + "'");
+                        oCn.RunProc("exec h_p_WMS_SetMaxNo '" + HXH + "'");
                         DisplayTM();
                     }
                 }
                 //2.寰幆缁撴潫鍚庯紝鏍规嵁 鏈鐢熸垚鐨� 涓诲唴鐮侊紝浠庡悗鍙版暟鎹簱鑾峰彇 鏉$爜鍒楄〃锛岀敓鎴� 缁勬墭鍗� 鍜� 鎵樻潯鐮侊紝 鐩存帴璋冪敤瀛樺偍杩囩▼ 
                  //鏍规嵁澶栫鐮� 鍐欏叆 缁勬墭鍗曚富琛紝缁勬墭鍗曞瓙琛紝SUM锛屽绠辩爜妗f锛孲UM妗f
-                oCn.RunProc("exec  h_p_WMS_PackUnionBill_AddNew  '" + sPackBarCode + "'," + HInterID_TTM.ToString() + ",'" + DBUtility.ClsPub.CurUserName + "'," + HInterID.ToString()); //鏍规嵁绠辨潯鐮侊紝鍐欏叆 涓昏〃锛屽瓙琛� 锛岀鏉$爜妗f 
+                oCn.RunProc("exec  h_p_WMS_PackUnionBill_AddNew_test  '" + sPackBarCode + "'," + HInterID_TTM.ToString() + ",'" + DBUtility.ClsPub.CurUserName + "'," + HInterID.ToString()); //鏍规嵁绠辨潯鐮侊紝鍐欏叆 涓昏〃锛屽瓙琛� 锛岀鏉$爜妗f 
                 oCn.RunProc("exec  h_p_WMS_PackUnionBill_SumSubBill  " + HInterID_TTM.ToString() + ",'" + sPackBarCode + "','3783','" + DBUtility.ClsPub.CurUserName + "'," + HInterID.ToString()); //鏍规嵁绠辨潯鐮侊紝鍐欏叆 SUM琛紝SUM鏉$爜妗f
 
 
 
 
                 sPackBarCode = "";
-                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);
+                DataSet DSet = oCn.RunProcReturn("select * from h_v_IF_BarCodeBillList_CS_Test Where HInterID=" + HInterID.ToString() + " and 鏉$爜绫诲瀷 = '鎵樼洏鏉$爜'", "h_v_IF_BarCodeBillList_CS_Test", ref DBUtility.ClsPub.sExeReturnInfo);
                 //鐢熸垚棣栬鏍囬
                 if (DSet == null)
                 {
@@ -997,191 +1157,107 @@
 
         private void button4_Click(object sender, EventArgs e)
         {
-            
-            //鏍规嵁鏈鏁伴噺 鏉� 鍒嗛厤鍒� 姣忎釜鐢熶骇璁㈠崟涓婏紙鍒嗛厤鏃� 瑕佽�冭檻 璁㈠崟鍓╀綑鏁伴噺宸茬粡鏄� 璐熸暟鐨勬儏鍐碉級
-            //濡傛灉鏈夋爣鍑嗚绠辨暟閲� 鍏堥粯璁ゅ彇鏍囧噯瑁呯鏁伴噺  娌℃湁鍐嶅彇鎵嬭緭鐨勬湰绠辨暟閲�
-            //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;
-            }
-            //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);
 
-                        //MessageBox.Show("璇风偣鍑昏秴棰濈敓浜ф寜閽敓鎴愭潯鐮侊紒");
-                        //return;
-                    }
-                    else
-                    {
-                        grdMain.Rows[i].Cells["鏈鏁伴噺"].Value = HZXQty;
-                        //
-
-                        //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();
-            //
-
-
-
-
-
-            ////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);//寰楀埌鏂板崟鍙�
+            bool flag = this.txtHZXQty.Text.Trim() != "";
+            double num;
+            double HICMOQty = 0;
+            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++)
+                {
+                    for (int i1 = 0; i1 < this.grdMain.Rows.Count; i1++)
+                    {
 
-            //    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);
+                        HICMOQty += Pub_Class.ClsPub.isDoule(this.grdMain.Rows[i1].Cells["鐢熶骇璁㈠崟鏁伴噺"].Value);
+                    }
+                    if (HICMOQty < num)
+                    {
+                        MessageBox.Show("璇风偣鍑昏秴棰濈敓浜ф寜閽敓鎴愭潯鐮侊紒");
+                        break;
+                    }
 
-            //    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 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()
@@ -1408,9 +1484,49 @@
                 }
                 if (cmbHBarCodeType.Text == "鍞竴鏉$爜")
                 {
-                    //鏉$爜缂栧彿 = 鏉$爜鍓嶇紑 + 娴佹按鍙�
-                    TM = HTMNumber + LSH2;
+                    HDate = DateTime.Now.ToShortDateString();
+                    DataSet DSet = oCn.RunProcReturn("select * from Gy_FactoryDayOff Where HFactoryDayOffDate='" + HDate.ToString() + "'", "Gy_FactoryDayOff", ref DBUtility.ClsPub.sExeReturnInfo);
+                    //鐢熸垚棣栬鏍囬
+                    if (DSet == null || DSet.Tables[0].Rows.Count == 0)
+                    {
+                        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);
+                        HTMNumber = HOrgNumber + HMaterNumber + HYear + HPeriod + HDay;
+                        Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + HTMNumber + "'", "h_p_WMS_GetMaxNo");    //鑾峰彇鏈�澶ф祦姘村彿
+                        LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
+                        TM = HTMNumber + LSH2;
+                    }
+                    else
+                    {
+                        HDate = DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[0]["HNoFactoryDayOffDate"]);
+                        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);
+                        HTMNumber = HOrgNumber + HMaterNumber + HYear + HPeriod + HDay;
+                        Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + HTMNumber + "'", "h_p_WMS_GetMaxNo");    //鑾峰彇鏈�澶ф祦姘村彿
+                        LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
+                        TM = HTMNumber + LSH2 + "+"; 
+                    }
+                    //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);
+                    //HTMNumber = HOrgNumber + HMaterNumber + HYear + HPeriod + HDay;
+                    //Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + HTMNumber + "'", "h_p_WMS_GetMaxNo");    //鑾峰彇鏈�澶ф祦姘村彿
+                    //LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                 }
+                //if (cmbHBarCodeType.Text == "鍞竴鏉$爜")
+                //{
+                //    //鏉$爜缂栧彿 = 鏉$爜鍓嶇紑 + 娴佹按鍙�
+                //    TM = HTMNumber + LSH2;
+                //}
                 if (TM.Trim() == "")
                 {
                     MessageBox.Show("鏉″舰鐮佷笉鑳戒负绌猴紝涓嶈兘鐢熸垚鏉$爜锛�");
@@ -1531,7 +1647,7 @@
         private void DisplayTM()
         {
             //HInterID = DBUtility.ClsPub.isInt(txtHMaterID.Tag);
-            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_test Where HinterID=" + HInterID.ToString() + " and 鏉$爜绫诲瀷 = '鎵樼洏鏉$爜' order by HItemID", "h_v_IF_BarCodeBillList_test", ref DBUtility.ClsPub.sExeReturnInfo);
             //鐢熸垚棣栬鏍囬
             if (DSet == null)
             {

--
Gitblit v1.9.1