yusijie
2024-08-07 36e2fbb6b4523b6dbbbab6dace3d5e05d49ca4e1
WarM/ÌõÂë´òÓ¡/Gy_CusBarCodeBill_KaiBei.cs
@@ -41,26 +41,27 @@
        public const Int16 HCode1Col = 20;
        public const Int16 HCode2Col = 21;
        public const Int16 HCode3Col = 22;
        public const Int16 HQtyCol = 23;
        public const Int16 HMinQtyCol = 24;
        public const Int16 HBQtyCol = 25;
        public const Int16 HProduceDateCol = 26;
        public const Int16 HExpiryDateCol = 27;
        public const Int16 HCusIDCol = 28;
        public const Int16 HCusNumberCol = 29;
        public const Int16 HCusNameCol = 30;
        public const Int16 HSourceInterIDCol = 31;
        public const Int16 HSourceEntryIDCol = 32;
        public const Int16 HSourceBillNoCol = 33;
        public const Int16 HSourceBillTypeCol = 34;
        public const Int16 HRemarkCol = 35;
        public const Int16 HInitQtyCol = 36;
        public const Int16 HMTONoCol = 37;
        public const Int16 HISKFPERIODCol = 38;
        public const Int16 HEXPUNITCol = 39;
        public const Int16 HEXPPERIODCol = 40;
        public const Int16 HLSHCol = 41;
        public const Int16 HBaNoCol = 42;
        public const Int16 HInnerBillNoCol = 23;
        public const Int16 HQtyCol = 24;
        public const Int16 HMinQtyCol = 25;
        public const Int16 HBQtyCol = 26;
        public const Int16 HProduceDateCol = 27;
        public const Int16 HExpiryDateCol = 28;
        public const Int16 HCusIDCol = 29;
        public const Int16 HCusNumberCol = 30;
        public const Int16 HCusNameCol = 31;
        public const Int16 HSourceInterIDCol = 32;
        public const Int16 HSourceEntryIDCol = 33;
        public const Int16 HSourceBillNoCol = 34;
        public const Int16 HSourceBillTypeCol = 35;
        public const Int16 HRemarkCol = 36;
        public const Int16 HInitQtyCol = 37;
        public const Int16 HMTONoCol = 38;
        public const Int16 HISKFPERIODCol = 39;
        public const Int16 HEXPUNITCol = 40;
        public const Int16 HEXPPERIODCol = 41;
        public const Int16 HLSHCol = 42;
        public const Int16 HBaNoCol = 43;
        //
        public  string ModName = "85";
        public  string ModCaption = "客户标签生成";
@@ -74,8 +75,7 @@
        public bool grdStatus;
        public int selectRow = 0;
        public Int64 HInterID = 0;      //内码
        public Int64 HOrgID = -1;
        public string HOrgNumber = "";
        public Int64 HOrgID = ClsPub.HOrgID;
        public string HCusModel = "Z";     //厂商代码
        public string sDate = "";          //日期
        public string sYear = "";          //å¹´
@@ -95,15 +95,15 @@
            cmbHBarCodeType.Items.Add("外箱码");
            //源单类型
            cmbSourceBillType.Items.Add("生产汇报单");
            //
            DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
            //获取组织
            //获取当前组织
            DataSet Ds1 = oCn.RunProcReturn("select * from Xt_ORGANIZATIONS with(nolock) where HItemID=" + ClsPub.HOrgID, "Xt_ORGANIZATIONS", ref DBUtility.ClsPub.sExeReturnInfo);
            if (Ds1.Tables[0].Rows.Count != 0)
            {
                cmbHOrgID.Text = DBUtility.ClsPub.isStrNull(Ds1.Tables[0].Rows[0]["HName"]);
            }
            //
            txtHMaker.Text = ClsPub.CurUserName;
            txtHMakeDate.Text = "";
            txtHChecker.Text = "";
@@ -255,22 +255,25 @@
                MessageBox.Show("获取组织失败");
                return;
            }
            cmbHOrgID.DataSource = null;
            cmbHOrgID.Items.Clear();
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                cmbHOrgID.Items.Add(DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HName"]));
            }
            cmbHOrgID.DataSource = ds.Tables[0];
            cmbHOrgID.DisplayMember = "HName";
            cmbHOrgID.ValueMember = "HItemID";
        }
        //加载客户信息
        private void Sub_AddHCusNameList()
        {
            DataSet ds = oCn.RunProcReturn("exec h_p_Gy_CusBarCodeBill_Cus ", "h_p_Gy_CusBarCodeBill_Cus");
            DataSet ds = oCn.RunProcReturn("exec h_p_Gy_CusBarCodeBill_Cus " + HOrgID.ToString(), "h_p_Gy_CusBarCodeBill_Cus");
            if (ds == null || ds.Tables[0].Rows.Count == 0)
            {
                cmbHCusName.DataSource = null;
                cmbHCusName.Items.Clear();
                MessageBox.Show("获取客户信息失败");
                return;
            }
            cmbHCusName.DataSource = null;
            cmbHCusName.Items.Clear();
            cmbHCusName.DataSource = ds.Tables[0];
            cmbHCusName.DisplayMember = "HName";
@@ -412,19 +415,7 @@
        {
            //获取内码
            HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
            //获取组织信息
            DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
            HOrgNumber = "";
            if (oClsGy_ORGANIZATIONS_View.GetInfoByName(cmbHOrgID.Text))
            {
                HOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
                HOrgNumber = DBUtility.ClsPub.isStrNull(oClsGy_ORGANIZATIONS_View.omodel.HNumber);
            }
            if (HOrgID == -1)
            {
                MessageBox.Show("选择组织有错误!");
                return false;
            }
            lblCaption.Focus();
            //生成条码前控制
            if (!Sub_AllowSave())
@@ -575,10 +566,12 @@
                string HCode3 = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode3Col].Value);                 // ç‰ˆæœ¬å·
                string HBatchNoNumber = HCode1 + sYear + sPeriod + sDay + HCusModel;                                // æ‰¹æ¬¡ç”Ÿæˆå‰ç¼€
                HBatchNoNumber = HBatchNoNumber.ToUpper();
                string HBarCodeType = DBUtility.ClsPub.isStrNull(cmbHBarCodeType.Text);                             // æ¡ç ç±»åž‹
                string HInnerBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HInnerBillNoCol].Value);     // å®¢æˆ·è®¢å•号
                if (HMaterID != 0)
                {
                    DataSet oDsCheck = oCn.RunProcReturn("exec h_p_Gy_CusBarCodeBill_AddCheck " + HSno.ToString() + ",'" + HSourceBillNo + "'," + HMaterID.ToString() + "," + HSourceQty.ToString() + "," + HQty.ToString() + "," + HMinQty.ToString() + ",'" + HCusModelName + "','" + HCode1 + "','" + HCode2 + "','" + HCode3 + "','" + HBatchNoNumber + "'", "h_p_Gy_CusBarCodeBill_AddCheck");
                    DataSet oDsCheck = oCn.RunProcReturn("exec h_p_Gy_CusBarCodeBill_AddCheck " + HSno.ToString() + ",'" + HSourceBillNo + "'," + HMaterID.ToString() + "," + HSourceQty.ToString() + "," + HQty.ToString() + "," + HMinQty.ToString() + ",'" + HCusModelName + "','" + HCode1 + "','" + HCode2 + "','" + HCode3 + "','" + HBatchNoNumber + "','" + HBarCodeType + "','" + HInnerBillNo + "'", "h_p_Gy_CusBarCodeBill_AddCheck");
                    //
                    if (oDsCheck == null && oDsCheck.Tables[0].Rows.Count == 0)
                    {
@@ -685,6 +678,7 @@
                string HSourceBillType = "";//源单类型
                string HMTONo = "";         //MTO号
                string HRemark = "";        //备注
                string HInnerBillNo = "";   //客户订单号
                string HSno = "";           //批次序列号
                string HBoxNo = "";         //批次生成前缀
                string sHBaNo = "";         //界面上输入的批次位
@@ -768,15 +762,17 @@
                            HSourceBillType = ClsPub.isStrNull(grdMain.Rows[j].Cells[HSourceBillTypeCol].Value);
                            HRemark = ClsPub.isStrNull(grdMain.Rows[j].Cells[HRemarkCol].Value);
                            HMTONo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HMTONoCol].Value);
                            HInnerBillNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HInnerBillNoCol].Value);
                            HCode1 = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode1Col].Value).ToUpper();
                            HCode2 = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode2Col].Value).ToUpper();
                            HCode3 = ClsPub.isStrNull(grdMain.Rows[j].Cells[HCode3Col].Value).ToUpper();
                            HSno = ClsPub.isStrNull(LSH);
                            HBoxNo = HCode1 + sYear + sPeriod + sDay + HCusModel;
                            HBoxNo = HBoxNo.ToUpper();
                            sHBaNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[HBaNoCol].Value);                        // ç•Œé¢ä¸Šè¾“入的批次位
                            sHBaNo = ClsPub.isStrNull(grdMain.Rows[j].Cells[HBaNoCol].Value);                        // ç•Œé¢ä¸Šè¾“入的批次位
                            //客户料号HCusModelName、物料类别HCode1、批次位HCode2、版本号HCode3、批次序列号HSno、批次生成前缀HBoxNo、厂商代码HCusModel、界面上输入的批次位HSupName、36进制批次序列号HSupNumber
                            //客户料号HCusModelName、物料类别HCode1、批次位HCode2、版本号HCode3、批次序列号HSno、批次生成前缀HBoxNo、厂商代码HCusModel
                            //界面上输入的批次位HSupName、36进制批次序列号HSupNumber、客户订单号HInnerBillNo
                            oCn.RunProc("insert into Gy_BarCodeBill_Cus" +
                                    "(HInterID,HEntryID,HBillType,HBarCode,HBarCodeType" +
                                    ",HMaterID,HUnitID,HAuxPropID,HBatchNo,HQty" +
@@ -799,7 +795,7 @@
                                    + "," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "'"
                                    + ",0,'','" + HRemark + "'," + HOrgID.ToString() + "," + HOrgID.ToString()
                                    + ",'" + ClsPub.CurUserName + "',getdate(),'','','" + HMTONo + "'"
                                    + ",0,'','',''"
                                    + ",0,'','','" + HInnerBillNo + "'"
                                    + ",'','','" + LSH2 + "','" + sHBaNo + "','" + HCode1 + "'"
                                    + ",'" + HCode2 + "','" + HCode3 + "','','" + HSno + "','" + HBoxNo + "')");
                            n = n + 1;
@@ -878,7 +874,7 @@
        private void initGrid()
        {
            grdMain.RowCount = 0;
            grdMain.ColumnCount = 43;                       //总列数
            grdMain.ColumnCount = 44;                       //总列数
            DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name);
            grdMain.Columns[HSnoCol].HeaderText = "序号";
            grdMain.Columns[HMainIDCol].HeaderText = "源单主ID";
@@ -915,6 +911,7 @@
            grdMain.Columns[HCode1Col].HeaderText = "物料类别";
            grdMain.Columns[HCode2Col].HeaderText = "批次位";
            grdMain.Columns[HCode3Col].HeaderText = "版本号";
            grdMain.Columns[HInnerBillNoCol].HeaderText = "客户订单号";
            //格式化   éšè—åˆ—
            grdMain.Columns[HTagCol].Visible = false;
@@ -956,6 +953,7 @@
                                "," + HCode1Col.ToString() +
                                //"," + HCode2Col.ToString() +
                                "," + HCode3Col.ToString() +
                                "," + HInnerBillNoCol.ToString() +
                                "," + HRemarkCol.ToString();
            //设置合计列
@@ -1030,19 +1028,7 @@
        //帮助函数
        private void Sub_GridKey(int sKeyCode, int sRow, int sCol, DataGridViewTextBoxEditingControl oEdit)
        {
            long sHOrgID = -1;
            string sWhere = "";
            DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
            if (oClsGy_ORGANIZATIONS_View.GetInfoByName(cmbHOrgID.Text))
            {
                sHOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
            }
            if (sHOrgID == -1)
            {
                MessageBox.Show("选择组织有错误!");
                return;
            }
            DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View();//物料
            DAL.ClsIF_Unit_View oUnit = new DAL.ClsIF_Unit_View();//计量单位
            DAL.ClsIF_Property_View oProperty = new DAL.ClsIF_Property_View();//辅助属性
@@ -1060,7 +1046,7 @@
                        {
                            case HMaterNumberCol:
                                oMater.WherePart = "";
                                sWhere = " and HUSEORGID = " + sHOrgID;
                                sWhere = " and HUSEORGID = " + HOrgID;
                                if (oMater.RefreshViewForBig(sWhere))
                                {
                                    if (oMater.GetInfoByID(oMater.oModel.HItemID))
@@ -1272,17 +1258,6 @@
        private void cmdSourceBillNo_Click(object sender, EventArgs e)
        {
            DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
            if (oClsGy_ORGANIZATIONS_View.GetInfoByName(cmbHOrgID.Text))
            {
                HOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
            }
            if (HOrgID == -1)
            {
                MessageBox.Show("选择组织有错误!");
                return;
            }
            if (cmbSourceBillType.Text.Trim() == "生产汇报单")
            {
                string sWhere = " and HOrgID =" + HOrgID.ToString();
@@ -1365,6 +1340,7 @@
                                "," + HCode1Col.ToString() +
                                //"," + HCode2Col.ToString() +
                                "," + HCode3Col.ToString() +
                                "," + HInnerBillNoCol.ToString() +
                                "," + HRemarkCol.ToString();
            grdMain.Columns[HBillNoCol].ReadOnly = true;
            //设置合计列
@@ -1385,13 +1361,6 @@
        {
            if (e.KeyChar == (char)Keys.Return)//回车带出源单信息
            {
                long sHOrgID = -1;
                DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
                if (oClsGy_ORGANIZATIONS_View.GetInfoByName(cmbHOrgID.Text))
                {
                    sHOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
                }
                if (txtHSourceBillNo.Text.Length < 4)
                {
                    MessageBox.Show("请输入4位以上数据!");
@@ -1401,7 +1370,7 @@
                if (cmbSourceBillType.Text.Trim() == "生产汇报单")
                {
                    DAL.Cls_S_IF_ICMOReportBillList_CusBarCodeBill oIF_ICMOReportBillList = new DAL.Cls_S_IF_ICMOReportBillList_CusBarCodeBill();
                    if (oIF_ICMOReportBillList.RefreshBySourceBillNo(" Where å•据号 like '%" + txtHSourceBillNo.Text + "' "))  //选择原单
                    if (oIF_ICMOReportBillList.RefreshBySourceBillNo(" Where å•据号 like '%" + txtHSourceBillNo.Text + "' and HOrgID =" + HOrgID.ToString()))  //选择原单
                    {
                        FillSelectData(oIF_ICMOReportBillList.oBillSelectColl);
                        txtHSourceBillNo.Text = "";
@@ -1582,7 +1551,18 @@
        #endregion
        #region é€‰æ‹©ç»„织
        private void cmbHOrgID_SelectionChangeCommitted(object sender, EventArgs e)
        {
            HOrgID = ClsPub.isLong(cmbHOrgID.SelectedValue);
            //加载客户信息
            Sub_AddHCusNameList();
            //清空初始化列表
            initGrid();
            grdMain.Columns[HBillNoCol].ReadOnly = false;
        }
        #endregion