From 17ee2c474c049c2ae348532c1e10773c15f9ecde Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期五, 29 七月 2022 08:34:50 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WarM/条码打印/Sc_ICMOToBarCode.cs |  150 ++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 114 insertions(+), 36 deletions(-)

diff --git "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Sc_ICMOToBarCode.cs" "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Sc_ICMOToBarCode.cs"
index 258363c..83a651c 100644
--- "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Sc_ICMOToBarCode.cs"
+++ "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/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.姝e父涓婄彮鏃堕棿 灏辨槸鐧界彮  濡傛灉涓嶆槸绀兼嫓澶� 灏卞線鍓嶆彁鍓嶄竴澶�
+                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 + "'");
+                //    }
 
                 //=============鏍规嵁鐣岄潰涓婂凡缁忓垎閰嶇殑鏁版嵁杩涜鏉$爜鐢熸垚鍜屾墦鍗般��
                 //鑾峰彇鏈鐢熸垚鐨� 涓诲唴鐮� 

--
Gitblit v1.9.1