SCM/Gy_BarCodeBill_Cus.cs
@@ -23,45 +23,51 @@
        public const Int16 HMainIDCol = 2;
        public const Int16 HSubIDCol = 3;
        public const Int16 HBillNoCol = 4;
        public const Int16 HBillTypeCol = 5;
        public const Int16 HMaterIDCol = 5;
        public const Int16 HCusModelCol = 6;
        public const Int16 HCode1Col = 7;
        public const Int16 HSupNumberCol = 8;
        public const Int16 HCode2Col = 9;
        public const Int16 HWorkLineNameCol = 10;
        public const Int16 HBarCodeDateCol = 11;
        public const Int16 HCode3Col = 12;
        public const Int16 HBackDataFlagCol = 13;
        public const Int16 HQtyCol = 14;
        public const Int16 HMinQtyCol = 15;
        public const Int16 HBQtyCol = 16;
        public const Int16 HDateCol = 17;
        public const Int16 HSourceInterIDCol = 18;
        public const Int16 HSourceEntryIDCol = 19;
        public const Int16 HSourceBillNoCol = 20;
        public const Int16 HSourceBillTypeCol = 21;
        public const Int16 HinitQtyCol = 22;
        public const Int16 HRemarkCol = 23;
        public const Int16 HCusModelNameCol = 7;
        public const Int16 HCode1Col = 8;
        public const Int16 HSupNumberCol = 9;
        public const Int16 HSupNameCol = 10;
        public const Int16 HCode2Col = 11;
        public const Int16 HWorkLineNameCol = 12;
        public const Int16 HBarCodeDateCol = 13;
        public const Int16 HCode3Col = 14;
        public const Int16 HBackDataFlagCol = 15;
        public const Int16 HQtyCol = 16;
        public const Int16 HMinQtyCol = 17;
        public const Int16 HBQtyCol = 18;
        public const Int16 HDateCol = 19;
        public const Int16 HinitQtyCol = 20;
        public const Int16 HRemarkCol = 21;
        public const Int16 HBillTypeCol = 22;
        public const Int16 HLSSnoCol = 23;
        public const Int16 HBoxNoCol = 24;
        public Int16 HSelectCol = 0;
        public Int16 HSno2Col = 1;
        public Int16 HTMCol = 2;
        public Int16 HBarCodeType2Col = 3;
        public Int16 HMaterID2Col = 3;
        public Int16 HCusModel2Col = 4;
        public Int16 HCode1_SecCol = 5;
        public Int16 HSupNumber2Col = 6;
        public Int16 HCode2_SecCol = 7;
        public Int16 HWorkLineName2Col = 8;
        public Int16 HBarCodeDate2Col = 9;
        public Int16 HCode3_SecCol = 10;
        public Int16 HBackDataFlag2Col = 11;
        public Int16 HQty2Col = 12;
        public Int16 HWeiCol = 13;
        public Int16 HPrintCol = 14;
        public Int16 HDate2Col = 15;
        public Int16 HBeginDate2Col = 16;
        public Int16 HEndDate2Col = 17;
        public Int16 HRemark2Col = 18;
        public Int16 HCusModelName2Col = 5;
        public Int16 HCode1_SecCol = 6;
        public Int16 HSupNumber2Col = 7;
        public Int16 HSupName2Col = 8;
        public Int16 HCode2_SecCol = 9;
        public Int16 HWorkLineName2Col = 10;
        public Int16 HBarCodeDate2Col = 11;
        public Int16 HCode3_SecCol = 12;
        public Int16 HBackDataFlag2Col = 13;
        public Int16 HQty2Col = 14;
        public Int16 HWeiCol = 15;
        public Int16 HPrintCol = 16;
        public Int16 HDate2Col = 17;
        public Int16 HBeginDate2Col = 18;
        public Int16 HEndDate2Col = 19;
        public Int16 HRemark2Col = 20;
        public Int16 HBarCodeType2Col = 21;
        public  Int16 HLSSno2Col = 22;
        public  Int16 HBoxNo2Col = 23;
        //
        public  string ModName = "85";
        public  string ModCaption = "条码生成";
@@ -343,7 +349,7 @@
            {
                this.Sub_AddBill();
            }
            DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
            //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
        }
        //窗体卸载
@@ -459,7 +465,7 @@
            bool b = false;
            for (int i = 0; i < grdMain.RowCount; i++)
            {
                if (!IsNullRow(i))
                if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HCusModelCol].Value) !="")
                {
                    b = true;
                    break;
@@ -528,13 +534,26 @@
            SaveBarCode();
            return true;
        }
        const string X34 = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
        //34进制 
        private string set_SNoBy10To34Type(int iSno)
        {
            string s34Code = "";
            s34Code = iSno.ToString();
            return s34Code;
        {
            var a = X34.Length;
            //if(iSno==35)
            //{
            //    iSno = iSno;
            //}
            string Result = "";
            while (iSno >= 34)
            {
                Result = X34[(iSno % 34) == 0 ? 0 : (iSno % 34) ] + Result;
                iSno /= 34;
            }
            if (iSno >= 0)
                Result = X34[iSno] + Result;
            return Result;
        }
        //生成条码
@@ -597,10 +616,12 @@
                        sDay = sDay.Substring(sDay.Length - 2, 2);
                        //================================== 
                            //条码前缀 = 零件号17 + 扩展位1 2 + 供应商编码7 + 扩展位2 3+ 产线1 + 年00 + 月00 + 日00 + 扩展位3 4 + 追溯标识
                        //条码前缀 = 零件号17 + 扩展位1 2 + 供应商编码7 + 扩展位2 3+ 产线1 + 年00 + 月00 + 日00 + 扩展位3 4 + 追溯标识
                        sCusModel = (sCusModel + "*****************").Substring(0, 17);
                        sSupNumber = (sSupNumber + "*******").Substring(0, 7);
                        sTMNumber = sCusModel + sCode1 + sSupNumber + sCode2 + sLineNumber  + sYear + sPeriod + sDay ;
                        sTMNumber_b =  sCode3 + sBackDataFlag;
                        Ds = oWeb.getDataSetBySQL("exec h_p_WMS_GetMaxNo  '" + sTMNumber + sTMNumber_b + "'", "h_p_WMS_GetMaxNo", ref DBUtility.ClsPub.sExeReturnInfo);//获取最大流水号
                        Ds = oWeb.getDataSetBySQL("exec h_p_WMS_GetMaxNo_Cus  '" + sTMNumber + sTMNumber_b + "'", "h_p_WMS_GetMaxNo_Cus", ref DBUtility.ClsPub.sExeReturnInfo);//获取最大流水号
                        LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
 
                        HBQty = HBQty + ClsPub.isInt(grdMain.Rows[j].Cells[HBQtyCol].Value);
@@ -655,10 +676,14 @@
                                return;
                            }
                            grdSub.Rows[i].Cells[HTMCol].Value = TM;  
                            grdSub.Rows[i].Cells[HQty2Col].Value = HMinQty;
                            grdSub.Rows[i].Cells[HQty2Col].Value = HMinQty;
                            grdSub.Rows[i].Cells[HMaterID2Col].Value = grdMain.Rows[j].Cells[HMaterIDCol].Value;
                            grdSub.Rows[i].Cells[HLSSno2Col].Value = LSH2;
                            grdSub.Rows[i].Cells[HCusModel2Col].Value = grdMain.Rows[j].Cells[HCusModelCol].Value;
                            grdSub.Rows[i].Cells[HCusModelName2Col].Value = grdMain.Rows[j].Cells[HCusModelNameCol].Value;
                            grdSub.Rows[i].Cells[HCode1_SecCol].Value = grdMain.Rows[j].Cells[HCode1Col].Value;
                            grdSub.Rows[i].Cells[HSupNumber2Col].Value = grdMain.Rows[j].Cells[HSupNumberCol].Value;
                            grdSub.Rows[i].Cells[HSupName2Col].Value = grdMain.Rows[j].Cells[HSupNameCol].Value;
                            grdSub.Rows[i].Cells[HCode2_SecCol].Value = grdMain.Rows[j].Cells[HCode2Col].Value;
                            grdSub.Rows[i].Cells[HWorkLineName2Col].Value = grdMain.Rows[j].Cells[HWorkLineNameCol].Value;
                            grdSub.Rows[i].Cells[HCode3_SecCol].Value = grdMain.Rows[j].Cells[HCode3Col].Value;
@@ -670,9 +695,8 @@
                            grdSub.Rows[i].Cells[HDate2Col].Value = grdMain.Rows[j].Cells[HDateCol].Value;  
                            grdSub.Rows[i].Cells[HCusModel2Col].Value = grdMain.Rows[j].Cells[HCusModelCol].Value;  
                            k = k + 1;
                            n = n + 1;
                            //oWeb.getRunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'", ref DBUtility.ClsPub.sExeReturnInfo);
                            sSQLNoMul[nn] = " exec h_p_WMS_SetMaxNo '" + sTMNumber + sTMNumber_b + "' ";
                            n = n + 1;
                            sSQLNoMul[nn] = " exec h_p_WMS_SetMaxNo_Cus '" + sTMNumber + sTMNumber_b + "' ";
                            nn = nn + 1;
                        }
                        //后台批量执行语句
@@ -735,7 +759,10 @@
                string HCode2 = "";
                string HBarCodeDate = "";
                string HCode3 = "";
                string HBackDataFlag = "";
                string HBackDataFlag = "";
                string HCusModelName = "";
                string HSupName = "";
                string HLSSNO = "";
                long HCustomQty1 = 0;
                string[] sSQLMul = new string[grdSub.Rows.Count];
@@ -749,10 +776,14 @@
                    Application.DoEvents();
                    if (ClsPub.isStrNull(grdSub.Rows[i].Cells[HCusModel2Col].Value) != "")
                    {
                        HLSSNO = ClsPub.isStrNull(grdSub.Rows[i].Cells[HLSSno2Col].Value);
                        HMaterID = ClsPub.isLong(grdSub.Rows[i].Cells[HMaterID2Col].Value);
                        HCusModel = ClsPub.isStrNull(grdSub.Rows[i].Cells[HCusModel2Col].Value);
                        HCusModelName = ClsPub.isStrNull(grdSub.Rows[i].Cells[HCusModelName2Col].Value);
                        HWorkLineName = ClsPub.isStrNull(grdSub.Rows[i].Cells[HWorkLineName2Col].Value);
                        HCode1 = ClsPub.isStrNull(grdSub.Rows[i].Cells[HCode1_SecCol].Value);
                        HSupNumber = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSupNumber2Col].Value);
                        HSupName = ClsPub.isStrNull(grdSub.Rows[i].Cells[HSupName2Col].Value);
                        HCode2 = ClsPub.isStrNull(grdSub.Rows[i].Cells[HCode2Col].Value);
                        HBarCodeDate = ClsPub.isStrNull(grdSub.Rows[i].Cells[HBarCodeDate2Col].Value);
                        HCode3 = ClsPub.isStrNull(grdSub.Rows[i].Cells[HCode3_SecCol].Value);
@@ -772,18 +803,15 @@
                        sSQLMul[mm] = "insert into Gy_BarCodeBill_Cus (HBarCode,HBarCodeType,HCusModel,HWorkLineName,HQty" +
                                    ",HCode1,HSupNumber,HCode2,HMaker,HMakeDate,HPrintQty" +
                                    ",HBarCodeDate,HCode3,HBackDataFlag,HRemark " +
                                    ",HInterID " +
                                    ",HInterID,HCusModelName,HSupName,HMaterID,HSNO " +
                                    ") values ("
                                    + "'" + HBarCode + "','" + HBarCodeType + "','" + HCusModel.ToString() + "','" + HWorkLineName.ToString() + "'," + HQty2.ToString()
                                    + ",'" + HCode1 + "','" + HSupNumber.ToString() + "','" + HCode2.ToString() + "','" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() 
                                    + ", '" + HBarCodeDate.ToString() + "','" + HCode3.ToString() + "','" + HBackDataFlag + "', '" + HRemark + "'" 
                                    + "," + HInterID.ToString()  + ")";
                                    + "," + HInterID.ToString() + " ,'" + HCusModelName + "'" + " ,'" + HSupName + "'" + "," + HMaterID.ToString() + ",'" + HLSSNO + "')";
                        //oCn.RunProc("exec setLSH '" + ClsPub.GetServerDate(0) + "'");
                        mm = mm + 1;
                        Application.DoEvents();
                        ////oWeb.getRunProc("exec setLSH '" + sTMNumber + "'", ref DBUtility.ClsPub.sExeReturnInfo);
                        //sSQLMul[mm] = "exec h_p_WMS_SetMaxNo '" + sTMNumber + "'";
                        //mm = mm + 1;
                        Application.DoEvents();
                        Application.DoEvents();
                    }
                }
@@ -845,7 +873,7 @@
        {
            grdMain.RowCount = 0;
            grdSub.RowCount = 0;
            grdMain.ColumnCount = 76;                       //总列数
            grdMain.ColumnCount = 25;                       //总列数
            ClsPub1.initGridFst(grdMain, this.Name);
            grdMain.Columns[HSnoCol].HeaderText = "序号";
            grdMain.Columns[HMainIDCol].HeaderText = "源单主ID";
@@ -862,9 +890,14 @@
            grdMain.Columns[HBackDataFlagCol].HeaderText = "追溯标识";
            grdMain.Columns[HWorkLineNameCol].HeaderText = "产线";
            grdMain.Columns[HSupNumberCol].HeaderText = "供应商编码";
            grdMain.Columns[HSupNameCol].HeaderText = "供应商名称";
            grdMain.Columns[HDateCol].HeaderText = "进料日期";
            grdMain.Columns[HRemarkCol].HeaderText = "备注"; 
            grdMain.Columns[HCusModelCol].HeaderText = "客户零件号";
            grdMain.Columns[HCusModelNameCol].HeaderText = "客户零件名称";
            grdMain.Columns[HMaterIDCol].HeaderText = "物料代码";
            grdMain.Columns[HLSSnoCol].HeaderText = "流水号";
            grdMain.Columns[HBoxNoCol].HeaderText = "箱号";
            ////
            //格式化    隐藏列
            grdMain.Columns[HTagCol].Visible = false;
@@ -874,11 +907,7 @@
            //grdMain.Columns[HBatchNoCol].Visible = false; 
            //grdMain.Columns[HCusModelCol].Visible = false; 
            grdMain.Columns[HDateCol].Visible = false; 
            //grdMain.Columns[HSupNumberCol].Visible = false;
            grdMain.Columns[HSourceInterIDCol].Visible = false;
            grdMain.Columns[HSourceEntryIDCol].Visible = false;
            grdMain.Columns[HSourceBillNoCol].Visible = false;
            grdMain.Columns[HSourceBillTypeCol].Visible = false;
            //grdMain.Columns[HSupNumberCol].Visible = false;
            grdMain.Columns[HinitQtyCol].Visible = false;
@@ -888,8 +917,11 @@
            string sAllowCol;
            sAllowCol = HQtyCol.ToString() +
                            "," + HCusModelCol.ToString() +
                            "," + HMaterIDCol.ToString() +
                            "," + HCusModelNameCol.ToString() +
                            "," + HWorkLineNameCol.ToString() +
                            "," + HSupNumberCol.ToString() +
                            "," + HSupNameCol.ToString() +
                            "," + HCode1Col.ToString() +
                            "," + HCode2Col.ToString() +
                            "," + HCode3Col.ToString() +
@@ -903,7 +935,7 @@
            ClsPub1.initGridLast(sAllowCol, sTotalCol, oSumGrid);
            //----------------------------
            grdSub.ColumnCount = 74;                       //总列数
            grdSub.ColumnCount = 25;                       //总列数
            ClsPub1.initGridFst(grdSub, this.Name);
            grdSub.Columns[HSelectCol].HeaderText = "选择";
            grdSub.Columns[HCusModel2Col].HeaderText = "客户零件号";
@@ -919,12 +951,17 @@
            grdSub.Columns[HQty2Col].HeaderText = "数量";
            grdSub.Columns[HWeiCol].HeaderText = "尾数";
            grdSub.Columns[HPrintCol].HeaderText = "打印次数"; 
            grdSub.Columns[HSupNumber2Col].HeaderText = "供应商编码";
            grdSub.Columns[HSupNumber2Col].HeaderText = "供应商编码";
            grdSub.Columns[HSupName2Col].HeaderText = "供应商编码";
            grdSub.Columns[HDate2Col].HeaderText = "进料日期";
            grdSub.Columns[HRemark2Col].HeaderText = "备注"; 
            grdSub.Columns[HBeginDate2Col].HeaderText = "计划开工日期";
            grdSub.Columns[HEndDate2Col].HeaderText = "计划完工日期"; 
            grdSub.Columns[HCusModel2Col].HeaderText = "客户型号";
            grdSub.Columns[HCusModel2Col].HeaderText = "客户型号";
            grdSub.Columns[HCusModelName2Col].HeaderText = "客户型号名称";
            grdSub.Columns[HMaterID2Col].HeaderText = "物料代码";
            grdSub.Columns[HLSSno2Col].HeaderText = "流水号";
            grdSub.Columns[HBoxNo2Col].HeaderText = "箱号";
            //格式化    隐藏列
            grdSub.Columns[HBarCodeType2Col].Visible = false; 
@@ -957,7 +994,7 @@
            //    return;
            //}
            //
            DSet = oWeb.getDataSetBySQL("select * from h_v_IF_BarCodeBill_CusList Where HinterID=" + HInterID.ToString() + " order by HItemID", "h_v_IF_BarCodeBill_CusList", ref DBUtility.ClsPub.sExeReturnInfo);
            DSet = oWeb.getDataSetBySQL("exec h_p_IF_BarCodeBill_CusList " + HInterID.ToString() + "  ", "h_p_IF_BarCodeBill_CusList", ref DBUtility.ClsPub.sExeReturnInfo);
            //生成首行标题
            if (DSet == null)
            {
@@ -1073,7 +1110,7 @@
        //是否是空行
        private bool IsNullRow(int Row)
        {
            return DBUtility.Xt_BaseBillFun.IsNullRow(Row, HCusModelCol,grdMain);
            return DBUtility.Xt_BaseBillFun.IsNullRow(Row, HCusModelCol ,grdMain);
        }
        //'判断网格行的录入是否正确
        private bool CheckGridRow(int Row)
@@ -1110,6 +1147,7 @@
            }
             
            SCM.ClsIF_Supplier_View oSup = new SCM.ClsIF_Supplier_View();       //供应商
            SCM.ClsIF_Material_View oMater = new SCM.ClsIF_Material_View();       //
            if (!grdStatus)
            {
@@ -1124,8 +1162,45 @@
                        {
                             
                            case HSupNumberCol:
                            case HMaterIDCol:
                                oMater.WherePart = "";
                                sWhere = " and HUSEORGID = " + sHOrgID;
                                if (oMater.RefreshViewForBig(sWhere))
                                {
                                    grdMain.Rows[sRow].Cells[HMaterIDCol].Value = oMater.omodel.HItemID.ToString();
                                    grdMain.Rows[sRow].Cells[HMinQtyCol].Value = 1;
                                    grdMain.Rows[sRow].Cells[HCusModelNameCol].Value = oMater.omodel.HName.ToString();
                                    grdMain.Rows[sRow].Cells[HCode1Col].Value = "00";
                                    grdMain.Rows[sRow].Cells[HCode2Col].Value ="000";
                                    grdMain.Rows[sRow].Cells[HCode3Col].Value = "0000";
                                    grdMain.Rows[sRow].Cells[HSupNumberCol].Value = "VG509";
                                    grdMain.Rows[sRow].Cells[HWorkLineNameCol].Value = "1";
                                    grdMain.Rows[sRow].Cells[HBarCodeDateCol].Value = dtpHDate.Value.ToShortDateString();
                                    grdMain.Rows[sRow].Cells[HBackDataFlagCol].Value = "%";
                                    oEdit.Text = oMater.omodel.HItemID.ToString();
                                }
                                else
                                {
                                    grdMain.Rows[sRow].Cells[HMaterIDCol].Value = 0;
                                    grdMain.Rows[sRow].Cells[HMinQtyCol].Value = 0;
                                }
                                //if (CampanyName == "四维尔") //系统参数  客户定制化名称
                                //{
                                    sHMaterID = DBUtility.ClsPub.isLong(grdMain.Rows[sRow].Cells[HMaterIDCol].Value);
                                    //获取品番
                                    oDs2 = oWeb.getDataSetBySQL("exec h_p_HMaterPinfan " + sHMaterID, "h_p_HMaterPinfan", ref DBUtility.ClsPub.sExeReturnInfo);
                                    //
                                    if (oDs2 != null && oDs2.Tables[0].Rows.Count > 0)
                                    {
                                        grdMain.Rows[sRow].Cells[HCusModelCol].Value = DBUtility.ClsPub.isStrNull(oDs2.Tables[0].Rows[0]["HPinfan"]);
                                    }
                                    else
                                    {
                                        grdMain.Rows[sRow].Cells[HCusModelCol].Value = "";
                                    }
                                //}
                                break;
                            //case HDateCol:
@@ -1340,9 +1415,7 @@
            //            HDate = SetDateStr(dtpHDate.Value);
            //            //箱号前缀 = 班组ID + 批次 + 日期 + 物料代码 + 辅助属性
            //            sCaseNoNumber = HGroupID + HBatchNo + HDate + sMaterNumber + sAuxItemName;
            //            Ds = oWeb.getDataSetBySQL("exec h_p_WMS_GetMaxNo  '" + sCaseNoNumber + "'", "h_p_WMS_GetMaxNo", ref DBUtility.ClsPub.sExeReturnInfo);//获取最大流水号
            //            txtHCaseNo.Text = (DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]) + 1).ToString();
            //            sCaseNoNumber = HGroupID + HBatchNo + HDate + sMaterNumber + sAuxItemName;
            //            txtHCaseNo.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]).ToString();
            //        }
            //    }
@@ -1634,7 +1707,7 @@
        //网格编辑后处理
        private void grdMain_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
            //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
            if (e.ColumnIndex == HMinQtyCol)
            {
                RowCount(e.RowIndex, 0);  //
@@ -1694,12 +1767,12 @@
        }
        private void grdMain_RowHeadersWidthChanged(object sender, EventArgs e)
        {
            DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
            //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
        }
        private void grdMain_Scroll(object sender, ScrollEventArgs e)
        {
            DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
            //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
            oSumGrid.DisplayCurRow();
        }
@@ -1881,7 +1954,7 @@
        private void grdSub_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
            //DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
            RowCount(e.RowIndex, 0);  //计算 金额 单价
            //
            if (this.EditingControl != null)      //释放事件