条码自动生成_PLC:产品条码条码编号的流水号根据当天同产品递增进行生成
1个文件已修改
54 ■■■■■ 已修改文件
WarM/条码打印/Gy_BarCodeBill_automaticallyByPLC_New.cs 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WarM/ÌõÂë´òÓ¡/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