From cb98f3abf09cb75bf1328c42745f3be8cd9d9374 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期五, 17 五月 2024 08:04:43 +0800
Subject: [PATCH] 1

---
 WarM/条码打印/Gy_BarCodeBill_automaticallyByPLC_New.cs |   88 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 82 insertions(+), 6 deletions(-)

diff --git "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_automaticallyByPLC_New.cs" "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_automaticallyByPLC_New.cs"
index 954c4cd..6da5b7b 100644
--- "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_automaticallyByPLC_New.cs"
+++ "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_automaticallyByPLC_New.cs"
@@ -351,6 +351,9 @@
             //grdMain.Rows[i].Cells[HSourceNumberCol].Value = oTable.Rows[0]["鐢熶骇绾夸唬鐮�"].ToString();
             grdMain.Rows[i].Cells[HSourceNameCol].Value = oTable.Rows[0]["鐢熶骇绾�"].ToString();
             grdMain.Rows[i].Cells[HEndDateCol].Value = oTable.Rows[0]["璁″垝瀹屽伐鏃ユ湡"].ToString();//鍗氭棩 鐢熶骇璁㈠崟 澶辨晥鏃ユ湡
+
+            grdMain.Rows[i].Cells[HAuxPropIDCol].Value = oTable.Rows[0]["HAuxPropID"].ToString();
+
             if (cmbHBarCodeType.Text == "浠櫒澶栬喘浠舵潯鐮佸鍣ㄨ鍒�")
             {
                 grdMain.Rows[i].Cells[HMinQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["鏈敓鎴愭潯鐮佹暟閲�"]);
@@ -847,6 +850,15 @@
                             HBatchNo2 = getBatchNo();
                         }
 
+                        HBarCode = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMaterModel2Col].Value) + getHBarCode_MaxNo();
+
+                        long HSourceID = 0;
+                        string sql = "select * from Gy_Source where HName = '" + comboBox_SourceNameParams.Text + "' ";
+                        DataSet ds = oCn.RunProcReturn(sql, "Gy_Source");
+                        if (ds != null && ds.Tables[0].Rows.Count > 0)
+                        {
+                            HSourceID = DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HItemID"].ToString());
+                        }
 
                         oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
                                     ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
@@ -857,7 +869,7 @@
                                     ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
                                     ",HProduceDate,HExpiryDate " +
                                     ",HISKFPERIOD,HEXPUNIT,HEXPPERIOD " +
-                                    ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " +
+                                    ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HSourceID " +
                                     ") values ("
                                     + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString()
                                     + ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() + "," + HQty2.ToString()
@@ -868,7 +880,8 @@
                                     + ", " + DBUtility.ClsPub.BoolToString(HGiveAwayFlag) + "," + HSeOrderSEQ.ToString() + "," + HSourceEntryID.ToString()
                                     + ", " + (HProduceDate == "" ? "NULL" : "'" + HProduceDate + "'") + "," + (HExpiryDate == "" ? "NULL" : "'" + HExpiryDate + "'")
                                     + ", " + DBUtility.ClsPub.BoolToString(HISKFPERIOD) + ",'" + HEXPUNIT + "'," + HEXPPERIOD.ToString()
-                                    + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HInnerBillNo + "')");
+                                    + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HInnerBillNo + "'," + HSourceID +
+                                    ")");
                     }
                 }
                 //澧炲姞 鏉$爜瓒呰繃鏈敓鎴愬姛鑳芥帶鍒�
@@ -906,7 +919,7 @@
                 string LIU = "";
                 int LEN = 4;
                 DataSet ds;
-                string sql = "select * from h_v_IF_BarCodeBillList Where 婧愬崟鍗曞彿 ='" + grdMain.Rows[0].Cells[HSourceBillNoCol].Value + "' and HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),鏉$爜鏃ユ湡, 23) = '" + HDate + "' order by 鎵瑰彿 desc";
+                string sql = "select * from h_v_IF_BarCodeBillList Where HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),鏉$爜鏃ユ湡, 23) = '" + HDate + "' order by 鎵瑰彿 desc";
                 ds = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList");
                 if (ds != null)
                 {
@@ -933,6 +946,69 @@
 
             return HBatchNo;
         }
+
+        //鐢熸垚褰撳ぉ浜у搧鏉$爜鐨勬祦姘村彿
+        private string getHBarCode_MaxNo()
+        {
+            string HBarCode_MaxNo = "";
+
+            //鏃ユ湡鑾峰彇鏂瑰紡
+            string sDate = dtpHDate.Value.ToShortDateString();                                                                                   //
+            string sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2);
+            string sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString();
+            sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
+            string sDay = "0" + ClsPub.isDate(sDate).Day.ToString();
+            sDay = sDay.Substring(sDay.Length - 2, 2);
+
+            string HDate = "20" + sYear + "-" + sPeriod + "-" + sDay;
+
+            //鑾峰彇娴佹按鍙凤細鍥涗綅锛岃鐗╂枡褰撳ぉ鐢熸垚鐨勬潯鐮佹暟
+            string LIU = "";
+            int LEN = 4;
+
+            //鑾峰彇浜у搧鏉$爜澶囦唤琛ㄤ腑褰撴棩鏈骇鍝佹潯鐮佺紪鍙锋渶澶х殑璁板綍
+            long HMaxNo_Bak = 0;                //璁板綍浜у搧鏉$爜澶囦唤琛ㄤ腑褰撴棩鏈骇鍝佹潯鐮佺紪鍙锋渶澶х殑璁板綍鐨勬潯鐮佺紪鍙风殑娴佹按鍙�
+            DataSet ds1;
+            string sql1 = "select * from Gy_BarCodeBill_SWELL_SubBarCodeBill Where HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),HBarCodeDate, 23) = '" + HDate + "' and HInterID <>0 order by HBarCode desc";
+            ds1 = oCn.RunProcReturn(sql1, "Gy_BarCodeBill_SWELL_SubBarCodeBill");
+            if (ds1 != null && ds1.Tables[0].Rows.Count>0)
+            {
+                string HBarCodeMaxNo = ds1.Tables[0].Rows[0]["HBarCode"].ToString();
+                HBarCodeMaxNo = HBarCodeMaxNo.Substring(HBarCodeMaxNo.Length - LEN, LEN);
+                HMaxNo_Bak = ClsPub.isLong(HBarCodeMaxNo);
+            }
+
+            ////鑾峰彇鏉$爜妗f涓綋鏃ユ湰浜у搧鏉$爜缂栧彿鏈�澶х殑璁板綍
+            long HMaxNo = 0;                //璁板綍鏉$爜妗f涓綋鏃ユ湰浜у搧鏉$爜缂栧彿鏈�澶х殑璁板綍鐨勬潯鐮佺紪鍙风殑娴佹按鍙�
+            DataSet ds;
+            string sql = "select * from h_v_IF_BarCodeBillList Where HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),鏉$爜鏃ユ湡, 23) = '" + HDate + "' and HInterID <> 0 order by 鏉$爜缂栧彿 desc";
+            ds = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList");
+            if (ds != null && ds.Tables[0].Rows.Count > 0)
+            {
+                string HBarCodeMaxNo = ds.Tables[0].Rows[0]["鏉$爜缂栧彿"].ToString();
+                HBarCodeMaxNo = HBarCodeMaxNo.Substring(HBarCodeMaxNo.Length - LEN, LEN);
+                HMaxNo = ClsPub.isLong(HBarCodeMaxNo);
+            }
+
+
+            //鑾峰彇褰撴棩鏈骇鍝� 鍦ㄦ潯鐮佹。妗堝拰浜у搧鏉$爜澶囦唤琛ㄤ腑 鏈�澶х殑娴佹按鍙�
+            long count = 0;
+            count = HMaxNo >= HMaxNo_Bak ? HMaxNo : HMaxNo_Bak;
+
+            //涓烘祦姘村彿鍓嶉潰琛ラ浂
+            LIU += count + 1;
+            while (LIU.Length < LEN)  //濡傛灉娴佹按鍙峰皬浜�6浣嶆暟鍓嶉潰琛�0
+            {
+                LIU = "0" + LIU;
+            }
+
+            //鎷兼帴鎵瑰彿
+            HBarCode_MaxNo = sYear + sPeriod + sDay + LIU;
+
+            return HBarCode_MaxNo;
+        }
+        #endregion
+
         #endregion
 
         #region 鐩戝惉閫氳
@@ -1125,7 +1201,8 @@
                 sDate = "20" + sYear + "-" + sPeriod + "-" + sDay;
 
                 //璁剧疆宸ュ崟鏉$爜閫夐」鍗¤〃鏍兼暟鎹�
-                string sql = "select * from h_v_IF_BarCodeBillList Where 婧愬崟鍗曞彿 = '" + grdMain.Rows[0].Cells[HBillNoCol].Value + "' and HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),鏉$爜鏃ユ湡, 23) = '" + sDate + "' order by 鏉$爜缂栧彿";
+                //string sql = "select * from h_v_IF_BarCodeBillList Where 婧愬崟鍗曞彿 = '" + grdMain.Rows[0].Cells[HBillNoCol].Value + "' and HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),鏉$爜鏃ユ湡, 23) = '" + sDate + "' order by 鏉$爜缂栧彿";
+                string sql = "select * from h_v_IF_BarCodeBillList Where 婧愬崟鍗曞彿 = '" + grdMain.Rows[0].Cells[HBillNoCol].Value + "' and HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and CONVERT(varchar(100),鏉$爜鏃ユ湡, 23) = '" + sDate + "' order by 鏉$爜缂栧彿";
                 DataSet DSet1 = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList", ref DBUtility.ClsPub.sExeReturnInfo);
                 //鐢熸垚棣栬鏍囬
                 if (DSet1 == null)
@@ -1264,7 +1341,7 @@
 
 
             //璁剧疆浜х嚎 涓嬫媺鍒楄〃
-            DataSet DsSource = oCn.RunProcReturn("select * from Gy_Source where HUSEORGID =" + ClsPub.HOrgID, "Gy_Source");
+            DataSet DsSource = oCn.RunProcReturn("select * from Gy_Source", "Gy_Source");
             comboBox_SourceNameParams.Items.Add("");
             if (DsSource != null)
             {
@@ -1700,7 +1777,6 @@
         {
             return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdList);
         }
-        #endregion
         #endregion
 
 

--
Gitblit v1.9.1