chenhaozhe
2025-10-26 1948124877478db58b27841f9398aed97ef13053
WarM/ÌõÂë´òÓ¡/Gy_CusBarCodeBill_KaiBei_LangChao.cs
@@ -8,6 +8,7 @@
using gregn6Lib;
using Pub_Class;
using System.Threading;
using System.Globalization;
namespace WarM
{
@@ -64,9 +65,10 @@
        public const Int16 HEXPPERIODCol = 43;
        public const Int16 HLSHCol = 44;
        public const Int16 HBaNoCol = 45;
        public const Int16 HCusModelCol = 46;
        //
        public  string ModName = "85";
        public  string ModCaption = "浪潮客户标签生成";
        public  string ModCaption = "浪潮、元脑、顺达客户标签生成";
        public const string ModRightName = "Gy_CusBarCodeBill_KaiBei_LangChao";
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
@@ -78,13 +80,15 @@
        public int selectRow = 0;
        public Int64 HInterID = 0;      //内码
        public Int64 HOrgID = ClsPub.HOrgID;
        public string HCusModel = "Z";     //厂商代码
        public string HCS = "Z";           //厂商代码
        public string sDate = "";          //日期
        public string sYear = "";          //年(2位)
        public string sYear4 = "";         //年(4位)
        public string sPeriod = "";        //月
        public string sPeriod2 = "";       //月(正常)
        public string sDay = "";           //日
        public string sWeek = "";          //周
        public string sYearWeek = "";      //年(2位)周(2位)
        #region å›ºå®šä»£ç 
@@ -460,6 +464,12 @@
            sPeriod2 = sPeriod.Substring(sPeriod.Length - 2, 2);
            sDay = "0" + ClsPub.isDate(sDate).Day.ToString();
            sDay = sDay.Substring(sDay.Length - 2, 2);
            //获取周
            GregorianCalendar calendar = new GregorianCalendar();
            int weekNumber = calendar.GetWeekOfYear(dtpHDate.Value, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
            sWeek = "0" + weekNumber.ToString();
            sWeek = sWeek.Substring(sWeek.Length - 2, 2);
            sYearWeek = sYear + sWeek;
            //==================================
            switch (sYear)
            {
@@ -571,9 +581,9 @@
                string HCode2 = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode2Col].Value);                 // æ‰¹æ¬¡ä½
                HCode2 = HCode2.ToUpper();
                string HCode3 = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode3Col].Value);                 // ç‰ˆæœ¬å·
                string HBatchNoNumber = HCode1 + sYear + sPeriod + sDay + HCusModel;                                // æ‰¹æ¬¡ç”Ÿæˆå‰ç¼€
                string HBatchNoNumber = HCode1 + sYear + sPeriod + sDay + HCS;                                      // æ‰¹æ¬¡ç”Ÿæˆå‰ç¼€
                HBatchNoNumber = HBatchNoNumber.ToUpper();
                string HBarCodeType = "";                                                                           // æ¡ç ç±»åž‹
                string HBarCodeType = cmbHCusName.Text;                                                             // æ¡ç ç±»åž‹
                string HInnerBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HInnerBillNoCol].Value);     // å®¢æˆ·è®¢å•号
                if (HMaterID != 0)
@@ -654,6 +664,7 @@
            {
                string TM = "";             //条码
                int LSHlen = 4;             //流水号长度
                int LWSHlen = 5;            //外箱流水号长度
                double HSumQty = 0;         //产品数量
                double HMinQty = 0;         //内箱最小包装数
                int HBQty = 0;              //内箱数
@@ -678,6 +689,7 @@
                double HQty = 0;            //数量
                Int64 HCusID = 0;           //客户ID
                string HCusModelName = "";  //客户料号
                string HCusModel = "";      //客户物料名称
                bool HGiveAwayFlag = false; //赠品标记
                string HProduceDate;        //生产日期(保质期用)
                string HExpiryDate;         //保质期至(保质期用)
@@ -721,7 +733,7 @@
                        string sHCode1 = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode1Col].Value);                 // ç‰©æ–™ç±»åˆ«
                        string sHCode2 = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode2Col].Value);                 // æ‰¹æ¬¡ä½
                        sHCode2 = sHCode2.ToUpper();
                        string HBatchNoNumber = sHCode1 + sYear + sPeriod + sDay + HCusModel;                                // æ‰¹æ¬¡ç”Ÿæˆå‰ç¼€
                        string HBatchNoNumber = sHCode1 + sYear + sPeriod + sDay + HCS;                                      // æ‰¹æ¬¡ç”Ÿæˆå‰ç¼€
                        HBatchNoNumber = HBatchNoNumber.ToUpper();
                        DataSet oDsBatchNo = oCn.RunProcReturn("exec h_p_Gy_CusBarCodeBill_KaiBeiLC_GetBatchNo '" + sHSourceBillNo + "'," + sHMaterID.ToString() + ",'" + sHMaterNumber + "','" + sHCusModelName + "','" + sHCode2 + "','" + HBatchNoNumber + "'", "h_p_Gy_CusBarCodeBill_KaiBeiLC_GetBatchNo");
@@ -784,13 +796,25 @@
                            HEntryID = j + 1;
                            HBarCode = TM.ToUpper();
                            HBarCodeType = "内箱码";
                            if(cmbHCusName.Text.Contains("元脑"))
                            {
                                HBarCodeType = "元脑内箱码";
                            }
                            else if (cmbHCusName.Text.Contains("顺达"))
                            {
                                HBarCodeType = "顺达内箱码";
                            }
                            else
                            {
                                HBarCodeType = "内箱码";
                            }
                            HMaterID = ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value);
                            HUnitID = ClsPub.isLong(grdMain.Rows[j].Cells[HUnitIDCol].Value);
                            HAuxPropID = ClsPub.isLong(grdMain.Rows[j].Cells[HAuxPropIDCol].Value);
                            HQty = HMinQty;
                            HCusID = ClsPub.isLong(cmbHCusName.SelectedValue);
                            HCusModelName = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCusModelNameCol].Value);
                            HCusModel = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCusModelCol].Value);
                            HGiveAwayFlag = ClsPub.isBool(grdMain.Rows[j].Cells[HGiveAwayFlagCol].Value);
                            HISKFPERIOD = ClsPub.isBool(grdMain.Rows[j].Cells[HISKFPERIODCol].Value);
                            HProduceDate = ClsPub.isStrNull(grdMain.Rows[j].Cells[HProduceDateCol].Value);
@@ -808,12 +832,12 @@
                            HCode2 = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode2Col].Value).ToUpper();
                            HCode3 = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode3Col].Value).ToUpper();
                            HSno = LSH;
                            HBoxNo = HCode1 + sYear + sPeriod + sDay + HCusModel;
                            HBoxNo = HCode1 + sYear + sPeriod + sDay + HCS;
                            HBoxNo = HBoxNo.ToUpper();
                            sHBaNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HBaNoCol].Value);                        // ç•Œé¢ä¸Šè¾“入的批次位
                            //客户料号HCusModelName、物料类别HCode1、批次位HCode2、版本号HCode3、批次序列号HSno、批次生成前缀HBoxNo、厂商代码HCusModel
                            //界面上输入的批次位HSupName、36进制批次序列号HSupNumber、客户订单号HInnerBillNo
                            //客户料号HCusModelName、物料类别HCode1、批次位HCode2、版本号HCode3、批次序列号HSno、批次生成前缀HBoxNo、客户物料名称HCusModel
                            //界面上输入的批次位HSupName、36进制批次序列号HSupNumber、客户订单号HInnerBillNo、年周HWorkLineName
                            oCn.RunProc("insert into Gy_BarCodeBill_Cus" +
                                    "(HInterID,HEntryID,HBillType,HBarCode,HBarCodeType" +
                                    ",HMaterID,HUnitID,HAuxPropID,HBatchNo,HQty" +
@@ -835,7 +859,7 @@
                                    + "," + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + ",1,0"
                                    + "," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "'"
                                    + ",0,'','" + HRemark + "'," + HOrgID.ToString() + "," + HOrgID.ToString()
                                    + ",'" + ClsPub.CurUserName + "',getdate(),'','','" + HMTONo + "'"
                                    + ",'" + ClsPub.CurUserName + "',getdate(),'','" + sYearWeek + "','" + HMTONo + "'"
                                    + ",0,'','','" + HInnerBillNo + "'"
                                    + ",'','','" + LSH2 + "','" + sHBaNo + "','" + HCode1 + "'"
                                    + ",'" + HCode2 + "','" + HCode3 + "',''," + HSno.ToString() + ",'" + HBoxNo + "')");
@@ -852,11 +876,36 @@
                    {
                        HBatchNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBatchNoCol].Value);
                        HCode3 = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode3Col].Value);
                        //获取最大流水号
                        //条码前缀 = ä¾›åº”商代码 + å¹´ + æœˆ + æ—¥
                        sTMNumber = HCusModel + sYear4 + sPeriod2 + sDay;
                        Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                        LWSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        if (cmbHCusName.Text.Contains("元脑"))
                        {
                            LWSHlen = 5;
                            HBarCodeType = "元脑外箱码";
                            //获取最大流水号
                            //条码前缀 = 'CA'+年周
                            sTMNumber = "CA" + sYearWeek;
                            Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                            LWSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        }
                        else if (cmbHCusName.Text.Contains("顺达"))
                        {
                            LWSHlen = 6;
                            HBarCodeType = "顺达外箱码";
                            //获取最大流水号
                            //条码前缀 = 'B103288'+年周
                            sTMNumber = "B103288" + sYearWeek;
                            Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                            LWSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        }
                        else
                        {
                            LWSHlen = 5;
                            HBarCodeType = "外箱码";
                            //获取最大流水号
                            //条码前缀 = ä¾›åº”商代码 + å¹´ + æœˆ + æ—¥
                            sTMNumber = HCS + sYear4 + sPeriod2 + sDay;
                            Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                            LWSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                        }
                        HWBQty = ClsPub.isInt(grdMain.Rows[j].Cells[HWBQtyCol].Value);
                        HWMinQty = ClsPub.isDoule(grdMain.Rows[j].Cells[HWMinQtyCol].Value);
@@ -876,7 +925,7 @@
                            //
                            LWSH = LWSH + 1;
                            LSH2 = LWSH.ToString();
                            while (LSH2.Length < 5)  //如果流水号位数小于 5 å‰é¢è¡¥0
                            while (LSH2.Length < LWSHlen)  //如果外箱流水号位数小于 å¤–箱流水号长度 å‰é¢è¡¥0
                            {
                                LSH2 = "0" + LSH2;
                            }
@@ -884,13 +933,13 @@
                            HEntryID = j + 1;
                            HBarCode = TM.ToUpper();
                            HBarCodeType = "外箱码";
                            HMaterID = ClsPub.isLong(grdMain.Rows[j].Cells[HMaterIDCol].Value);
                            HUnitID = ClsPub.isLong(grdMain.Rows[j].Cells[HUnitIDCol].Value);
                            HAuxPropID = ClsPub.isLong(grdMain.Rows[j].Cells[HAuxPropIDCol].Value);
                            HQty = HWMinQty;
                            HCusID = ClsPub.isLong(cmbHCusName.SelectedValue);
                            HCusModelName = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCusModelNameCol].Value);
                            HCusModel = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCusModelCol].Value);
                            HGiveAwayFlag = ClsPub.isBool(grdMain.Rows[j].Cells[HGiveAwayFlagCol].Value);
                            HISKFPERIOD = ClsPub.isBool(grdMain.Rows[j].Cells[HISKFPERIODCol].Value);
                            HProduceDate = ClsPub.isStrNull(grdMain.Rows[j].Cells[HProduceDateCol].Value);
@@ -908,12 +957,12 @@
                            HCode2 = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode2Col].Value).ToUpper();
                            HCode3 = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode3Col].Value).ToUpper();
                            HSno = 0;
                            HBoxNo = HCode1 + sYear + sPeriod + sDay + HCusModel;
                            HBoxNo = HCode1 + sYear + sPeriod + sDay + HCS;
                            HBoxNo = HBoxNo.ToUpper();
                            sHBaNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HBaNoCol].Value);                        // ç•Œé¢ä¸Šè¾“入的批次位
                            //客户料号HCusModelName、物料类别HCode1、批次位HCode2、版本号HCode3、批次序列号HSno、批次生成前缀HBoxNo、厂商代码HCusModel
                            //界面上输入的批次位HSupName、36进制批次序列号HSupNumber、客户订单号HInnerBillNo
                            //客户料号HCusModelName、物料类别HCode1、批次位HCode2、版本号HCode3、批次序列号HSno、批次生成前缀HBoxNo、客户物料名称HCusModel
                            //界面上输入的批次位HSupName、36进制批次序列号HSupNumber、客户订单号HInnerBillNo、年周HWorkLineName
                            oCn.RunProc("insert into Gy_BarCodeBill_Cus" +
                                    "(HInterID,HEntryID,HBillType,HBarCode,HBarCodeType" +
                                    ",HMaterID,HUnitID,HAuxPropID,HBatchNo,HQty" +
@@ -935,7 +984,7 @@
                                    + "," + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + ",1,0"
                                    + "," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "'"
                                    + ",0,'','" + HRemark + "'," + HOrgID.ToString() + "," + HOrgID.ToString()
                                    + ",'" + ClsPub.CurUserName + "',getdate(),'','','" + HMTONo + "'"
                                    + ",'" + ClsPub.CurUserName + "',getdate(),'','" + sYearWeek + "','" + HMTONo + "'"
                                    + ",0,'','','" + HInnerBillNo + "'"
                                    + ",'','','" + LSH2 + "','" + sHBaNo + "','" + HCode1 + "'"
                                    + ",'" + HCode2 + "','" + HCode3 + "',''," + HSno.ToString() + ",'" + HBoxNo + "')");
@@ -965,7 +1014,7 @@
        private void Display()
        {
            //刷新内箱码列表
            DataSet DSet = oCn.RunProcReturn("select * from h_v_Gy_BarCodeBill_CusList where HInterID=" + HInterID.ToString() + " and æ¡ç ç±»åž‹='内箱码' order by HItemID", "h_v_Gy_BarCodeBill_CusList", ref DBUtility.ClsPub.sExeReturnInfo);
            DataSet DSet = oCn.RunProcReturn("select * from h_v_Gy_BarCodeBill_CusList where HInterID=" + HInterID.ToString() + " and (条码类型='内箱码' or æ¡ç ç±»åž‹='元脑内箱码' or æ¡ç ç±»åž‹='顺达内箱码') order by HItemID", "h_v_Gy_BarCodeBill_CusList", ref DBUtility.ClsPub.sExeReturnInfo);
            //生成首行标题
            if (DSet == null)
            {
@@ -976,7 +1025,7 @@
            grdSub.DataSource = DSet.Tables[0].DefaultView;
            //刷新外箱码列表
            DataSet DWSet = oCn.RunProcReturn("select * from h_v_Gy_BarCodeBill_CusList where HInterID=" + HInterID.ToString() + " and æ¡ç ç±»åž‹='外箱码' order by HItemID", "h_v_Gy_BarCodeBill_CusList", ref DBUtility.ClsPub.sExeReturnInfo);
            DataSet DWSet = oCn.RunProcReturn("select * from h_v_Gy_BarCodeBill_CusList where HInterID=" + HInterID.ToString() + " and (条码类型='外箱码' or æ¡ç ç±»åž‹='元脑外箱码' or æ¡ç ç±»åž‹='顺达外箱码') order by HItemID", "h_v_Gy_BarCodeBill_CusList", ref DBUtility.ClsPub.sExeReturnInfo);
            //生成首行标题
            if (DWSet == null)
            {
@@ -1036,7 +1085,7 @@
        private void initGrid()
        {
            grdMain.RowCount = 0;
            grdMain.ColumnCount = 46;                       //总列数
            grdMain.ColumnCount = 47;                       //总列数
            DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name);
            grdMain.Columns[HSnoCol].HeaderText = "序号";
            grdMain.Columns[HMainIDCol].HeaderText = "源单主ID";
@@ -1048,6 +1097,7 @@
            grdMain.Columns[HMaterNameCol].HeaderText = "物料名称";
            grdMain.Columns[HMaterModelCol].HeaderText = "规格型号";
            grdMain.Columns[HCusModelNameCol].HeaderText = "客户料号";
            grdMain.Columns[HCusModelCol].HeaderText = "客户物料名称";
            grdMain.Columns[HUnitIDCol].HeaderText = "计量单位ID";
            grdMain.Columns[HUnitNumberCol].HeaderText = "计量单位代码";
            grdMain.Columns[HUnitNameCol].HeaderText = "计量单位名称";
@@ -1115,6 +1165,8 @@
                                //"," + HMaterNumberCol.ToString() +
                                "," + HAuxPropNumberCol.ToString() +
                                "," + HUnitNumberCol.ToString() +
                                "," + HCusModelNameCol.ToString() +
                                "," + HCusModelCol.ToString() +
                                //"," + HCode1Col.ToString() +
                                //"," + HCode2Col.ToString() +
                                //"," + HCode3Col.ToString() +
@@ -1544,6 +1596,8 @@
                                "," + HMinQtyCol.ToString() +
                                "," + HWMinQtyCol.ToString() +
                                "," + HAuxPropNumberCol.ToString() +
                                "," + HCusModelNameCol.ToString() +
                                "," + HCusModelCol.ToString() +
                                //"," + HCode1Col.ToString() +
                                //"," + HCode2Col.ToString() +
                                //"," + HCode3Col.ToString() +
@@ -1863,11 +1917,23 @@
                    DataSet ds = oCn.RunProcReturn("exec h_p_Gy_CusBarCodeBill_CusMatNo " + num.ToString() + "," + HCusID.ToString() + "," + HMaterID.ToString(), "h_p_Gy_CusBarCodeBill_CusMatNo");
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        grdMain.Rows[j].Cells[HCusModelNameCol].Value = "";
                        //网格下拉选择框
                        DataGridViewComboBoxCell column = new DataGridViewComboBoxCell();
                        column.Items.Add("");
                        grdMain.Rows[j].Cells[HCusModelNameCol] = column;
                        grdMain.Rows[j].Cells[HCusModelCol].Value = "";
                    }
                    else
                    {
                        //网格下拉选择框
                        DataGridViewComboBoxCell column = new DataGridViewComboBoxCell();
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                        {
                            column.Items.Add(DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HCusRelationNumber"]));
                        }
                        grdMain.Rows[j].Cells[HCusModelNameCol] = column;
                        grdMain.Rows[j].Cells[HCusModelNameCol].Value = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HCusRelationNumber"]);
                        grdMain.Rows[j].Cells[HCusModelCol].Value = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HCusRelationName"]);
                        if (num == 2)
                        {
                            grdMain.Rows[j].Cells[HCode1Col].Value = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HCode1"]);