1
wangbin
2024-07-08 4548e24916ac5f63eef736cabdcd634864f8de16
WarM/ÌõÂë´òÓ¡/Gy_BarCodeBill_automaticallyByPLC_New.cs
@@ -223,14 +223,14 @@
                //系统参数,生成条码数量可否超源单数量控制(N为不可超源单数量)
                if (SourceQtyCtl == "N")
                {
                    sWhere = " and HOrgID =" + HOrgID.ToString() + " and ä»»åŠ¡æ•°é‡>0 and ç”Ÿäº§çº¿='" + comboBox_SourceNameParams.Text + "' ";
                    sWhere = " and HOrgID =" + HOrgID.ToString() + " and ä»»åŠ¡æ•°é‡>0 and çŠ¶æ€ = '开工' and ç”Ÿäº§çº¿='" + comboBox_SourceNameParams.Text + "' ";
                }
                else
                {
                    sWhere = " and HOrgID =" + HOrgID.ToString();
                    sWhere = " and HOrgID =" + HOrgID.ToString() + " and çŠ¶æ€ = '开工' and ç”Ÿäº§çº¿='" + comboBox_SourceNameParams.Text + "' "; ;
                }
                DAL.Cls_S_IFCLD_ICMOList oIFCLD_ICMOList = new DAL.Cls_S_IFCLD_ICMOList();
                DAL.Cls_S_IFCLD_ICMOList1 oIFCLD_ICMOList = new DAL.Cls_S_IFCLD_ICMOList1();
                if (oIFCLD_ICMOList.Refresh(sWhere))  //选择原单
                {
                    FillSelectData(oIFCLD_ICMOList.oBillSelectColl);
@@ -794,7 +794,6 @@
                    {
                        HWei = ClsPub.isStrNull(grdSub.Rows[i].Cells[HWeiCol].Value);
                        HBarCode = ClsPub.isStrNull(grdSub.Rows[i].Cells[HTMCol].Value);
                        HBarCode = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMaterModel2Col].Value) + ClsPub.isStrNull(grdSub.Rows[i].Cells[HBatchNo2Col].Value);
                        //
                        HBarCodeType = ClsPub.isStrNull(cmbHBarCodeType.Text);
                        HMaterID = ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value);
@@ -850,6 +849,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 + "' ";
@@ -945,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);
            }
            ////获取条码档案中当日本产品条码编号最大的记录
            long HMaxNo = 0;                //记录条码档案中当日本产品条码编号最大的记录的条码编号的流水号
            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 ç›‘听通讯
@@ -1020,6 +1084,10 @@
                    {
                        string RMess = Encoding.UTF8.GetString(buffer, 0, length);
                        produceQty = ClsPub.isLong(RMess);
                        if (produceQty == 0)
                        {
                            produceQty = 1;
                        }
                    }
                }
            }
@@ -1713,7 +1781,6 @@
        {
            return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdList);
        }
        #endregion
        #endregion