From e6c680c4955d341d1afd8753edec9744be1ad260 Mon Sep 17 00:00:00 2001 From: duhe <226547893@qq.com> Date: 星期二, 30 四月 2024 11:42:41 +0800 Subject: [PATCH] 条码自动生成_PLC:产品条码条码编号的流水号根据当天同产品递增进行生成 --- WarM/条码打印/Gy_BarCodeBill_automaticallyByPLC_New.cs | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 53 insertions(+), 1 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 2319049..5b895f1 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" @@ -850,6 +850,8 @@ 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"); @@ -944,6 +946,57 @@ 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; + + //鑾峰彇褰撴棩鏈骇鍝佹潯鐮佺紪鍙锋渶澶х殑璁板綍 + 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 + "' order by 鏉$爜缂栧彿 desc"; + ds = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList"); + if (ds != null) + { + long count = 0; + if (ds.Tables[0].Rows.Count > 0) + { + string HBarCodeMaxNo = ds.Tables[0].Rows[0]["鏉$爜缂栧彿"].ToString(); + HBarCodeMaxNo = HBarCodeMaxNo.Substring(HBarCodeMaxNo.Length - LEN, LEN); + count = ClsPub.isLong(HBarCodeMaxNo); + } + LIU += count + 1; + while (LIU.Length < LEN) //濡傛灉娴佹按鍙峰皬浜�6浣嶆暟鍓嶉潰琛�0 + { + LIU = "0" + LIU; + } + } + else + { + return ""; + } + + //鎷兼帴鎵瑰彿 + HBarCode_MaxNo = sYear + sPeriod + sDay + LIU; + + return HBarCode_MaxNo; + } + #endregion + #endregion #region 鐩戝惉閫氳 @@ -1712,7 +1765,6 @@ { return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdList); } - #endregion #endregion -- Gitblit v1.9.1