zzr99
2022-07-30 defb6352aa8847b7acb921f505ba202e491b8835
WarM/ÌõÂë´òÓ¡/Sc_ICMOToBarCode.cs
@@ -790,48 +790,126 @@
                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 = "";
                    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)
                HDate = dtpHBeginDate.Value.ToShortDateString();
                //判断当前时间是否在工作时间段内
                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;
                //1.正常上班时间 å°±æ˜¯ç™½ç­  å¦‚果不是礼拜天 å°±å¾€å‰æå‰ä¸€å¤©
                if (dspNow > dspWorkingDayAM && dspNow < dspWorkingDayPM)
                {
                    HBC = "白班";
                    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)
                    {
                        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='" + 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"]);
                    }
                }
                //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(HPrdDate.Length - 2, 2);
                HDay = "0" + ClsPub.isDate(HPrdDate).Day.ToString();
                HDay = HDay.Substring(HPrdDate.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 + "'");
                //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 + "'");
                //    }
                //=============根据界面上已经分配的数据进行条码生成和打印。
                //获取本次生成的 ä¸»å†…码