From 710311abde05a1e08a90d8b6154d7d6b78e7a84e Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期一, 24 三月 2025 17:31:24 +0800
Subject: [PATCH] 设备启动点检单、防错验证检查单、首件单、巡检单、工序转移检验单、库存检验单、车间自检单、环境检测单、不良品评审处理单、异常反馈单、异常反馈接收单、异常反馈签到单、异常反馈处理单、异常反馈验收单、检验取样单、检验还样单 数据库分页;    保存前控制,保存后控制; 审核前控制,反审核前控制, 审核后控制,反审核后控制,删除前控制,删除后控制; 关闭前控制,反关闭前控制;;关闭后控制,反关闭后控制;

---
 WebAPI/Controllers/CJGL/Qc_PreventErrMouldCheckBillController.cs |  524 ++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 367 insertions(+), 157 deletions(-)

diff --git a/WebAPI/Controllers/CJGL/Qc_PreventErrMouldCheckBillController.cs b/WebAPI/Controllers/CJGL/Qc_PreventErrMouldCheckBillController.cs
index dec3bdd..a4fe018 100644
--- a/WebAPI/Controllers/CJGL/Qc_PreventErrMouldCheckBillController.cs
+++ b/WebAPI/Controllers/CJGL/Qc_PreventErrMouldCheckBillController.cs
@@ -2,6 +2,7 @@
 using Model;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
+using SyntacticSugar.constant;
 using System;
 using System.Collections.Generic;
 using System.Data;
@@ -79,6 +80,62 @@
             }
         }
         #endregion
+
+        #region 闃查敊楠岃瘉妫�鏌� 鍒嗛〉鍒楄〃
+        [Route("Qc_PreventErrMouldCheckBill/get锘縌c_PreventErrMouldCheckBillListPage")]
+        [HttpGet]
+        public json get锘縎c_WorkBeginDotCheckBillListPage(string sWhere, string user, int page, int size)
+        {
+            DataSet ds;
+            json res = new json();
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鍒ゆ柇鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Qc_PreventErrMouldCheckBillMain_Check", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愭煡璇紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                sWhere = sWhere.Replace("'", "''");
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Qc_PreventErrMouldCheckBillList " + page + "," + size + ",''", "h_p_Qc_PreventErrMouldCheckBillList");
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Qc_PreventErrMouldCheckBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_Qc_PreventErrMouldCheckBillList");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                res.code = CodeConstant.SUCCEED;
+                res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                res.Message = "Sucess锛�";
+                res.list = columnNameList;
+                res.data = ds.Tables[0];
+                return res;
+            }
+            catch (Exception e)
+            {
+                res.code = CodeConstant.FAIL;
+                res.count = CountConstant.FAIL;
+                res.Message = "Exception锛�" + e.ToString();
+                res.data = null;
+                return res;
+            }
+        }
+        #endregion
+
 
         #region 闃查敊楠岃瘉妫�鏌ュ垪琛� 鑾峰彇缂栬緫鍒楄〃鏁版嵁
         [Route("Qc_PreventErrMouldCheckBill/锘縌c_PreventErrMouldCheckBillMainEditList")]
@@ -313,9 +370,78 @@
                     return objJsonResult;
                 }
 
+                string s = "";
+                DAL.ClsQc_PreventErrMouldCheckBillMain BillOld = new DAL.ClsQc_PreventErrMouldCheckBillMain();
+                if (BillOld.ShowBill(long.Parse(HInterID), ref s) == false)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "姝ゅ崟鎹湁璇紒";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇鏄惁鍙垹闄�
+                if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽鍒犻櫎锛�";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+
+
                 oCN.BeginTran();
 
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Qc_PreventErrMouldCheckBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Qc_PreventErrMouldCheckBill_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //==================================================================================  
+
                 oCN.RunProc("delete from Qc_PreventErrMouldCheckBillMain where HInterID = " + HInterID);
+                oCN.RunProc("delete from Qc_PreventErrMouldCheckBillSub where HInterID = " + HInterID);
+
+                //鍒犻櫎鍚庢帶鍒�==================================================================================      
+                string sql2 = "exec h_p_Qc_PreventErrMouldCheckBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+                ds = oCN.RunProcReturn(sql2, "h_p_Qc_PreventErrMouldCheckBill_AfterDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //==============================================================================================     
+
+
 
                 oCN.Commit();
 
@@ -362,44 +488,32 @@
                     return objJsonResult;
                 }
 
-                ClsPub.CurUserName = user;
-                BillOld.MvarItemKey = "Qc_PreventErrMouldCheckBillMain";
-                oCN.BeginTran();//寮�濮嬩簨鍔�
+               
 
-                //Type 1 瀹℃牳  2  鍙嶅鏍�
-                if (Type == 1)
+                DAL.ClsQc_PreventErrMouldCheckBillMain oBill = new DAL.ClsQc_PreventErrMouldCheckBillMain();                   //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(long.Parse(HInterID), ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
                 {
-                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳
-                    DataSet ds;
-                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
-                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
-                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    if (oBill.omodel.HCloseMan.Trim() != "")
                     {
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
-                        objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦紒";
+                        objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�";
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
-                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    if (oBill.omodel.HDeleteMan.Trim() != "")
                     {
-                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆瀹℃牳锛�";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶆瀹℃牳锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (Type == 1)  //瀹℃牳鍒ゆ柇
+                    {
+                        if (oBill.omodel.HChecker.Trim() != "")
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -407,42 +521,10 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
-                        //瀹℃牳鍗曟嵁
-                        if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 1;
-                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
                     }
-                }
-                else
-                {
-                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅鏍�
-                    DataSet ds;
-                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
-                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
-                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    if (Type == 2) //鍙嶅鏍稿垽鏂�
                     {
-                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘杩涜鍙嶅鏍革紒";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍙嶅鏍革紒";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        if (oBill.omodel.HChecker.Trim() == "")
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
@@ -450,25 +532,117 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
-                        //鍙嶅鏍稿崟鎹�
-                        if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 1;
-                            objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
                     }
                 }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
 
-                oCN.Commit();//鎻愪氦浜嬪姟
+                ClsPub.CurUserName = user;
+                BillOld.MvarItemKey = "Qc_PreventErrMouldCheckBillMain";
 
-                objJsonResult.code = "0";
-                objJsonResult.count = 1;
-                objJsonResult.Message = "鎵ц鎴愬姛锛�";
-                objJsonResult.data = null;
-                return objJsonResult; ;
+
+                //Type 1 瀹℃牳  2  鍙嶅鏍�
+                if (Type == 1)
+                {
+                    oCN.BeginTran();
+
+                    //瀹℃牳鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Qc_PreventErrMouldCheckBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Qc_PreventErrMouldCheckBill_BeforeCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+                    //瀹℃牳鎻愪氦
+                    if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Qc_PreventErrMouldCheckBill_AfterCheckCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        oCN.Commit();
+
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳鎴愬姛锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        oCN.RollBack();
+
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                if (Type == 2) //鍙嶅鏍告彁浜�
+                {
+
+                    //鍙嶅鏍稿墠鎺у埗=========================================        
+                    string sql1 = "exec h_p_Qc_PreventErrMouldCheckBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Qc_PreventErrMouldCheckBill_BeforeUnCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+
+                    }
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //===========================================================          
+
+                    //鍙嶅鏍告彁浜bandonCheck
+                    if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Qc_PreventErrMouldCheckBill_AfterUnCheckCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍告垚鍔�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                return objJsonResult;
+
 
             }
             catch (Exception e)
@@ -508,58 +682,48 @@
                     return objJsonResult;
                 }
 
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);
                 ClsPub.CurUserName = user;
-                BillOld.MvarItemKey = "Qc_PreventErrMouldCheckBillMain";
-                oCN.BeginTran();//寮�濮嬩簨鍔�
+                DAL.ClsQc_PreventErrMouldCheckBillMain oBill = new DAL.ClsQc_PreventErrMouldCheckBillMain();           //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
 
-                //Type 1 鍏抽棴  2  鍙嶅叧闂�
-                if (Type == 1)
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
                 {
-                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍏抽棴
-                    DataSet ds;
-                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
-                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
-                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    if (oBill.omodel.HDeleteMan.Trim() != "")
                     {
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
-                        objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦紒";
+                        objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴锛�";
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
-                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+                    if (oBill.omodel.HChecker.Trim() == "")
                     {
-                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (Type == 1)  //鍏抽棴鍒ゆ柇
+                    {
+                        if (oBill.omodel.HCloseMan.Trim() != "")
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
-                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!";
+                            objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴锛�";
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
-                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                    }
+                    if (Type == 2) //鍙嶅叧闂垽鏂�
+                    {
+                        if (oBill.omodel.HCloseMan.Trim() == "")
                         {
                             objJsonResult.code = "0";
                             objJsonResult.count = 0;
-                            objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-
-                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-                        //鍏抽棴鍗曟嵁
-                        if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 1;
-                            objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                            objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸弽鍏抽棴锛�";
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
@@ -567,55 +731,101 @@
                 }
                 else
                 {
-                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅叧闂�
-                    DataSet ds;
-                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
-                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
-                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
-                    {
-                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶈兘杩涜鍏抽棴!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-                        if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "")
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸啀鍙嶅叧闂�!";
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-                        //鍙嶅叧闂崟鎹�
-                        if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 1;
-                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
-                            objJsonResult.data = null;
-                            return objJsonResult;
-                        }
-                    }
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
                 }
 
-                oCN.Commit();//鎻愪氦浜嬪姟
 
-                objJsonResult.code = "0";
-                objJsonResult.count = 1;
-                objJsonResult.Message = "鎵ц鎴愬姛锛�";
-                objJsonResult.data = null;
-                return objJsonResult; ;
+                //杩涜闇�瑕佽繘琛岀殑鍏抽棴/鍙嶅叧闂搷浣�
+                if (Type == 1) //鍏抽棴鎻愪氦
+                {
+                    //鍏抽棴鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Qc_PreventErrMouldCheckBill_BeforeCloseCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Qc_PreventErrMouldCheckBill_BeforeCloseCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:鍏抽棴鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+                    //鍏抽棴鎻愪氦
+                    if (oBill.CloseBill(lngBillKey, oBill.omodel.HBillNo, "h_p_Qc_PreventErrMouldCheckBill_AfterCloseCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴鎴愬姛";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                if (Type == 2) //鍙嶅叧闂彁浜�
+                {
+                    //鍙嶅叧闂墠鎺у埗=========================================      
+                    string sql1 = "exec h_p_Qc_PreventErrMouldCheckBill_BeforeUnCloseCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Qc_PreventErrMouldCheckBill_BeforeUnCloseCtrl    ");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:鍙嶅叧闂墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //==================================================================================      
+
+
+                    //鍙嶅叧闂彁浜�
+                    if (oBill.CancelClose(lngBillKey, oBill.omodel.HBillNo, "h_p_Qc_PreventErrMouldCheckBill_AfterUnCloseCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂垚鍔�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                return objJsonResult;
 
             }
             catch (Exception e)

--
Gitblit v1.9.1