yusijie
2023-02-08 7f8ed8cdc49b33178f34c91edf862f831cd30c9c
WarM/ÌõÂë´òÓ¡/Gy_BarCodeBill.cs
@@ -43,42 +43,44 @@
        public const Int16 HQtyCol = 22;
        public const Int16 HMinQtyCol = 23;
        public const Int16 HBQtyCol = 24;
        public const Int16 HDeptIDCol = 25;
        public const Int16 HDeptNumberCol = 26;
        public const Int16 HDeptNameCol = 27;
        public const Int16 HSourceIDCol = 28;
        public const Int16 HSourceNumberCol = 29;
        public const Int16 HSourceNameCol = 30;
        public const Int16 HDateCol = 31;
        public const Int16 HEndDateCol = 32;
        public const Int16 HSupIDCol = 33;
        public const Int16 HSupNumberCol = 34;
        public const Int16 HSupNameCol = 35;
        public const Int16 HCusIDCol = 36;
        public const Int16 HCusNumberCol = 37;
        public const Int16 HCusNameCol = 38;
        public const Int16 HCusTypeCol = 39;
        public const Int16 HSourceInterIDCol = 40;
        public const Int16 HSourceEntryIDCol = 41;
        public const Int16 HSourceBillNoCol = 42;
        public const Int16 HSourceBillTypeCol = 43;
        public const Int16 HInstructIDCol = 44;
        public const Int16 HInstructNoCol = 45;
        public const Int16 HSeOrderBillIDCol = 46;
        public const Int16 HSeOrderBillNoCol = 47;
        public const Int16 HWhIDCol = 48;
        public const Int16 HWhNumberCol = 49;
        public const Int16 HWhNameCol = 50;
        public const Int16 HSPIDCol = 51;
        public const Int16 HSPNumberCol = 52;
        public const Int16 HSPNameCol = 53;
        public const Int16 HinitQtyCol = 54;
        public const Int16 HRemarkCol = 55;
        public const Int16 HPinfanBarCodeCol = 56;
        public const Int16 HMTONoCol = 57;
        public const Int16 HShowDateCol = 58;
        public const Int16 HInnerBillNoCol = 59;
        public const Int16 HMakerCol = 60;
        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 Int16 HSelectCol = 0;
        public Int16 HSno2Col = 1;
@@ -126,18 +128,20 @@
        public Int16 HInstructNo2Col = 43;
        public Int16 HSeOrderBillID2Col = 44;
        public Int16 HSeOrderBillNo2Col = 45;
        public Int16 HWhID2Col = 46;
        public Int16 HWhNumber2Col = 47;
        public Int16 HWhName2Col = 48;
        public Int16 HSPID2Col = 49;
        public Int16 HSPNumber2Col = 50;
        public Int16 HSPName2Col = 51;
        public Int16 HRemark2Col = 52;
        public Int16 HPinfanBarCode2Col = 53;
        public Int16 HMTONo2Col = 54;
        public Int16 HShowDate2Col = 55;
        public Int16 HInnerBillNo2Col = 56;
        public Int16 HMaker2Col = 57;
        public Int16 HSeOrderSEQ2Col = 46;
        public Int16 HWhID2Col = 47;
        public Int16 HWhNumber2Col = 48;
        public Int16 HWhName2Col = 49;
        public Int16 HSPID2Col = 50;
        public Int16 HSPNumber2Col = 51;
        public Int16 HSPName2Col = 52;
        public Int16 HRemark2Col = 53;
        public Int16 HPinfanBarCode2Col = 54;
        public Int16 HMTONo2Col = 55;
        public Int16 HShowDate2Col = 56;
        public Int16 HInnerBillNo2Col = 57;
        public Int16 HMaker2Col = 58;
        public Int16 HEntryID2Col = 59;
        //
        public  string ModName = "85";
        public  string ModCaption = "条码生成";
@@ -161,7 +165,10 @@
        public string ERPMode = ""; //ERP模式(WISE、CLOUD)
        public string CampanyName = ""; //客户定制化名称
        public string SourceQtyCtl = ""; //超源单数量控制
                                         //-------------------------------------------------------------------------
        public long PrintQty = 0;               //允许条码打印次数
        public string PrintQtyCtl = "";         //条码打印次数控制
        public string UpdatePrintQtyCtl = "";   //条码打印次数更新
                                                //-------------------------------------------------------------------------
        #region å›ºå®šä»£ç 
        //清空界面
@@ -204,6 +211,8 @@
            cmbSourceBillType.Items.Add("采购订单");
            cmbSourceBillType.Items.Add("收料通知单");
            cmbSourceBillType.Items.Add("委外订单");
            cmbSourceBillType.Items.Add("工序汇报单");
            cmbSourceBillType.Items.Add("工序流转卡");
            cmbSourceBillType.Items.Add("退货通知单");
            cmbSourceBillType.Items.Add("其他入库单");
            cmbSourceBillType.Items.Add("直接调拨单");
@@ -401,6 +410,9 @@
                ERPMode = oSystemParameter.omodel.WMS_WMSStockCtl_ERPMode;
                CampanyName = oSystemParameter.omodel.WMS_CampanyName;
                SourceQtyCtl = oSystemParameter.omodel.BarCode_SourceQtyCtl;
                PrintQty = oSystemParameter.omodel.BarCode_PrintQty;
                PrintQtyCtl = oSystemParameter.omodel.BarCode_PrintQtyCtl;
                UpdatePrintQtyCtl = oSystemParameter.omodel.BarCode_UpdatePrintQtyCtl;
            }
            cmbHWorksNumber.Items.Clear();
@@ -675,10 +687,10 @@
            string HMaterNumber = "";   //物料代码
            double HSumQty = 0;         //产品数量
            double HMinQty = 0;         //最小包装数
            int HBQty = 0;              //箱数
            Int64 HBQty = 0;              //箱数
            double HQty = 0;            //数量
            string WeiShu = "";         //尾数
            int LSH = 0;                //流水号
            Int64 LSH = 0;                //流水号
            string LSH2 = "";           //流水号转换成字符
            string sDate = "";          //日期
            string sYear = "";          //å¹´
@@ -691,7 +703,7 @@
            string HBarCodeBatchNo = "";       //条码批次号
            string HBarCodeDate = "";         //条码日期
            int k = 0;
            int n = 0;                  //同一批生成条码中的第几条
            Int64 n = 0;                  //同一批生成条码中的第几条
            string sTMNumber = "";      //条码自定义前缀
            DataSet Ds;
            //Ds = oCn.RunProcReturn("exec GetLSH '" + ClsPub.GetServerDate(0) + "'", "GetLSH");
@@ -738,7 +750,7 @@
                            sTMNumber = HNumber + sYear + sPeriod + sDay;
                            Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                            //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                            LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                            LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        }
                        else if (CampanyName == "飞龙")
                        {
@@ -753,7 +765,7 @@
                            sTMNumber = HWorksNumber + HNumber + sYear + sPeriod + sDay;
                            Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                            //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                            LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                            LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        }
                        else  //通用方法
                        {
@@ -761,7 +773,7 @@
                            sTMNumber = HOrgNumber + HNumber + sYear + sPeriod + sDay;
                            Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                            //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                            LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                            LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        }
                    }
                    else if (cmbHBarCodeType.Text == "品种条码")
@@ -779,13 +791,22 @@
                    {
                        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位 
                        sTMNumber = HMaterNumber + sYear + sPeriod + sDay;
                        Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                                                                                                    //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                        LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        LSHlen = 4;
                    }
                    else if (cmbHBarCodeType.Text == "仪器成品条码规则") //另外处理了
@@ -794,7 +815,7 @@
                        //sTMNumber = HMaterNumber + sYear + sPeriod + sDay;
                        //Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                        //                                                                                            //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        //LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                        //LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                    }
                    else if (cmbHBarCodeType.Text == "试剂成品条码规则")
                    {
@@ -802,7 +823,7 @@
                        sTMNumber = HMaterNumber + HBatchNo ;
                        Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                                                                                                    //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                        LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        LSHlen = 6;
                    }
                    else if (cmbHBarCodeType.Text == "内销机条码")
@@ -812,11 +833,11 @@
                        sTMNumber = "1" + HModelName + HBarCodeDate + HBarCodeBatchNo + HYasuoji + "00" ;
                        Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                                                                                                    //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                        LSHlen = 5;
                        if (sTMNumber.Length != 16)
                        LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        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;
                        }
                    }
@@ -827,11 +848,11 @@
                        sTMNumber = HMaterNumber.Replace( "."  ,  "" ) + HBarCodeDate + HBarCodeBatchNo;
                        Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                                                                                                    //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                        LSHlen = 5;
                        if (sTMNumber.Length != 18)
                        LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        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;
                        }
                    }
@@ -841,7 +862,7 @@
                        sTMNumber = HICMOBillNo;
                        Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                                                                                                                    //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                        LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        LSHlen = 5;
                    }
                    //else if (cmbHBarCodeType.Text == "托盘条码")
@@ -854,10 +875,11 @@
                        return;
                    }
                    HBQty = HBQty + ClsPub.isInt(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)
@@ -889,6 +911,11 @@
                            //条码编号 = æ¡ç å‰ç¼€ + æµæ°´å·
                            TM = sTMNumber + LSH2;
                        }
                        else if (cmbHBarCodeType.Text == "序列码")
                        {
                            //条码编号 = æ¡ç å‰ç¼€ + æµæ°´å·
                            TM = sTMNumber + LSH2;
                        }
                        else if(cmbHBarCodeType.Text == "仪器外购件条码普通规则" || cmbHBarCodeType.Text == "仪器外购件条码容器规则" || cmbHBarCodeType.Text == "试剂成品条码规则" 
                            || cmbHBarCodeType.Text == "半成品条码" || cmbHBarCodeType.Text == "外销机条码")
                        {
@@ -911,6 +938,7 @@
                            return;
                        }
                        grdSub.Rows[i].Cells[HTMCol].Value = TM;
                        grdSub.Rows[i].Cells[HEntryID2Col].Value = j + 1;
                        grdSub.Rows[i].Cells[HMaterID2Col].Value = grdMain.Rows[j].Cells[HMaterIDCol].Value;
                        grdSub.Rows[i].Cells[HMaterNumber2Col].Value = grdMain.Rows[j].Cells[HMaterNumberCol].Value;
                        grdSub.Rows[i].Cells[HMaterName2Col].Value = grdMain.Rows[j].Cells[HMaterNameCol].Value;
@@ -961,6 +989,7 @@
                        grdSub.Rows[i].Cells[HSourceName2Col].Value = grdMain.Rows[j].Cells[HSourceNameCol].Value;
                        grdSub.Rows[i].Cells[HEndDate2Col].Value = grdMain.Rows[j].Cells[HEndDateCol].Value;
                        grdSub.Rows[i].Cells[HSeOrderBillNo2Col].Value = grdMain.Rows[j].Cells[HSeOrderBillNoCol].Value;
                        grdSub.Rows[i].Cells[HSeOrderSEQ2Col].Value = grdMain.Rows[j].Cells[HSeOrderSEQCol].Value;
                        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;
@@ -972,8 +1001,11 @@
                        grdSub.Rows[i].Cells[HGiveAwayFlag2Col] = oCell;
                        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 = "";      //尾数
@@ -1006,8 +1038,10 @@
            DateTime HEndDate;
            string HWorkLineName = "";
            string HSeOrderBillNo = "";
            Int64 HSeOrderSEQ = 0;
            string HInnerBillNo = "";
            bool HGiveAwayFlag = false;
            Int64 HEntryID = 0;
            try
            {
                oCn.BeginTran();
@@ -1025,6 +1059,7 @@
                        }
                        //
                        HMaterID = ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value);
                        HEntryID = ClsPub.isLong(grdSub.Rows[i].Cells[HEntryID2Col].Value);
                        HAuxPropID = ClsPub.isLong(grdSub.Rows[i].Cells[HAuxPropID2Col].Value);
                        HUnitID = ClsPub.isLong(grdSub.Rows[i].Cells[HUnitID2Col].Value);
                        HQty2 = ClsPub.isDoule(grdSub.Rows[i].Cells[HQty2Col].Value);
@@ -1049,6 +1084,7 @@
                        HEndDate = ClsPub.isDate(grdSub.Rows[i].Cells[HEndDate2Col].Value);
                        HWorkLineName = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSourceName2Col].Value);
                        HSeOrderBillNo = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSeOrderBillNo2Col].Value);
                        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);
                        oCn.RunProc("insert into Gy_BarCodeBill (HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
@@ -1056,8 +1092,8 @@
                                    ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
                                    ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
                                    ",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate " +
                                    ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID " +
                                    ",HGiveAwayFlag " +
                                    ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HEntryID " +
                                    ",HGiveAwayFlag,HSeOrderSEQ,HInitSourceEntryID " +
                                    ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " +
                                    ") values ("
                                    + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString()
@@ -1065,8 +1101,8 @@
                                    + ", " + 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()
                                    + ", " + DBUtility.ClsPub.BoolToString(HGiveAwayFlag)
                                    + ", " + HOrgID.ToString() + "," + HOrgID.ToString() + ",'" + HSeOrderBillNo + "'," + HInterID.ToString() + "," + HEntryID.ToString() + ""
                                    + ", " + DBUtility.ClsPub.BoolToString(HGiveAwayFlag) + "," + HSeOrderSEQ.ToString() + "," + HSourceEntryID.ToString()
                                    + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HInnerBillNo + "')");
@@ -1149,7 +1185,7 @@
            string HMaterNumber = "";   //物料代码
            double HSumQty = 0;         //产品数量
            double HMinQty = 0;         //最小包装数
            int HBQty = 0;              //箱数
            Int64 HBQty = 0;              //箱数
            double HQty = 0;            //数量
            string WeiShu = "";         //尾数
            //int LSH = 0;                //流水号
@@ -1200,7 +1236,7 @@
                    //    return;
                    //}
                    HBQty = HBQty + ClsPub.isInt(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;
@@ -1473,7 +1509,7 @@
            //
            grdMain.RowCount = 0;
            grdSub.RowCount = 0;
            grdMain.ColumnCount = 61;                       //总列数
            grdMain.ColumnCount = 63;                       //总列数
            DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name);
            grdMain.Columns[HSnoCol].HeaderText = "序号";
            grdMain.Columns[HMainIDCol].HeaderText = "源单主ID";
@@ -1499,6 +1535,7 @@
            grdMain.Columns[HGiveAwayFlagCol].HeaderText = "是否赠品";
            grdMain.Columns[HQtyCol].HeaderText = "数量";
            grdMain.Columns[HMinQtyCol].HeaderText = "最小包装数";
            grdMain.Columns[HPackQtyCol].HeaderText = "外箱数";
            grdMain.Columns[HBQtyCol].HeaderText = "箱数";
            grdMain.Columns[HSupIDCol].HeaderText = "供应商ID";
            grdMain.Columns[HSupNumberCol].HeaderText = "供应商代码";
@@ -1514,6 +1551,7 @@
            grdMain.Columns[HSPNameCol].HeaderText = "仓位";
            grdMain.Columns[HInstructNoCol].HeaderText = "指令单号";
            grdMain.Columns[HSeOrderBillNoCol].HeaderText = "销售订单号";
            grdMain.Columns[HSeOrderSEQCol].HeaderText = "销售订单行号";
            grdMain.Columns[HDateCol].HeaderText = "进料日期";
            grdMain.Columns[HRemarkCol].HeaderText = "备注";
            grdMain.Columns[HMTONoCol].HeaderText = "计划跟踪号";
@@ -1585,6 +1623,7 @@
                                "," + HSeOrderBillNoCol.ToString() +
                                "," + HBatchNoCol.ToString() +
                                "," + HCusNumberCol.ToString() +
                                "," + HPackQtyCol.ToString() +
                                "," + HRemarkCol.ToString();
            //设置合计列
            string sTotalCol = HQtyCol.ToString();
@@ -1604,7 +1643,7 @@
            DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol,oSumGrid);
            //----------------------------
            grdSub.ColumnCount = 58;                       //总列数
            grdSub.ColumnCount = 60;                       //总列数
            DBUtility.Xt_BaseBillFun.initGridFst(grdSub, this.Name);
            grdSub.Columns[HSelectCol].HeaderText = "选择";
            grdSub.Columns[HTMCol].HeaderText = "条码编号";
@@ -1633,6 +1672,7 @@
            grdSub.Columns[HSourceBillNo2Col].HeaderText = "源单单号";
            grdSub.Columns[HSourceBillType2Col].HeaderText = "源单类型";
            grdSub.Columns[HSeOrderBillNo2Col].HeaderText = "销售订单号";
            grdSub.Columns[HSeOrderSEQ2Col].HeaderText = "销售订单行号";
            grdSub.Columns[HBarcodeNoCol].HeaderText = "托号";
            grdSub.Columns[HBarcodeQtysCol].HeaderText = "总托数";
            grdSub.Columns[HSupID2Col].HeaderText = "供应商ID";
@@ -1662,6 +1702,7 @@
            grdSub.Columns[HShowDate2Col].HeaderText = "日期";
            grdSub.Columns[HInnerBillNo2Col].HeaderText = "内部采购订单号";
            grdSub.Columns[HMaker2Col].HeaderText = "制单人";
            grdSub.Columns[HEntryID2Col].HeaderText = "行号";
            //格式化 
            grdSub.Columns[HMaterID2Col].Visible = false;
            grdSub.Columns[HModel2Col].Visible = false;
@@ -2152,6 +2193,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
            {
@@ -2297,6 +2356,26 @@
                    //写入信息
                    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")
                {
@@ -2377,6 +2456,7 @@
                                "," + HMinQtyCol.ToString() +
                                "," + HAuxPropNumberCol.ToString() +
                                "," + HBatchNoCol.ToString() +
                                "," + HPackQtyCol.ToString() +
                                "," + HRemarkCol.ToString();
            grdMain.Columns[HBillNoCol].ReadOnly = true;
            //设置合计列
@@ -2450,6 +2530,8 @@
                    {
                        grdMain.Rows[i].Cells[HGiveAwayFlagCol].Value = 0;
                    }
                    grdMain.Rows[i].Cells[HSeOrderBillNoCol].Value = oTable.Rows[0]["销售订单号"].ToString();
                    grdMain.Rows[i].Cells[HSeOrderSEQCol].Value = oTable.Rows[0]["销售订单行号"].ToString();
                }
            }
@@ -2689,9 +2771,10 @@
        #region  //打印设置
        GridppReport Report;
        int CurRows = 0;
        string sBarCodeItemID = ""; //条码自增列
        //预览
        int CurRows = 0;
        private void yl_Click(object sender, EventArgs e)
        {
            //判断是否已经生成条码
@@ -2720,32 +2803,68 @@
            }
        }
        //打印前判断条码是否已打印过
        //打印
        private void dy_Click(object sender, EventArgs e)
        {
            //判断是否已经生成条码
            if (DBUtility.ClsPub.isStrNull(grdSub.Rows[0].Cells[HTMCol].Value) == "")
            {
                MessageBox.Show("条码未生成,请先生成条码后再打印!");
                return;
            }
            //打印前判断条码是否已打印过
            if (ReportPrintBegin())
            {
                return;
            }
            //选择打印模板
            BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
            oFrm.sBillName = ModName;
            oFrm.sBillModel = ModCaption;
            oFrm.ShowDialog();
            if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
            {
                //循环选中行
                Sub_SetReport(oFrm.sOpenTmp);
                Report.Print(true);
                Thread.Sleep(1000);
            }
        }
        ////打印前判断条码是否已打印过
        //private bool ReportPrintBegin()
        //{
        //    string sRelQty = "";
        //    if (oBar.Set_BPrintQty(DBUtility.ClsPub.isStrNull(grdSub.Rows[0].Cells[HTMCol].Value), ref sRelQty))
        //    {
        //        MessageBox.Show("条码已经打印过,不可重复打印!");
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}
        //打印前判断条码是否超过允许可打印次数
        private bool ReportPrintBegin()
        {
            string sRelQty = "";
            if (oBar.Set_BPrintQty(DBUtility.ClsPub.isStrNull(grdSub.Rows[0].Cells[HTMCol].Value), ref sRelQty))
            string sHRemark = "";
            if (PrintQtyCtl == "Y")
            {
                MessageBox.Show("条码已经打印过,不可重复打印!");
                return true;
                if (oBar.Set_CheckPrintQty_SD(HInterID, PrintQty, ref sHRemark))
                {
                    MessageBox.Show(sHRemark);
                    return true;
                }
                return false;
            }
            else
            {
                return false;
            }
        }
        //打印结束后回填条码打印次数
        private void ReportPrintEnd()
        {
            try
            {
                oCn.RunProc("update Gy_BarCodeBill set HPrintQty=isnull(HPrintQty,0)+1 where HInterID=" + HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
            }
            catch (Exception e)
            {
                MessageBox.Show("打印失败!打印结束 ï¼š" + e.Message);
            }
        }
@@ -2755,26 +2874,6 @@
            for (int i = 0; i < grdList.Rows.Count; i++)
            {
                grdList.Rows[i].Cells[0].Value = "*";
            }
            //
            Report = new GridppReport();
            Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf");  //here .
            Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
            Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
            Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
        }
        private void Sub_SetReportView(string sOpenTmp)
        {
            //判断行数
            for (int i = 0; i < grdList.Rows.Count; i++)
            {
                grdList.Rows[i].Cells[0].Value = "";
            }
            for (int i = 0; i < grdList.SelectedRows.Count; i++)
            {
                grdList.Rows[grdList.SelectedRows[i].Index].Cells[0].Value = "*";
            }
            //
            Report = new GridppReport();
@@ -2806,11 +2905,7 @@
            }
        }
        private Int32 Fun_GetCol(string sCol)
        {
            return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdList);
        }
        //填入单据表体信息
        private void ReportFetchRecordByDataTable()
        {
            try
@@ -2824,17 +2919,40 @@
            }
        }
        private void dy_Click(object sender, EventArgs e)
        ////打印结束后回填条码打印次数
        //private void ReportPrintEnd()
        //{
        //    try
        //    {
        //        oCn.RunProc("update Gy_BarCodeBill set HPrintQty=isnull(HPrintQty,0)+1 where HInterID=" + HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
        //    }
        //    catch (Exception e)
        //    {
        //        MessageBox.Show("打印失败!打印结束 ï¼š" + e.Message);
        //    }
        //}
        //打印结束后回填条码打印次数
        private void ReportPrintEnd()
        {
            if (UpdatePrintQtyCtl == "Y")
            {
                oBar.Set_UpdatePrintQty_SD(HInterID);
            }
        }
        //试打印
        private void sdy_Click(object sender, EventArgs e)
        {
            //判断是否已经生成条码
            if (DBUtility.ClsPub.isStrNull(grdSub.Rows[0].Cells[HTMCol].Value) == "")
            {
                MessageBox.Show("条码未生成,请先生成条码后再打印!");
                MessageBox.Show("条码未生成,请先生成条码后再预览!");
                return;
            }
            //打印前判断条码是否已打印过
            if (ReportPrintBegin())
            if (ReportPrintBegin_SDY())
            {
                return;
            }
@@ -2846,12 +2964,71 @@
            oFrm.ShowDialog();
            if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
            {
                //循环选中行
                Sub_SetReport(oFrm.sOpenTmp);
                Report.Print(true);
                Sub_SetReportView(oFrm.sOpenTmp);
                Report.PrintPreview(false);
                Thread.Sleep(1000);
            }
        }
        //打印前判断条码是否超过允许可打印次数
        private bool ReportPrintBegin_SDY()
        {
            string sHRemark = "";
            sBarCodeItemID = "";
            for (int i = 0; i < grdList.SelectedRows.Count; i++)
            {
                sBarCodeItemID = sBarCodeItemID + "," + DBUtility.ClsPub.isLong(grdList.Rows[grdList.SelectedRows[i].Index].Cells[Fun_GetCol("HItemID")].Value).ToString();
            }
            sBarCodeItemID = sBarCodeItemID.Remove(0, 1);
            if (PrintQtyCtl == "Y")
            {
                if (oBar.Set_CheckPrintQty(sBarCodeItemID, PrintQty, ref sHRemark))
                {
                    MessageBox.Show(sHRemark);
                    return true;
                }
                return false;
            }
            else
            {
                return false;
            }
        }
        private void Sub_SetReportView(string sOpenTmp)
        {
            //判断行数
            for (int i = 0; i < grdList.Rows.Count; i++)
            {
                grdList.Rows[i].Cells[0].Value = "";
            }
            for (int i = 0; i < grdList.SelectedRows.Count; i++)
            {
                grdList.Rows[grdList.SelectedRows[i].Index].Cells[0].Value = "*";
            }
            //
            Report = new GridppReport();
            Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf");  //here .
            Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
            Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
            Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd_SDY);
        }
        //打印结束后回填条码打印次数
        private void ReportPrintEnd_SDY()
        {
            if (UpdatePrintQtyCtl == "Y")
            {
                oBar.Set_UpdatePrintQty(sBarCodeItemID);
            }
        }
        private Int32 Fun_GetCol(string sCol)
        {
            return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdList);
        }
        #endregion
@@ -2895,7 +3072,7 @@
            }
            sWhere = " and HOrgID =" + sHOrgID.ToString();
            BLL.Cls_S_KF_ICInventoryList_IF oadd = new BLL.Cls_S_KF_ICInventoryList_IF();
            if (oadd.Refresh(""))  //选择原单
            if (oadd.Refresh(sWhere))  //选择原单
            //if (oadd.Refresh(" and HErpClsID in (1,2,3) "))  //选择原单
            {
                FillSelectData(oadd.oBillSelectColl);
@@ -2994,6 +3171,12 @@
                grdMain.Rows[row + r].Cells[HMTONoCol].Value = grdMain.Rows[row].Cells[HMTONoCol].Value;
                grdMain.Rows[row + r].Cells[HInnerBillNoCol].Value = grdMain.Rows[row].Cells[HInnerBillNoCol].Value;
                grdMain.Rows[row + r].Cells[HMakerCol].Value = grdMain.Rows[row].Cells[HMakerCol].Value;
                //网格打勾
                DataGridViewCheckBoxCell oCell = new DataGridViewCheckBoxCell();
                oCell.ThreeState = false;
                oCell.Value = grdMain.Rows[row].Cells[HGiveAwayFlagCol].Value;
                oCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                grdMain.Rows[row + r].Cells[HGiveAwayFlagCol] = oCell;
            }
            DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
@@ -3182,61 +3365,144 @@
            }
        }
        private void sdy_Click(object sender, EventArgs e)
        {
            //判断是否已经生成条码
            if (DBUtility.ClsPub.isStrNull(grdSub.Rows[0].Cells[HTMCol].Value) == "")
            {
                MessageBox.Show("条码未生成,请先生成条码后再预览!");
                return;
            }
            //打印前判断条码是否已打印过
            if (ReportPrintBegin())
            {
                return;
            }
            //选择打印模板
            BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
            oFrm.sBillName = ModName;
            oFrm.sBillModel = ModCaption;
            oFrm.ShowDialog();
            if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
            {
                Sub_SetReportView(oFrm.sOpenTmp);
                Report.PrintPreview(false);
                Thread.Sleep(1000);
            }
        }
        //生成外箱码
        private void wxm_Click(object sender, EventArgs e)
        {
            //必须条码生成按钮是灰度才可以生成箱条码
            if(bc.Enabled != false)
            try
            {
                MessageBox.Show("请先生成条形码,再生成箱条码");
                return;
            }
            //-------------------根据HINTERID生成箱条码
                Int64 iInterID = 0;
                Int64 dPackQty = 0; //外箱数量
                Int64 dPackLeftQty = 0; //外箱剩余数量
                Int64 dLabelQty = 0; //小箱数量
                Int64 dQty = 0; //总数量
                Int64 dEntryID = 0; //行号
                string sPackBarCode = ""; //外箱码
                string sBarCode = ""; //唯一码
                Int64 LSH = 0;
                DataSet Ds;
                string sYear = DateTime.Today.Year.ToString().Substring(2, 2);
                string sPeriod = "0" + DateTime.Today.Month.ToString();
                sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
                string sDay = "0" + DateTime.Today.Day.ToString();
                sDay = sDay.Substring(sDay.Length - 2, 2);
                //
                string sPackStr = "ZXM" + sYear + sPeriod + sDay; //外箱码 å‰ç¼€
            //生成前判断,循环物料网格,判断 æ˜¯å¦è®¾ç½®äº†åˆç†çš„ å¤–箱数量。 å¤–箱数量 å¿…须是 æœ€å°åŒ…装数的 å€æ•° å¹¶å¿…须大于0和大于等于最小包装数量。
                //必须条码生成按钮是灰度才可以生成箱条码
                if (bc.Enabled != false)
                {
                    MessageBox.Show("请先生成条形码,再生成箱条码");
                    return;
                }
                //-------------------根据HINTERID生成箱条码
                //生成前判断,循环物料网格,判断 æ˜¯å¦è®¾ç½®äº†åˆç†çš„ å¤–箱数量。 å¤–箱数量 å¿…须是 æœ€å°åŒ…装数的 å€æ•° å¹¶å¿…须大于0和大于等于最小包装数量。
                for (int i = 0; i < grdMain.Rows.Count; i++)
                {
                    if (DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HMaterIDCol].Value) != 0)
                    {
                        if (DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HPackQtyCol].Value) <= 0)
                        {
                            MessageBox.Show("请录入合理的外箱数量,第" + Convert.ToString(i + 1) + "行");
                            return;
                        }
                        if (DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HPackQtyCol].Value)
                            % DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HMinQtyCol].Value) != 0
                            || DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HPackQtyCol].Value)
                            < DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HMinQtyCol].Value))
                        {
                            MessageBox.Show("外箱数量必须是最小包装数的倍数,且大于等于最小包装数,第" + Convert.ToString(i + 1) + "行");
                            return;
                        }
                    }
                }
                //oCn.BeginTran();
                //从0行进行循环 ç‰©æ–™ç½‘格,获取外箱数量
                for (int i = 0; i < grdMain.Rows.Count; i++)
                {
                    if (DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HMaterIDCol].Value) != 0)
                    {
                        //获取总数量、外箱数量
                        dPackQty = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HPackQtyCol].Value);
                        dQty = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HQtyCol].Value);
                        dEntryID = i + 1;
                        dPackLeftQty = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HPackQtyCol].Value);
                        //生成一个外箱码
                        Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sPackStr + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号                                                                                          //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]) + 1;
                        sPackBarCode = sPackStr + LSH.ToString();
                        oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sPackStr + "'");
                        //子循环 æ¡ç ç½‘æ ¼
                        for (int j = 0; j < grdSub.Rows.Count; j++)
                        {
                            if (dEntryID == DBUtility.ClsPub.isLong(grdSub.Rows[j].Cells[HEntryID2Col].Value))
                            {
                                if (dQty <= 0)
                                {
                                    continue;
                                }
                                if (dPackLeftQty > 0) //当剩余外箱数量小于等于0时,重新生成外箱码
                                {
                                }
                                else
                                {
                                    //生成一个外箱码
                                    Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sPackStr + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号                                                                                          //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                                    LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]) + 1;
                                    sPackBarCode = sPackStr + LSH.ToString();
                                    oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sPackStr + "'");
                                    dPackLeftQty = DBUtility.ClsPub.isLong(grdMain.Rows[i].Cells[HPackQtyCol].Value);
                                }
                                sBarCode = DBUtility.ClsPub.isStrNull(grdSub.Rows[j].Cells[HTMCol].Value); // æ¡ç 
                                dLabelQty = DBUtility.ClsPub.isLong(grdSub.Rows[j].Cells[HQty2Col].Value); // å°ç®±æ•°é‡
                                oCn.RunProc("update Gy_BarCodebill set HInnerBillNo= '" + sPackBarCode + "' Where HbarCode='" + sBarCode + "'");
                                dPackLeftQty = dPackLeftQty - dLabelQty;
                                dQty = dQty - dLabelQty;
                                if (dPackLeftQty <= 0)//当箱剩余数量小于等于0时 æ‰§è¡Œ ç»„托单
                                {
                                    //获取组托单内码
                                    iInterID = DBUtility.ClsPub.CreateBillID("3783", ref DBUtility.ClsPub.sExeReturnInfo); ;//得到新单号;
                                                                                                                            //根据外箱码 å†™å…¥ ç»„托单主表,组托单子表,SUM,外箱码档案,SUM档案
                                    oCn.RunProc("exec  h_p_WMS_PackUnionBill_AddNew  '" + sPackBarCode + "'," + iInterID.ToString() + ",'" + DBUtility.ClsPub.CurUserName + "'," + HInterID.ToString()); //根据箱条码,写入 ä¸»è¡¨ï¼Œå­è¡¨ ï¼Œç®±æ¡ç æ¡£æ¡ˆ
                                    oCn.RunProc("exec  h_p_WMS_PackUnionBill_SumSubBill  " + iInterID.ToString() + ",'" + sPackBarCode + "','3783','" + DBUtility.ClsPub.CurUserName + "'," + HInterID.ToString()); //根据箱条码,写入 SUM表,SUM条码档案
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }
                }
                wxm.Enabled = false;
                //oCn.Commit();
                MessageBox.Show("生成箱码完毕!");
                //刷新数据
                Display();
            }
            catch(Exception e1)
            {
                //oCn.RollBack();
                MessageBox.Show("生成箱码失败!" + e1.Message );
            }
        }
            //从0行进行循环 ç‰©æ–™ç½‘格,获取外箱数量
            //子循环 æ¡ç ç½‘æ ¼
            //根据外箱数量 æ‰£å‡ï¼Œç›´åˆ° å¤–箱数量扣减完,生成 å¤–箱条码和组托单
            //结束循环
            //刷新打印页签(-S çš„ è™šæ‹Ÿæ¡ç ä¸æ˜¾ç¤º ï¼‰
        private void cmbSourceBillType_TextChanged(object sender, EventArgs e)
        {
            if (cmbSourceBillType.Text == "工序流转卡")
            {
                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;
            }
        }
    }
}