yangle
2022-08-16 1cbc6c9bee7048d3546adebe87d96715630e7d59
WarM/ÌõÂë´òÓ¡/Sc_ICMOToBarCode.cs
@@ -781,6 +781,8 @@
                DataSet Ds;
                int LSH = 0;                //流水号
                string LSH2 = "";           //流水号转换成字符
                double HZXQty = 0;         //装箱数量
                double HDDQty = 0;         //订单数量
                double HBQty = 0;         //箱数
@@ -790,48 +792,159 @@
                int LSHlen = 6;             //流水号长度
                string TM = "";             //条码
                string sPackBarCode = "";
                //HDate = dtpHBeginDate.Value.ToShortDateString();
                //HYear = ClsPub.isDate(HDate).Year.ToString().Substring(2, 2);
                //HPeriod = "0" + ClsPub.isDate(HDate).Month.ToString();
                //HPeriod = HPeriod.Substring(HPeriod.Length - 2, 2);
                //HDay = "0" + ClsPub.isDate(HDate).Day.ToString();
                //HDay = HDay.Substring(HDay.Length - 2, 2);
                string HPrdDate = "";
                string HBC = "";
                string HDate1 = "";
                DataSet Ds99;
                    HDate = dtpHBeginDate.Value.ToShortDateString();
                    DataSet DSet1 = oCn.RunProcReturn("select * from Gy_FactoryDayOff Where HFactoryDayOffDate='" + HDate.ToString() + "'", "Gy_FactoryDayOff", ref DBUtility.ClsPub.sExeReturnInfo);
                    //生成首行标题
                    if (DSet1 == null || DSet1.Tables[0].Rows.Count == 0)
                //箱号
                string HXH = "";
                //箱号流水号
                int LSH3 = 0;                //流水号
                string LSH4 = "";           //流水号转换成字符
                //机台
                string HJT = "";
                HDate = DateTime.Now.ToString();
                //判断当前时间是否在工作时间段内
                string _strWorkingDayAM = "07:30";//工作时间上午08:30
                string _strWorkingDayPM = "19:30";
                string _strWorkingDayTM = "00:00";
                string _strWorkingDaySM = "23:59";
                TimeSpan dspWorkingDayAM = DateTime.Parse(_strWorkingDayAM).TimeOfDay;
                TimeSpan dspWorkingDayPM = DateTime.Parse(_strWorkingDayPM).TimeOfDay;
                TimeSpan dspWorkingDayTM = DateTime.Parse(_strWorkingDayTM).TimeOfDay;
                TimeSpan dspWorkingDaySM = DateTime.Parse(_strWorkingDaySM).TimeOfDay;
                //string time1 = "2017-2-17 8:10:00";
                DateTime t1 = Convert.ToDateTime(HDate);
                TimeSpan dspNow = t1.TimeOfDay;
                HDate1 = Convert.ToDateTime(HDate).ToShortDateString();
                //1.正常上班时间 å°±æ˜¯ç™½ç­  å¦‚果不是礼拜天 å°±å¾€å‰æå‰ä¸€å¤©
                if (dspNow > dspWorkingDayAM && dspNow < dspWorkingDayPM)
                {
                    HBC = "白班";
                    DataSet DSet2 = oCn.RunProcReturn("select * from Gy_FactoryDayOff Where HFactoryDayOffDate='" + HDate1.ToString() + "'", "Gy_FactoryDayOff", ref DBUtility.ClsPub.sExeReturnInfo);
                    if (DSet2 == null || DSet2.Tables[0].Rows.Count == 0)
                    {
                        HDate = DateTime.Now.ToShortDateString();
                        HYear = ClsPub.isDate(HDate).Year.ToString().Substring(2, 2);
                        HPeriod = "0" + ClsPub.isDate(HDate).Month.ToString();
                        HPeriod = HPeriod.Substring(HPeriod.Length - 2, 2);
                        HDay = "0" + ClsPub.isDate(HDate).Day.ToString();
                        HDay = HDay.Substring(HDay.Length - 2, 2);
                        long HTMaterID = 0;
                        HTMaterID = ClsPub.isLong(grdMain.Rows[0].Cells[Fun_GetCol("HMaterID")].Value);
                        string sPackStr = "ZXM" + HYear + HPeriod + HDay + HTMaterID; //外箱码 å‰ç¼€
                        DataSet DsTM = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sPackStr + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号                                                                                          //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                        Int64 TTM_LSH = ClsPub.isInt(DsTM.Tables[0].Rows[0][0]) + 1;
                        sPackBarCode = sPackStr + TTM_LSH.ToString();
                        oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sPackStr + "'");
                        HPrdDate = HDate;
                    }
                    else
                    {
                    HDate = DBUtility.ClsPub.isStrNull(DSet1.Tables[0].Rows[0]["HNoFactoryDayOffDate"]);
                    HYear = ClsPub.isDate(HDate).Year.ToString().Substring(2, 2);
                    HPeriod = "0" + ClsPub.isDate(HDate).Month.ToString();
                    HPeriod = HPeriod.Substring(HPeriod.Length - 2, 2);
                    HDay = "0" + ClsPub.isDate(HDate).Day.ToString();
                    HDay = HDay.Substring(HDay.Length - 2, 2);
                    long HTMaterID = 0;
                    HTMaterID = ClsPub.isLong(grdMain.Rows[0].Cells[Fun_GetCol("HMaterID")].Value);
                    string sPackStr = "ZXM" + HYear + HPeriod + HDay + HTMaterID; //外箱码 å‰ç¼€
                    DataSet DsTM = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sPackStr + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号                                                                                          //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                    Int64 TTM_LSH = ClsPub.isInt(DsTM.Tables[0].Rows[0][0]) + 1;
                    sPackBarCode = sPackStr + TTM_LSH.ToString() + "+" ;
                    oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sPackStr + "'");
                        HPrdDate = DBUtility.ClsPub.isStrNull(DSet2.Tables[0].Rows[0]["HNoFactoryDayOffDate"]);
                    }
                }
                //2.大于19:30  å°äºŽ24:00  å¤œç­
                if (dspNow > dspWorkingDayPM && dspNow < dspWorkingDaySM)
                {
                    HBC = "夜班";
                    DataSet DSet2 = oCn.RunProcReturn("select * from Gy_FactoryDayOff Where HFactoryDayOffDate='" + HDate1.ToString() + "'", "Gy_FactoryDayOff", ref DBUtility.ClsPub.sExeReturnInfo);
                    if (DSet2 == null || DSet2.Tables[0].Rows.Count == 0)
                    {
                        HPrdDate = HDate;
                    }
                    else
                    {
                        HPrdDate = DBUtility.ClsPub.isStrNull(DSet2.Tables[0].Rows[0]["HNoFactoryDayOffDate"]);
                    }
                }
                //3.大于00:00  å°äºŽ7:30  ç™½ç­  å…ˆå‡ä¸€å¤©  å†åˆ¤æ–­å‡äº†ä¸€å¤©çš„æ—¥æœŸæ˜¯ä¸æ˜¯åŽ‚ä¼‘æ—¥æœŸ
                if (dspNow > dspWorkingDayTM && dspNow < dspWorkingDayAM)
                {
                    HBC = "夜班";
                    HDate = DBUtility.ClsPub.isStrNull(DBUtility.ClsPub.isDate(HDate).AddDays(-1));
                    HDate = DBUtility.ClsPub.isDate(HDate).ToShortDateString();
                    DataSet DSet2 = oCn.RunProcReturn("select * from Gy_FactoryDayOff Where HFactoryDayOffDate='" + HDate.ToString() + "'", "Gy_FactoryDayOff", ref DBUtility.ClsPub.sExeReturnInfo);
                    if (DSet2 == null || DSet2.Tables[0].Rows.Count == 0)
                    {
                        HPrdDate = HDate;
                    }
                    else
                    {
                        HPrdDate = DBUtility.ClsPub.isStrNull(DSet2.Tables[0].Rows[0]["HNoFactoryDayOffDate"]);
                    }
                }
                HYear = ClsPub.isDate(HPrdDate).Year.ToString().Substring(2, 2);
                HPeriod = "0" + ClsPub.isDate(HPrdDate).Month.ToString();
                HPeriod = HPeriod.Substring(HPeriod.Length - 2, 2);
                HDay = "0" + ClsPub.isDate(HPrdDate).Day.ToString();
                HDay = HDay.Substring(HDay.Length - 2, 2);
                long HTMaterID = 0;
                HTMaterID = ClsPub.isLong(grdMain.Rows[0].Cells[Fun_GetCol("HMaterID")].Value);
                string sPackStr = "ZXM" + HYear + HPeriod + HDay + HTMaterID; //外箱码 å‰ç¼€
                //获取处理过的日期跟今天差几天  ç„¶åŽåŠ å‡ ä¸ª+号
                TimeSpan HCY = Convert.ToDateTime(HPrdDate) - Convert.ToDateTime(DateTime.Now.ToString());
                int a = 1;
                while (a <= HCY.Days)  //当a å°äºŽ å·®å¼‚天数  å¾ªçŽ¯åŠ ä¸Š + å·
                {
                    HPrdDate = HPrdDate + "+";
                    a = a + 1;
                }
                DataSet DsTM = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sPackStr + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号                                                                                          //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                Int64 TTM_LSH = ClsPub.isInt(DsTM.Tables[0].Rows[0][0]) + 1;
                sPackBarCode = sPackStr + TTM_LSH.ToString();
                //DataSet DSet3 = oCn.RunProcReturn("select * from Gy_FactoryDayOff Where HFactoryDayOffDate='" + HDate1.ToString() + "'", "Gy_FactoryDayOff", ref DBUtility.ClsPub.sExeReturnInfo);
                //if (DSet3 == null || DSet3.Tables[0].Rows.Count == 0)
                //{
                //    sPackBarCode = sPackStr + TTM_LSH.ToString() ;
                //}
                //else
                //{
                //    sPackBarCode = sPackStr + TTM_LSH.ToString() + "+";
                //}
                oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sPackStr + "'");
                //DataSet DSet1 = oCn.RunProcReturn("select * from Gy_FactoryDayOff Where HFactoryDayOffDate='" + HDate.ToString() + "'", "Gy_FactoryDayOff", ref DBUtility.ClsPub.sExeReturnInfo);
                //    //生成首行标题
                //    if (DSet1 == null || DSet1.Tables[0].Rows.Count == 0)
                //    {
                //        HDate = DateTime.Now.ToShortDateString();
                //        HYear = ClsPub.isDate(HDate).Year.ToString().Substring(2, 2);
                //        HPeriod = "0" + ClsPub.isDate(HDate).Month.ToString();
                //        HPeriod = HPeriod.Substring(HPeriod.Length - 2, 2);
                //        HDay = "0" + ClsPub.isDate(HDate).Day.ToString();
                //        HDay = HDay.Substring(HDay.Length - 2, 2);
                //        long HTMaterID = 0;
                //        HTMaterID = ClsPub.isLong(grdMain.Rows[0].Cells[Fun_GetCol("HMaterID")].Value);
                //        string sPackStr = "ZXM" + HYear + HPeriod + HDay + HTMaterID; //外箱码 å‰ç¼€
                //        DataSet DsTM = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sPackStr + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号                                                                                          //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                //        Int64 TTM_LSH = ClsPub.isInt(DsTM.Tables[0].Rows[0][0]) + 1;
                //        sPackBarCode = sPackStr + TTM_LSH.ToString();
                //        oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sPackStr + "'");
                //    }
                //    else
                //    {
                //        HDate = DBUtility.ClsPub.isStrNull(DSet1.Tables[0].Rows[0]["HNoFactoryDayOffDate"]);
                //        HYear = ClsPub.isDate(HDate).Year.ToString().Substring(2, 2);
                //        HPeriod = "0" + ClsPub.isDate(HDate).Month.ToString();
                //        HPeriod = HPeriod.Substring(HPeriod.Length - 2, 2);
                //        HDay = "0" + ClsPub.isDate(HDate).Day.ToString();
                //        HDay = HDay.Substring(HDay.Length - 2, 2);
                //        long HTMaterID = 0;
                //        HTMaterID = ClsPub.isLong(grdMain.Rows[0].Cells[Fun_GetCol("HMaterID")].Value);
                //        string sPackStr = "ZXM" + HYear + HPeriod + HDay + HTMaterID; //外箱码 å‰ç¼€
                //        DataSet DsTM = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sPackStr + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号                                                                                          //oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sTMNumber + "'");
                //        Int64 TTM_LSH = ClsPub.isInt(DsTM.Tables[0].Rows[0][0]) + 1;
                //        sPackBarCode = sPackStr + TTM_LSH.ToString() + "+" ;
                //        oCn.RunProc("exec h_p_WMS_SetMaxNo '" + sPackStr + "'");
                //    }
                //=============根据界面上已经分配的数据进行条码生成和打印。
                //获取本次生成的 ä¸»å†…码 
@@ -874,6 +987,15 @@
                        HBatchNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[Fun_GetCol("批次")].Value);
                        
                        HOrgNumber = ClsPub.HOrgNumber;
                        //箱号生成规则  æ—¥æœŸ +  æœºå° + ç­æ¬¡ +  ç‰©æ–™   åªè¦èŽ·å–æœ€å¤§çš„æµæ°´å·
                        HJT = DBUtility.ClsPub.isStrNull(grdMain.Rows[j].Cells[Fun_GetCol("设备")].Value);
                        HXH = HYear + HPeriod + HDay + HBC + HJT + HMaterNumber;
                        Ds99 = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + HXH + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                        LSH3 = ClsPub.isInt(Ds99.Tables[0].Rows[0][0]) + 1;
                        LSH4 = LSH3.ToString();
                        //HBQty = HBQty + ClsPub.isInt(txtHBQty.Text);
@@ -969,7 +1091,7 @@
                                            ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
                                            ",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate " +
                                            ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HSourceID,HInterID " +
                                            ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo " +
                                            ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HPrdDate,HBC,HXH,HInnerBillNo " +
                                            ") values ("
                                            + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID1.ToString() + "," + HUnitID.ToString() + "," + HQty2.ToString() + ", " + HMZQty.ToString()
                                            + ",'" + HBatchNo2 + "'," + HSupID.ToString() + "," + HGroupID.ToString() + ",'" + ClsPub.CurUserName + "',getdate()," + HPrintQty.ToString() + "," + HQty2.ToString()
@@ -977,22 +1099,23 @@
                                            + ", " + HBarcodeQtys.ToString() + "," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'"
                                            + ", " + HCusID.ToString() + ",'" + HCusType + "','" + HEndDate.ToShortDateString() + "','" + HWorkLineName + "','" + HDate + "'"
                                            + ", " + ClsPub.HOrgID.ToString() + "," + ClsPub.HOrgID.ToString() + ",'" + HSeOrderBillNo + "'," + HSourceID.ToString() + "," + HInterID.ToString()
                                            + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HInnerBillNo + "')");
                                            + ",'" + HMaterName + "','" + HMaterModel + "','" + HPinfan + "'," + HAuxPropID.ToString() + ",'" + HMTONo + "','" + HPrdDate + "','" + HBC + "','" + LSH4 + "','" + HInnerBillNo + "')");
                        oCn.RunProc("exec h_p_WMS_SetMaxNo '" + HTMNumber + "'");
                        oCn.RunProc("exec h_p_WMS_SetMaxNo '" + HXH + "'");
                        DisplayTM();
                    }
                }
                //2.循环结束后,根据 æœ¬æ¬¡ç”Ÿæˆçš„ ä¸»å†…码,从后台数据库获取 æ¡ç åˆ—表,生成 ç»„托单 å’Œ æ‰˜æ¡ç ï¼Œ ç›´æŽ¥è°ƒç”¨å­˜å‚¨è¿‡ç¨‹ 
                 //根据外箱码 å†™å…¥ ç»„托单主表,组托单子表,SUM,外箱码档案,SUM档案
                oCn.RunProc("exec  h_p_WMS_PackUnionBill_AddNew  '" + sPackBarCode + "'," + HInterID_TTM.ToString() + ",'" + DBUtility.ClsPub.CurUserName + "','" + HDate + "'," + HInterID.ToString()); //根据箱条码,写入 ä¸»è¡¨ï¼Œå­è¡¨ ï¼Œç®±æ¡ç æ¡£æ¡ˆ
                oCn.RunProc("exec  h_p_WMS_PackUnionBill_AddNew_test  '" + sPackBarCode + "'," + HInterID_TTM.ToString() + ",'" + DBUtility.ClsPub.CurUserName + "'," + HInterID.ToString()); //根据箱条码,写入 ä¸»è¡¨ï¼Œå­è¡¨ ï¼Œç®±æ¡ç æ¡£æ¡ˆ
                oCn.RunProc("exec  h_p_WMS_PackUnionBill_SumSubBill  " + HInterID_TTM.ToString() + ",'" + sPackBarCode + "','3783','" + DBUtility.ClsPub.CurUserName + "'," + HInterID.ToString()); //根据箱条码,写入 SUM表,SUM条码档案
                sPackBarCode = "";
                DataSet DSet = oCn.RunProcReturn("select * from h_v_IF_BarCodeBillList_CS Where HInterID=" + HInterID.ToString() + " and æ¡ç ç±»åž‹ = '托盘条码'", "h_v_IF_BarCodeBillList_CS", ref DBUtility.ClsPub.sExeReturnInfo);
                DataSet DSet = oCn.RunProcReturn("select * from h_v_IF_BarCodeBillList_CS_Test Where HInterID=" + HInterID.ToString() + " and æ¡ç ç±»åž‹ = '托盘条码'", "h_v_IF_BarCodeBillList_CS_Test", ref DBUtility.ClsPub.sExeReturnInfo);
                //生成首行标题
                if (DSet == null)
                {
@@ -1525,7 +1648,7 @@
        private void DisplayTM()
        {
            //HInterID = DBUtility.ClsPub.isInt(txtHMaterID.Tag);
            DataSet DSet = oCn.RunProcReturn("select * from h_v_IF_BarCodeBillList Where HinterID=" + HInterID.ToString() + " and æ¡ç ç±»åž‹ = '托盘条码' order by HItemID", "h_v_IF_BarCodeBillList", ref DBUtility.ClsPub.sExeReturnInfo);
            DataSet DSet = oCn.RunProcReturn("select * from h_v_IF_BarCodeBillList_test Where HinterID=" + HInterID.ToString() + " and æ¡ç ç±»åž‹ = '托盘条码' order by HItemID", "h_v_IF_BarCodeBillList_test", ref DBUtility.ClsPub.sExeReturnInfo);
            //生成首行标题
            if (DSet == null)
            {