11
pzy
2024-08-26 dbbcd506929afda0a85ae23bcb5f88c1dccef387
WarM/ÌõÂë´òÓ¡/Gy_BarCodeBill.cs
@@ -44,43 +44,48 @@
        public const Int16 HMinQtyCol = 23;
        public const Int16 HBQtyCol = 24;
        public const Int16 HPackQtyCol = 25;
        public const Int16 HDeptIDCol = 26;
        public const Int16 HDeptNumberCol = 27;
        public const Int16 HDeptNameCol = 28;
        public const Int16 HSourceIDCol = 29;
        public const Int16 HSourceNumberCol = 30;
        public const Int16 HSourceNameCol = 31;
        public const Int16 HDateCol = 32;
        public const Int16 HEndDateCol = 33;
        public const Int16 HSupIDCol = 34;
        public const Int16 HSupNumberCol = 35;
        public const Int16 HSupNameCol = 36;
        public const Int16 HCusIDCol = 37;
        public const Int16 HCusNumberCol = 38;
        public const Int16 HCusNameCol = 39;
        public const Int16 HCusTypeCol = 40;
        public const Int16 HSourceInterIDCol = 41;
        public const Int16 HSourceEntryIDCol = 42;
        public const Int16 HSourceBillNoCol = 43;
        public const Int16 HSourceBillTypeCol = 44;
        public const Int16 HInstructIDCol = 45;
        public const Int16 HInstructNoCol = 46;
        public const Int16 HSeOrderBillIDCol = 47;
        public const Int16 HSeOrderBillNoCol = 48;
        public const Int16 HSeOrderSEQCol = 49;
        public const Int16 HWhIDCol = 50;
        public const Int16 HWhNumberCol = 51;
        public const Int16 HWhNameCol = 52;
        public const Int16 HSPIDCol = 53;
        public const Int16 HSPNumberCol = 54;
        public const Int16 HSPNameCol = 55;
        public const Int16 HinitQtyCol = 56;
        public const Int16 HRemarkCol = 57;
        public const Int16 HPinfanBarCodeCol = 58;
        public const Int16 HMTONoCol = 59;
        public const Int16 HShowDateCol = 60;
        public const Int16 HInnerBillNoCol = 61;
        public const Int16 HMakerCol = 62;
        public const Int16 HProduceDateCol = 26;
        public const Int16 HExpiryDateCol = 27;
        public const Int16 HDeptIDCol = 28;
        public const Int16 HDeptNumberCol = 29;
        public const Int16 HDeptNameCol = 30;
        public const Int16 HSourceIDCol = 31;
        public const Int16 HSourceNumberCol = 32;
        public const Int16 HSourceNameCol = 33;
        public const Int16 HDateCol = 34;
        public const Int16 HEndDateCol = 35;
        public const Int16 HSupIDCol = 36;
        public const Int16 HSupNumberCol = 37;
        public const Int16 HSupNameCol = 38;
        public const Int16 HCusIDCol = 39;
        public const Int16 HCusNumberCol = 40;
        public const Int16 HCusNameCol = 41;
        public const Int16 HCusTypeCol = 42;
        public const Int16 HSourceInterIDCol = 43;
        public const Int16 HSourceEntryIDCol = 44;
        public const Int16 HSourceBillNoCol = 45;
        public const Int16 HSourceBillTypeCol = 46;
        public const Int16 HInstructIDCol = 47;
        public const Int16 HInstructNoCol = 48;
        public const Int16 HSeOrderBillIDCol = 49;
        public const Int16 HSeOrderBillNoCol = 50;
        public const Int16 HSeOrderSEQCol = 51;
        public const Int16 HWhIDCol = 52;
        public const Int16 HWhNumberCol = 53;
        public const Int16 HWhNameCol = 54;
        public const Int16 HSPIDCol = 55;
        public const Int16 HSPNumberCol = 56;
        public const Int16 HSPNameCol = 57;
        public const Int16 HinitQtyCol = 58;
        public const Int16 HRemarkCol = 59;
        public const Int16 HPinfanBarCodeCol = 60;
        public const Int16 HMTONoCol = 61;
        public const Int16 HShowDateCol = 62;
        public const Int16 HInnerBillNoCol = 63;
        public const Int16 HMakerCol = 64;
        public const Int16 HISKFPERIODCol = 65;
        public const Int16 HEXPUNITCol = 66;
        public const Int16 HEXPPERIODCol = 67;
        public Int16 HSelectCol = 0;
        public Int16 HSno2Col = 1;
@@ -142,9 +147,16 @@
        public Int16 HInnerBillNo2Col = 57; 
        public Int16 HMaker2Col = 58;
        public Int16 HEntryID2Col = 59;
        public Int16 HProduceDate2Col = 60;
        public Int16 HExpiryDate2Col = 61;
        public Int16 HISKFPERIOD2Col = 62;
        public Int16 HEXPUNIT2Col = 63;
        public Int16 HEXPPERIOD2Col = 64;
        //
        public  string ModName = "85";
        public  string ModCaption = "条码生成";
        public const string ModRightName = "Gy_BarCodeBill";
        public const string ModRightNameSourceQty = ModRightName + "_SourceQty"; //超源单数量控制
        public bool BillChange;   //
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
@@ -196,6 +208,10 @@
                cmbHBarCodeType.Items.Add("仪器成品条码规则");
                cmbHBarCodeType.Items.Add("试剂成品条码规则");
            }
            else if (sCapName == "中控")
            {
                cmbHBarCodeType.Items.Add("唯一条码");
            }
            else
            {
                //
@@ -205,18 +221,28 @@
                //cmbHBarCodeType.Items.Add("托盘条码");
            }
            //
            cmbSourceBillType.Items.Add("生产订单");
            cmbSourceBillType.Items.Add("生产汇报单");
            cmbSourceBillType.Items.Add("采购订单");
            cmbSourceBillType.Items.Add("收料通知单");
            cmbSourceBillType.Items.Add("委外订单");
            cmbSourceBillType.Items.Add("退货通知单");
            cmbSourceBillType.Items.Add("其他入库单");
            cmbSourceBillType.Items.Add("直接调拨单");
            cmbSourceBillType.Items.Add("采购退料单");
            cmbSourceBillType.Items.Add("生产退料单");
            cmbSourceBillType.Items.Add("组装拆卸单");
            //源单类型
            if (sCapName == "中控")
            {
                cmbSourceBillType.Items.Add("生产汇报单");
                cmbSourceBillType.Items.Add("收料通知单");
            }
            else
            {
                cmbSourceBillType.Items.Add("生产订单");
                cmbSourceBillType.Items.Add("生产汇报单");
                cmbSourceBillType.Items.Add("采购订单");
                cmbSourceBillType.Items.Add("收料通知单");
                cmbSourceBillType.Items.Add("委外订单");
                cmbSourceBillType.Items.Add("工序汇报单");
                cmbSourceBillType.Items.Add("工序流转卡");
                cmbSourceBillType.Items.Add("退货通知单");
                cmbSourceBillType.Items.Add("其他入库单");
                cmbSourceBillType.Items.Add("直接调拨单");
                cmbSourceBillType.Items.Add("采购退料单");
                cmbSourceBillType.Items.Add("生产退料单");
                cmbSourceBillType.Items.Add("组装拆卸单");
            }
            //
            DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
            //
@@ -412,6 +438,16 @@
                PrintQtyCtl = oSystemParameter.omodel.BarCode_PrintQtyCtl;
                UpdatePrintQtyCtl = oSystemParameter.omodel.BarCode_UpdatePrintQtyCtl;
            }
            //系统参数,有源单生成条码,生成条码数量可否超源单数量控制(N为不可超源单数量)
            if (SourceQtyCtl == "N")
            {
                //系统参数为不可超源单数量时,再次判断用户权限是否可超源单数量
                //判断权限
                if (ClsPub.Security_Log(ModRightNameSourceQty, 3, false, ClsPub.CurUserName))
                {
                    SourceQtyCtl = "Y";
                }
            }
            cmbHWorksNumber.Items.Clear();
            if (CampanyName == "飞龙") //系统参数  å®¢æˆ·å®šåˆ¶åŒ–名称
@@ -565,23 +601,6 @@
        //单据完整性判断          æœªå®Œæˆ
        private bool Sub_AllowSave()
        {
            ////必输项目是否为空
            //if (txtHDeptID.Tag.ToString().Trim() == "0")
            //{
            //    MessageBox.Show("生产车间没有选择!", "提示");
            //    return false;
            //}
            //if (txtHGroupID.Tag.ToString().Trim() == "0")
            //{
            //    MessageBox.Show("班组没有选择!", "提示");
            //    return false;
            //}
            //单据号是否重复
            //if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, txtHBillNo.Text.Trim(), BillStatus, BillOld.omodel.HInterID))
            //{
            //    MessageBox.Show("单据号重复!", "提示");
            //    return false;
            //}
            //明细表是否为零行
            bool b = false;
            for (int i = 0; i < grdMain.RowCount; i++)
@@ -623,6 +642,45 @@
                    else if(DBUtility.ClsPub.isStrNull(oDsCheck.Tables[0].Rows[0][0]) == "1")
                    {
                        sHRemark= sHRemark+DBUtility.ClsPub.isStrNull(oDsCheck.Tables[0].Rows[0]["HRemark"]);
                    }
                    else if(DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HExpiryDateCol].Value) == "")
                    {
                        if (DBUtility.ClsPub.isBool(oDsCheck.Tables[0].Rows[0]["HISKFPERIOD"]))
                        {
                            DateTime HProduceDate;  //生产日期
                            string HEXPUNIT;        //保质期单位
                            int HEXPPERIOD;         //保质期
                            HProduceDate = dtpHDate.Value;
                            HEXPUNIT = DBUtility.ClsPub.isStrNull(oDsCheck.Tables[0].Rows[0]["HEXPUNIT"]);
                            HEXPPERIOD = DBUtility.ClsPub.isInt(oDsCheck.Tables[0].Rows[0]["HEXPPERIOD"]);
                            grdMain.Rows[j].Cells[HISKFPERIODCol].Value = 1;
                            grdMain.Rows[j].Cells[HEXPUNITCol].Value = HEXPUNIT;
                            grdMain.Rows[j].Cells[HEXPPERIODCol].Value = HEXPPERIOD.ToString();
                            grdMain.Rows[j].Cells[HProduceDateCol].Value = HProduceDate.ToShortDateString();
                            if (HEXPUNIT == "Y")
                            {
                                grdMain.Rows[j].Cells[HExpiryDateCol].Value = HProduceDate.AddYears(HEXPPERIOD).ToShortDateString();
                            }
                            else if (HEXPUNIT == "M")
                            {
                                grdMain.Rows[j].Cells[HExpiryDateCol].Value = HProduceDate.AddMonths(HEXPPERIOD).ToShortDateString();
                            }
                            else
                            {
                                grdMain.Rows[j].Cells[HExpiryDateCol].Value = HProduceDate.AddDays(HEXPPERIOD).ToShortDateString();
                            }
                        }
                        else
                        {
                            grdMain.Rows[j].Cells[HISKFPERIODCol].Value = 0;
                            grdMain.Rows[j].Cells[HEXPUNITCol].Value = "";
                            grdMain.Rows[j].Cells[HEXPPERIODCol].Value = 0;
                            grdMain.Rows[j].Cells[HProduceDateCol].Value = "";
                            grdMain.Rows[j].Cells[HExpiryDateCol].Value = "";
                        }
                    }
                }
            }
@@ -703,6 +761,8 @@
            int k = 0;
            Int64 n = 0;                  //同一批生成条码中的第几条
            string sTMNumber = "";      //条码自定义前缀
            string sSourceBillNo = "";       //源单号
            string sSourceEntryID = "";       //行号(源单子ID)
            DataSet Ds;
            //Ds = oCn.RunProcReturn("exec GetLSH '" + ClsPub.GetServerDate(0) + "'", "GetLSH");
            //LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
@@ -765,6 +825,23 @@
                            //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                            LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        }
                        else if (CampanyName == "中控")
                        {
                            sSourceBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBillNoCol].Value);
                            sSourceEntryID = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HSubIDCol].Value);
                            if (sSourceBillNo == "")
                            {
                                //条码前缀 = ç»„织代码 + ç‰©æ–™ä»£ç  + å¹´ + æœˆ + æ—¥
                                sTMNumber = HOrgNumber + HNumber + sYear + sPeriod + sDay;
                                Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                            }
                            else
                            {
                                //条码 = æºå•单号 + ç‰©æ–™ID + è¡Œå·
                                sTMNumber = sSourceBillNo + HNumber + sSourceEntryID;
                            }
                        }
                        else  //通用方法
                        {
                            //条码前缀 = ç»„织代码 + ç‰©æ–™ä»£ç  + å¹´ + æœˆ + æ—¥
@@ -789,6 +866,15 @@
                    {
                        TM = HOrgNumber + HNumber + HBatchNo;
                    }//博日特殊处理
                    else if (cmbHBarCodeType.Text == "序列码")
                    {
                        //条码规则: GX+物料内码+年年月月日日+5位流水号
                        LSHlen = 5;
                        //条码前缀 = GX+物料内码+年年月月日日
                        sTMNumber = "GX" + HNumber + sYear + sPeriod + sDay;
                        Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                        LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                    }
                    else if(cmbHBarCodeType.Text == "仪器外购件条码普通规则" || cmbHBarCodeType.Text == "仪器外购件条码容器规则")
                    {
                        //物料编码+单据日期(YYMMDD)+流水4位 
@@ -823,10 +909,10 @@
                        Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                                                                                                    //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        LSHlen = 5;
                        if (sTMNumber.Length != 16)
                        LSHlen = 4;
                        if (sTMNumber.Length != 16 && sTMNumber.Length != 15)
                        {
                            MessageBox.Show("条码长度不够16位,是否数据不全!制造本部1位:[0] + æœºåž‹ä»£ç 5位:[" + HModelName + "] + å¹´æœˆæ—¥5位:["+ HBarCodeDate + "] + æ‰¹æ¬¡å·2位:[" + HBarCodeBatchNo  + "]+ åŽ‹ç¼©æœº1位:["+ HYasuoji + "]+00 ; ");
                            MessageBox.Show("条码长度不够15或16位,是否数据不全!制造本部1位:[0] + æœºåž‹ä»£ç 5位:[" + HModelName + "] + å¹´æœˆæ—¥4或5位:["+ HBarCodeDate + "] + æ‰¹æ¬¡å·2位:[" + HBarCodeBatchNo  + "]+ åŽ‹ç¼©æœº1位:["+ HYasuoji + "]+00 ; ");
                            return;
                        }
                    }
@@ -838,10 +924,10 @@
                        Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                                                                                                    //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        LSHlen = 5;
                        if (sTMNumber.Length != 18)
                        LSHlen = 4;
                        if (sTMNumber.Length != 18 && sTMNumber.Length != 17)
                        {
                            MessageBox.Show("条码长度不够18位,是否数据不全!物料代码11位:["+ HMaterNumber.Replace(".", "") + "]+年月日5位:["+ HBarCodeDate + "]+批次号2位:[" + HBarCodeBatchNo  + "];");
                            MessageBox.Show("条码长度不够17或18位,是否数据不全!物料代码11位:["+ HMaterNumber.Replace(".", "") + "]+年月日4或5位:["+ HBarCodeDate + "]+批次号2位:[" + HBarCodeBatchNo  + "];");
                            return;
                        }
                    }
@@ -864,10 +950,13 @@
                        return;
                    }
                    Int64 HBQty2 = 0;              //箱数
                    HBQty2 =ClsPub.isLong(grdMain.Rows[j].Cells[HBQtyCol].Value);
                    HBQty = HBQty + ClsPub.isLong(grdMain.Rows[j].Cells[HBQtyCol].Value);
                    HMinQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HMinQtyCol].Value);
                    HSumQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HQtyCol].Value);
                    n = 0;
                    int nn = 0;
                    for (int i = k; i < HBQty; i++)
                    {
                        if (HSumQty - HMinQty > 0)
@@ -895,6 +984,33 @@
                            LSH2 = "0" + LSH2;
                        }
                        if (cmbHBarCodeType.Text == "唯一条码")
                        {
                            if (CampanyName == "中控")
                            {
                                if (sSourceBillNo == "")
                                {
                                    //条码编号 = æ¡ç å‰ç¼€ + æµæ°´å·
                                    TM = sTMNumber + LSH2;
                                }
                                else
                                {
                                    if (HBQty2 > 1)
                                    {
                                        MessageBox.Show("生产汇报单、收料通知单生成条码时,箱数不能大于1!");
                                        bc.Enabled = true;
                                        return;
                                    }
                                    //条码编号 = æ¡ç å‰ç¼€
                                    TM = sTMNumber;
                                }
                            }
                            else
                            {
                                //条码编号 = æ¡ç å‰ç¼€ + æµæ°´å·
                                TM = sTMNumber + LSH2;
                            }
                        }
                        else if (cmbHBarCodeType.Text == "序列码")
                        {
                            //条码编号 = æ¡ç å‰ç¼€ + æµæ°´å·
                            TM = sTMNumber + LSH2;
@@ -976,16 +1092,31 @@
                        grdSub.Rows[i].Cells[HInnerBillNo2Col].Value = grdMain.Rows[j].Cells[HInnerBillNoCol].Value;
                        grdSub.Rows[i].Cells[HMaker2Col].Value = grdMain.Rows[j].Cells[HMakerCol].Value;
                        grdSub.Rows[i].Cells[HGiveAwayFlag2Col].Value = grdMain.Rows[j].Cells[HGiveAwayFlagCol].Value;
                        grdSub.Rows[i].Cells[HProduceDate2Col].Value = grdMain.Rows[j].Cells[HProduceDateCol].Value;
                        grdSub.Rows[i].Cells[HExpiryDate2Col].Value = grdMain.Rows[j].Cells[HExpiryDateCol].Value;
                        grdSub.Rows[i].Cells[HISKFPERIOD2Col].Value = grdMain.Rows[j].Cells[HISKFPERIODCol].Value;
                        grdSub.Rows[i].Cells[HEXPUNIT2Col].Value = grdMain.Rows[j].Cells[HEXPUNITCol].Value;
                        grdSub.Rows[i].Cells[HEXPPERIOD2Col].Value = grdMain.Rows[j].Cells[HEXPPERIODCol].Value;
                        //网格打勾
                        //是否赠品
                        DataGridViewCheckBoxCell oCell = new DataGridViewCheckBoxCell();
                        oCell.ThreeState = false;
                        oCell.Value = grdSub.Rows[i].Cells[HGiveAwayFlag2Col].Value;
                        oCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                        grdSub.Rows[i].Cells[HGiveAwayFlag2Col] = oCell;
                        //是否启用保质期
                        DataGridViewCheckBoxCell oCell2 = new DataGridViewCheckBoxCell();
                        oCell2.ThreeState = false;
                        oCell2.Value = grdSub.Rows[i].Cells[HISKFPERIOD2Col].Value;
                        oCell2.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                        grdSub.Rows[i].Cells[HISKFPERIOD2Col] = oCell2;
                        k = k + 1;
                        n = n + 1;
                        oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        nn = nn + 1;
                    }
                    //后台批量执行语句
                    oCn.RunProc("exec h_p_WMS_SetMaxNo_QTY '" + sTMNumber + "'," + nn.ToString() + " ");
                }
            }
            string HWei = "";      //尾数
@@ -1022,6 +1153,11 @@
            string HInnerBillNo = "";
            bool HGiveAwayFlag = false;
            Int64 HEntryID = 0;
            string HProduceDate;
            string HExpiryDate;
            bool HISKFPERIOD = false;
            string HEXPUNIT = "";
            double HEXPPERIOD = 0;
            try
            {
                oCn.BeginTran();
@@ -1067,6 +1203,25 @@
                        HSeOrderSEQ = ClsPub.isLong(grdSub.Rows[i].Cells[HSeOrderSEQ2Col].Value);
                        HInnerBillNo = ClsPub.isStrNull(grdSub.Rows[i].Cells[HInnerBillNo2Col].Value);
                        HGiveAwayFlag = ClsPub.isBool(grdSub.Rows[i].Cells[HGiveAwayFlag2Col].Value);
                        if (ClsPub.isDate(grdSub.Rows[i].Cells[HProduceDate2Col].Value) < Convert.ToDateTime("1950-01-01"))
                        {
                            HProduceDate = "";
                        }
                        else
                        {
                            HProduceDate = ClsPub.isStrNull(grdSub.Rows[i].Cells[HProduceDate2Col].Value);
                        }
                        if (ClsPub.isDate(grdSub.Rows[i].Cells[HExpiryDate2Col].Value) < Convert.ToDateTime("1950-01-01"))
                        {
                            HExpiryDate = "";
                        }
                        else
                        {
                            HExpiryDate = ClsPub.isStrNull(grdSub.Rows[i].Cells[HExpiryDate2Col].Value);
                        }
                        HISKFPERIOD = ClsPub.isBool(grdSub.Rows[i].Cells[HISKFPERIOD2Col].Value);
                        HEXPUNIT = ClsPub.isStrNull(grdSub.Rows[i].Cells[HEXPUNIT2Col].Value);
                        HEXPPERIOD = ClsPub.isDoule(grdSub.Rows[i].Cells[HEXPPERIOD2Col].Value);
                        oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
                                    ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
                                    ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
@@ -1074,6 +1229,8 @@
                                    ",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate " +
                                    ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
                                    ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
                                    ",HProduceDate,HExpiryDate " +
                                    ",HISKFPERIOD,HEXPUNIT,HEXPPERIOD " +
                                    ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " +
                                    ") values ("
                                    + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString()
@@ -1081,8 +1238,10 @@
                                    + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "','" + HWei + "'"
                                    + ", " + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'"
                                    + ", " + HCusID.ToString() + ",'" + HCusType + "','" + HEndDate.ToShortDateString() + "','" + HWorkLineName + "','" + sDate + "'"
                                    + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",'" + HSeOrderBillNo + "'," + HInterID.ToString() + "," + HEntryID.ToString() + ""
                                    + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",'" + HSeOrderBillNo + "'," + HInterID.ToString() + "," + HEntryID.ToString()
                                    + ", " + 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 + "')");
@@ -1489,7 +1648,7 @@
            //
            grdMain.RowCount = 0;
            grdSub.RowCount = 0;
            grdMain.ColumnCount = 63;                       //总列数
            grdMain.ColumnCount = 68;                       //总列数
            DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name);
            grdMain.Columns[HSnoCol].HeaderText = "序号";
            grdMain.Columns[HMainIDCol].HeaderText = "源单主ID";
@@ -1546,6 +1705,11 @@
            grdMain.Columns[HShowDateCol].HeaderText = "日期";
            grdMain.Columns[HInnerBillNoCol].HeaderText = "内部采购订单号";
            grdMain.Columns[HMakerCol].HeaderText = "制单人";
            grdMain.Columns[HProduceDateCol].HeaderText = "生产日期";
            grdMain.Columns[HExpiryDateCol].HeaderText = "有效期至";
            grdMain.Columns[HISKFPERIODCol].HeaderText = "是否启用保质期";
            grdMain.Columns[HEXPUNITCol].HeaderText = "保质期单位";
            grdMain.Columns[HEXPPERIODCol].HeaderText = "保质期";
            ////
            //格式化 
            grdMain.Columns[HTagCol].Visible = false;                           //隐藏列
@@ -1593,7 +1757,12 @@
            grdMain.Columns[HSourceIDCol].Visible = false;
            grdMain.Columns[HSourceNumberCol].Visible = false;
            grdMain.Columns[HSourceNameCol].Visible = false;
            //grdMain.Columns[HProduceDateCol].Visible = false;
            //grdMain.Columns[HExpiryDateCol].Visible = false;
            grdMain.Columns[HISKFPERIODCol].Visible = false;
            grdMain.Columns[HEXPUNITCol].Visible = false;
            grdMain.Columns[HEXPPERIODCol].Visible = false;
            //设置可编辑列
            string sAllowCol =  HQtyCol.ToString()+
                                "," + HMinQtyCol.ToString() +
@@ -1623,7 +1792,7 @@
            DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol,oSumGrid);
            //----------------------------
            grdSub.ColumnCount = 60;                       //总列数
            grdSub.ColumnCount = 65;                       //总列数
            DBUtility.Xt_BaseBillFun.initGridFst(grdSub, this.Name);
            grdSub.Columns[HSelectCol].HeaderText = "选择";
            grdSub.Columns[HTMCol].HeaderText = "条码编号";
@@ -1683,6 +1852,11 @@
            grdSub.Columns[HInnerBillNo2Col].HeaderText = "内部采购订单号";
            grdSub.Columns[HMaker2Col].HeaderText = "制单人";
            grdSub.Columns[HEntryID2Col].HeaderText = "行号";
            grdSub.Columns[HProduceDate2Col].HeaderText = "生产日期";
            grdSub.Columns[HExpiryDate2Col].HeaderText = "有效期至";
            grdSub.Columns[HISKFPERIOD2Col].HeaderText = "是否启用保质期";
            grdSub.Columns[HEXPUNIT2Col].HeaderText = "保质期单位";
            grdSub.Columns[HEXPPERIOD2Col].HeaderText = "保质期";
            //格式化 
            grdSub.Columns[HMaterID2Col].Visible = false;
            grdSub.Columns[HModel2Col].Visible = false;
@@ -1731,11 +1905,18 @@
            for (int i = 0; i < grdSub.Rows.Count; i++)
            {
                //网格打勾
                //是否赠品
                DataGridViewCheckBoxCell oCell = new DataGridViewCheckBoxCell();
                oCell.ThreeState = false;
                oCell.Value = 0;
                oCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                grdSub.Rows[i].Cells[HGiveAwayFlag2Col] = oCell;
                //是否启用保质期
                DataGridViewCheckBoxCell oCell2 = new DataGridViewCheckBoxCell();
                oCell2.ThreeState = false;
                oCell2.Value = 0;
                oCell2.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                grdSub.Rows[i].Cells[HISKFPERIOD2Col] = oCell2;
            }
            DBUtility.Xt_BaseBillFun.GetGrid(grdMain, this.Name);
@@ -1929,6 +2110,11 @@
                                            grdMain.Rows[sRow].Cells[HUnitNumberCol].Value = "";
                                            grdMain.Rows[sRow].Cells[HUnitNameCol].Value = "";
                                        }
                                        if (CampanyName == "中控")
                                        {
                                            grdMain.Rows[sRow].Cells[HQtyCol].Value = oMater.omodel.HQtyMin;
                                            grdMain.Rows[sRow].Cells[HBQtyCol].Value = 1;
                                        }
                                        oEdit.Text = oMater.omodel.HNumber;
                                    }
                                    else
@@ -2058,7 +2244,17 @@
            if (cmbSourceBillType.Text.Trim() == "生产订单")
            {
                string sWhere = " and HOrgID =" + HOrgID.ToString();
                string sWhere = "";
                //系统参数,生成条码数量可否超源单数量控制(N为不可超源单数量)
                if (SourceQtyCtl == "N")
                {
                    sWhere = " and HOrgID =" + HOrgID.ToString() + " and ä»»åŠ¡æ•°é‡>0";
                }
                else
                {
                    sWhere = " and HOrgID =" + HOrgID.ToString();
                }
                DAL.Cls_S_IFCLD_ICMOList oIFCLD_ICMOList = new DAL.Cls_S_IFCLD_ICMOList();
                if (oIFCLD_ICMOList.Refresh(sWhere))  //选择原单
                {
@@ -2173,6 +2369,24 @@
                    FillSelectData(oIF_PackageDismantleBillList.oBillSelectColl);
                }
            }
            else if (cmbSourceBillType.Text.Trim() == "工序流转卡")
            {
                string sWhere = " and HOrgID =" + HOrgID.ToString();
                DAL.Cls_S_IF_ProcessExchangeBillList oIF_ProcessExchangeBillList = new DAL.Cls_S_IF_ProcessExchangeBillList();
                if (oIF_ProcessExchangeBillList.Refresh(sWhere))  //选择原单
                {
                    FillSelectData(oIF_ProcessExchangeBillList.oBillSelectColl);
                }
            }
            else if (cmbSourceBillType.Text.Trim() == "工序汇报单")
            {
                string sWhere = " and HOrgID =" + HOrgID.ToString();
                DAL.Cls_S_IF_ProcessReportBillList oIF_ProcessReportBillList = new DAL.Cls_S_IF_ProcessReportBillList();
                if (oIF_ProcessReportBillList.Refresh(sWhere))  //选择原单
                {
                    FillSelectData(oIF_ProcessReportBillList.oBillSelectColl);
                }
            }
            else
            {
@@ -2194,7 +2408,8 @@
                    grdMain.Rows.Add();
                    grdMain.Rows[i].Cells[HTagCol].Value = "*";
                    //得到信息
                    Ds = oCn.RunProcReturn("select * from h_v_IFCLD_ICMOList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IFCLD_ICMOList");
                    Ds = oCn.RunProcReturn("exec h_p_Gy_BarCodeBill_ICMOBillList " + oSelectRow.BillMainID.ToString() + "," + oSelectRow.BillSubID.ToString() + ",'" + SourceQtyCtl + "'", "h_p_Gy_BarCodeBill_ICMOBillList");
                    //Ds = oCn.RunProcReturn("select * from h_v_IFCLD_ICMOList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IFCLD_ICMOList");
                    //写入信息
                    Sub_WriteInForm(Ds.Tables[0], i);
                }
@@ -2244,7 +2459,7 @@
                    grdMain.Rows.Add();
                    grdMain.Rows[i].Cells[HTagCol].Value = "*";
                    //得到信息
                    Ds = oCn.RunProcReturn("select * from h_v_IF_POStockInList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_POStockInList");
                    Ds = oCn.RunProcReturn("select * from h_v_IF_POStockInBillList_Source where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_POStockInBillList_Source");
                    //写入信息
                    Sub_WriteInForm1(Ds.Tables[0], i);
                }
@@ -2318,13 +2533,33 @@
                    //写入信息
                    Sub_WriteInForm1(Ds.Tables[0], i);
                }
                //工序流转卡
                if (oSelectRow.BillType == "3772")
                {
                    grdMain.Rows.Add();
                    grdMain.Rows[i].Cells[HTagCol].Value = "*";
                    //得到信息
                    Ds = oCn.RunProcReturn("select * from h_v_IF_ProcessExchangeList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_ProcessExchangeList");
                    //写入信息
                    Sub_WriteInForm1(Ds.Tables[0], i);
                }
                //工序汇报单
                if (oSelectRow.BillType == "3714")
                {
                    grdMain.Rows.Add();
                    grdMain.Rows[i].Cells[HTagCol].Value = "*";
                    //得到信息
                    Ds = oCn.RunProcReturn("select * from h_v_IF_ProcessReportList where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_IF_ProcessReportList");
                    //写入信息
                    Sub_WriteInForm1(Ds.Tables[0], i);
                }
                //即时库存
                if (oSelectRow.BillType == "JSKC")
                {
                    grdMain.Rows.Add();
                    Application.DoEvents();
                    //得到信息
                    Ds = oCn.RunProcReturn("select * from h_v_KF_ICInventoryList_IF where hmaterid=" + oSelectRow.BillMainID + " and hwhid=" + oSelectRow.BillSubID + " and hspid=" + oSelectRow.SPID + " and HAuxPropID=" + oSelectRow.HAuxPropID + " and æ‰¹æ¬¡='" + oSelectRow.BatchNo + "' and è®¡åˆ’跟踪号='" + oSelectRow.BillNo + "'", "h_v_KF_ICInventoryList_IF");
                    Ds = oCn.RunProcReturn("select * from h_v_KF_ICInventoryList_IF where hmaterid=" + oSelectRow.BillMainID + " and hwhid=" + oSelectRow.BillSubID + " and hspid=" + oSelectRow.SPID + " and HAuxPropID=" + oSelectRow.HAuxPropID + " and æ‰¹æ¬¡='" + oSelectRow.BatchNo + "' and è®¡åˆ’跟踪号='" + oSelectRow.BillNo + "' and ç”Ÿäº§æ—¥æœŸ='" + oSelectRow.HProduceDate + "' and æœ‰æ•ˆæœŸè‡³='" + oSelectRow.HExpiryDate + "'", "h_v_KF_ICInventoryList_IF");
                    //写入信息
                    Sub_WriteInForm2(Ds.Tables[0], i);
                }
@@ -2392,6 +2627,11 @@
            {
                grdMain.Rows[i].Cells[HMinQtyCol].Value = oTable.Rows[0]["最小包装数"].ToString();
            }
            grdMain.Rows[i].Cells[HProduceDateCol].Value = oTable.Rows[0]["HProduceDate"].ToString();
            grdMain.Rows[i].Cells[HExpiryDateCol].Value = oTable.Rows[0]["HExpiryDate"].ToString();
            grdMain.Rows[i].Cells[HISKFPERIODCol].Value = oTable.Rows[0]["HISKFPERIOD"].ToString();
            grdMain.Rows[i].Cells[HEXPUNITCol].Value = oTable.Rows[0]["HEXPUNIT"].ToString();
            grdMain.Rows[i].Cells[HEXPPERIODCol].Value = oTable.Rows[0]["HEXPPERIOD"].ToString();
            //--
            //设置可编辑列
            string sAllowCol = HQtyCol.ToString() +
@@ -2442,6 +2682,11 @@
            grdMain.Rows[i].Cells[HUnitNameCol].Value = oTable.Rows[0]["计量单位"].ToString();
            grdMain.Rows[i].Cells[HRemarkCol].Value = oTable.Rows[0]["备注"].ToString();
            grdMain.Rows[i].Cells[HMTONoCol].Value = oTable.Rows[0]["计划跟踪号"].ToString();
            grdMain.Rows[i].Cells[HProduceDateCol].Value = oTable.Rows[0]["生产日期"].ToString();
            grdMain.Rows[i].Cells[HExpiryDateCol].Value = oTable.Rows[0]["有效期至"].ToString();
            grdMain.Rows[i].Cells[HISKFPERIODCol].Value = oTable.Rows[0]["HISKFPERIOD"].ToString();
            grdMain.Rows[i].Cells[HEXPUNITCol].Value = oTable.Rows[0]["HEXPUNIT"].ToString();
            grdMain.Rows[i].Cells[HEXPPERIODCol].Value = oTable.Rows[0]["HEXPPERIOD"].ToString();
            if (cmbHBarCodeType.Text == "仪器外购件条码容器规则")
            {
                grdMain.Rows[i].Cells[HMinQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["未生成条码数量"]);
@@ -2452,7 +2697,14 @@
            }
            else
            {
                grdMain.Rows[i].Cells[HMinQtyCol].Value = oTable.Rows[0]["最小包装数"].ToString();
                if (CampanyName == "中控")
                {
                    grdMain.Rows[i].Cells[HMinQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["未生成条码数量"]);
                }
                else
                {
                    grdMain.Rows[i].Cells[HMinQtyCol].Value = oTable.Rows[0]["最小包装数"].ToString();
                }
            }
            grdMain.Rows[i].Cells[HMakerCol].Value = ClsPub.CurUserName;
            if (cmbSourceBillType.Text.Trim() == "收料通知单"|| cmbSourceBillType.Text.Trim() == "采购订单"
@@ -2548,6 +2800,15 @@
            grdMain.Rows[i].Cells[HShowDateCol].Value = dtpHDate.Value.ToShortDateString();
            grdMain.Rows[i].Cells[HRemarkCol].Value = "按库存生成";
            grdMain.Rows[i].Cells[HMTONoCol].Value = oTable.Rows[0]["计划跟踪号"].ToString();
            grdMain.Rows[i].Cells[HProduceDateCol].Value = oTable.Rows[0]["生产日期"].ToString();
            grdMain.Rows[i].Cells[HExpiryDateCol].Value = oTable.Rows[0]["有效期至"].ToString();
            grdMain.Rows[i].Cells[HISKFPERIODCol].Value = oTable.Rows[0]["HISKFPERIOD"].ToString();
            grdMain.Rows[i].Cells[HEXPUNITCol].Value = oTable.Rows[0]["HEXPUNIT"].ToString();
            grdMain.Rows[i].Cells[HEXPPERIODCol].Value = oTable.Rows[0]["HEXPPERIOD"].ToString();
            if (CampanyName == "中控")
            {
                grdMain.Rows[i].Cells[HMinQtyCol].Value = ClsPub.isDoule(oTable.Rows[0]["数量"]);
            }
            //--
            //设置可编辑列
            string sAllowCol = HQtyCol.ToString() +
@@ -3231,15 +3492,32 @@
                if (cmbSourceBillType.Text.Trim() == "生产订单")
                {
                    DAL.Cls_S_IFCLD_ICMOList oIFCLD_ICMOList = new DAL.Cls_S_IFCLD_ICMOList();
                    if (oIFCLD_ICMOList.RefreshBySourceBillNo(" Where å•据号 like '%" + txtHSourceBillNo.Text + "' and HOrgID =" + sHOrgID.ToString()))  //选择原单
                    //系统参数,生成条码数量可否超源单数量控制(N为不可超源单数量)
                    if (SourceQtyCtl == "N")
                    {
                        FillSelectData(oIFCLD_ICMOList.oBillSelectColl);
                        txtHSourceBillNo.Text = "";
                        if (oIFCLD_ICMOList.RefreshBySourceBillNo(" Where å•据号 like '%" + txtHSourceBillNo.Text + "' and HOrgID =" + sHOrgID.ToString() + " and ä»»åŠ¡æ•°é‡>0"))  //选择原单
                        {
                            FillSelectData(oIFCLD_ICMOList.oBillSelectColl);
                            txtHSourceBillNo.Text = "";
                        }
                        else
                        {
                            MessageBox.Show("未查询到任务数据,请确认所选组织、源单类型与源单单号是否正确!");
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("未查询到任务数据,请确认所选组织、源单类型与源单单号是否正确!");
                        return;
                        if (oIFCLD_ICMOList.RefreshBySourceBillNo(" Where å•据号 like '%" + txtHSourceBillNo.Text + "' and HOrgID =" + sHOrgID.ToString()))  //选择原单
                        {
                            FillSelectData(oIFCLD_ICMOList.oBillSelectColl);
                            txtHSourceBillNo.Text = "";
                        }
                        else
                        {
                            MessageBox.Show("未查询到任务数据,请确认所选组织、源单类型与源单单号是否正确!");
                            return;
                        }
                    }
                }
                else if (cmbSourceBillType.Text.Trim() == "生产汇报单")
@@ -3428,5 +3706,49 @@
                MessageBox.Show("生成箱码失败!" + e1.Message );
            }
        }
        private void cmbSourceBillType_TextChanged(object sender, EventArgs e)
        {
            if (cmbSourceBillType.Text == "工序流转卡")
            {
                cmbHBarCodeType.Items.Clear();
                cmbHBarCodeType.Items.Add("序列码");
                this.cmbHBarCodeType.SelectedIndex = 0;
            }
            else
            {
                if (CampanyName == "夏宝电器")
                {
                    cmbHBarCodeType.Items.Clear();
                    cmbHBarCodeType.Items.Add("内销机条码");
                    cmbHBarCodeType.Items.Add("外销机条码");
                    cmbHBarCodeType.Items.Add("半成品条码");
                    this.cmbHBarCodeType.SelectedIndex = 0;
                }
                else if (CampanyName == "博日科技")
                {
                    cmbHBarCodeType.Items.Clear();
                    cmbHBarCodeType.Items.Add("仪器外购件条码普通规则");
                    cmbHBarCodeType.Items.Add("仪器外购件条码容器规则");
                    cmbHBarCodeType.Items.Add("仪器成品条码规则");
                    cmbHBarCodeType.Items.Add("试剂成品条码规则");
                    this.cmbHBarCodeType.SelectedIndex = 0;
                }
                else if (CampanyName == "中控")
                {
                    cmbHBarCodeType.Items.Clear();
                    cmbHBarCodeType.Items.Add("唯一条码");
                    this.cmbHBarCodeType.SelectedIndex = 0;
                }
                else
                {
                    cmbHBarCodeType.Items.Clear();
                    cmbHBarCodeType.Items.Add("唯一条码");
                    cmbHBarCodeType.Items.Add("品种条码");
                    cmbHBarCodeType.Items.Add("批次条码");
                    this.cmbHBarCodeType.SelectedIndex = 0;
                }
            }
        }
    }
}