From bafdbac9abdfc9de05b211cf7f54a3f792cb8a74 Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期三, 08 一月 2025 17:48:14 +0800
Subject: [PATCH] 单品过站增加班次,修复班次开班单的制单人字段保存错

---
 WebAPI/Controllers/CJGL/Sc_ProcExchWorkBackBillController.cs |  628 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 615 insertions(+), 13 deletions(-)

diff --git a/WebAPI/Controllers/CJGL/Sc_ProcExchWorkBackBillController.cs b/WebAPI/Controllers/CJGL/Sc_ProcExchWorkBackBillController.cs
index a954a0e..f500281 100644
--- a/WebAPI/Controllers/CJGL/Sc_ProcExchWorkBackBillController.cs
+++ b/WebAPI/Controllers/CJGL/Sc_ProcExchWorkBackBillController.cs
@@ -16,6 +16,7 @@
         public DBUtility.ClsPub.Enum_BillStatus BillStatus;
         private json objJsonResult = new json();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
         DataSet ds;
 
         #region 宸ュ簭杩斿伐鐢宠鍗曞垪琛�
@@ -36,9 +37,9 @@
                     return objJsonResult;
                 }
 
-                string sql1 = "select * from h_v_Sc_ProcExchWorkBackBillList where 1 = 1  ";
+                string sql1 = "select * from h_v_Sc_ProcExchWorkBackBillList_Query where 1 = 1  ";
                 string sql = sql1 + sWhere + " order by hmainid desc";
-                ds = oCN.RunProcReturn(sql, "h_v_Sc_ProcExchWorkBackBillList");
+                ds = oCN.RunProcReturn(sql, "h_v_Sc_ProcExchWorkBackBillList_Query");
 
                 //娣诲姞鍒楀悕
                 foreach (DataColumn col in ds.Tables[0].Columns)
@@ -67,6 +68,46 @@
         }
         #endregion
 
+        #region 宸ュ簭杩斿伐鐢宠鍗曞垪琛╛缂栬緫椤甸潰鍒濆鍖�
+        [Route("Sc_ProcExchWorkBackBill/Sc_ProcExchWorkBackBillList_Edit")]
+        [HttpGet]
+        public object Sc_ProcExchWorkBackBillList_Edit(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                string sql1 = "select * from h_v_Sc_ProcExchWorkBackBillList where 1 = 1  ";
+                string sql = sql1 + sWhere + " order by hmainid desc";
+                ds = oCN.RunProcReturn(sql, "h_v_Sc_ProcExchWorkBackBillList");
+
+                //娣诲姞鍒楀悕
+                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鍒楀璞$殑鍒楀悕
+                }
+
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.list = columnNameList;
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         #region 鏌ヨ宸ュ簭娴佽浆鍗℃暟鎹� 鏌ヨ 褰撳墠 鍜� 涓嬩竴鏉℃暟鎹�
         [Route("Sc_ProcExchWorkBackBill/GetProcessExchangeBillSub")]
         [HttpGet]
@@ -77,7 +118,7 @@
             {
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                 string sql = string.Format(@"select top 2 * from h_v_Sc_ProcessExchangeBillQuerySub");
-                ds = oCN.RunProcReturn(sql + sWhere, "h_v_Sc_ProcessExchangeBillQuerySub");
+                ds = oCN.RunProcReturn(sql + sWhere + " order by cast(娴佹按鍙� as int) ", "h_v_Sc_ProcessExchangeBillQuerySub");
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
@@ -145,6 +186,14 @@
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
                         objJsonResult.Message = "淇濆瓨澶辫触锛佹病鏈夊崟鎹棩鏈燂紝鏃犳硶淇濆瓨锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    if (oItem.HChecker != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佸崟鎹凡瀹℃牳锛屾棤娉曚繚瀛橈紒";
                         objJsonResult.data = 1;
                         return objJsonResult;
                     }
@@ -270,11 +319,34 @@
                     return objJsonResult;
                 }
 
-                bool IsDete = oBill.DeleteBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo);
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
+                string sql1 = "exec h_p_Sc_ProcExchWorkBackBill_BeforeDelCtrl " + HInterID + ",'" + HBillNo + "','" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Sc_ProcExchWorkBackBill_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //==================================================================================      
+
+                bool IsDete = oBill.DeleteBill(lngBillKey,HBillNo, "h_p_Sc_ProcExchWorkBackBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo);
 
                 if (IsDete)
                 {
-                    objJsonResult.code = "0";
+                    objJsonResult.code = "1";
                     objJsonResult.count = 1;
                     objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
                     objJsonResult.data = null;
@@ -301,7 +373,7 @@
         }
         #endregion
 
-        #region 宸ュ簭杩斿伐鐢宠鍗� 瀹℃牳
+        //#region 宸ュ簭杩斿伐鐢宠鍗� 瀹℃牳
         [Route("Sc_ProcExchWorkBackBill/set_CheckBill")]
         [HttpGet]
         public object set_CheckBill(int HInterID, string CurUserName)
@@ -339,9 +411,9 @@
                         return objJsonResult;
                     }
 
-                  
+
                     //瀹℃牳
-                    if (Cj_StationInBillCheckBill(HInterID, CurUserName, ref DBUtility.ClsPub.sExeReturnInfo))
+                    if (Cj_StationInBillCheckBill(HInterID, int.Parse(Ds.Tables[0].Rows[0]["HProcExchInterID"].ToString()), CurUserName, Ds.Tables[0].Rows[0]["HBillOperationType"].ToString(), ref DBUtility.ClsPub.sExeReturnInfo))
                     {
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
@@ -379,15 +451,81 @@
         }
 
         //瀹℃牳
-        public bool Cj_StationInBillCheckBill(Int64 HInterID, string CurUserName, ref string sReturn)
+        public bool Cj_StationInBillCheckBill(Int64 HInterID, int HProcExchInterID, string CurUserName,string HBillOperationType, ref string sReturn)
         {
             try
             {
                 oCN.BeginTran();
-                oCN.RunProc(" Update Sc_ProcExchWorkBackBillMain set HChecker='" + CurUserName + "',HBillStatus=2,HCheckDate='getdate()' Where HInterID=" + HInterID.ToString());
-                oCN.RunProc("exec h_p_ProcExchWorkBackBill_Check_In " + HInterID.ToString());
-                oCN.Commit();
-                return true;
+                oCN.RunProc(" Update Sc_ProcExchWorkBackBillMain set HChecker='" + CurUserName + "',HBillStatus=2,HCheckDate=getdate() Where HInterID=" + HInterID.ToString());
+                if (HBillOperationType == "1")
+                {
+                    //鍥炲~宸ュ簭娴佽浆鍗�
+                    oCN.RunProc("exec h_p_ProcExchWorkBackBill_Check_In " + HInterID.ToString());
+                    oCN.RunProc("exec h_p_Sc_ProcessExchangeBill_SetRemark " + HProcExchInterID.ToString()); //璁剧疆 澶囨敞 涓� 宸ヨ壓娴�
+                    oCN.RunProc("exec h_p_Sc_ProcessExchangeBill_SetUpdate " + HProcExchInterID.ToString()); //璁剧疆 鏈亾 棣栭亾 杞� 绛変俊鎭�   鍣ㄥ叿娓呭崟  宸ヨ壓鍙傛暟娓呭崟锛�
+                    DataSet ds = new DataSet();
+                    //璁剧疆鏉$爜鍙�  鍥炲~ 棰嗘枡鎵规
+                    ds = oCN.RunProcReturn("exec h_p_Mes_ProcessExchangeBackBarCode " + HProcExchInterID.ToString(), "h_p_Mes_ProcessExchangeBackBarCode");
+                    if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
+                    {
+                        sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]).ToString();
+                        oCN.RollBack();
+                        return false;
+                    }
+
+                    //鎺у埗鍏宠仈鏁伴噺
+                    ds = null;
+                    ds = oCN.RunProcReturn("exec h_p_Sc_ProcessExchangeBill_Checkqty " + HProcExchInterID.ToString(), "h_p_Sc_ProcessExchangeBill_Checkqty");
+                    if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
+                    {
+                        sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]).ToString();
+                        oCN.RollBack();
+                        return false;
+                    }
+                    oCN.Commit();
+                    return true;
+                }
+                else if(HBillOperationType == "2")
+                {
+                    //鍥炲~宸ュ簭娴佽浆鍗�
+                    DataSet ds0 = oCN.RunProcReturn("exec h_p_ProcExchWorkBackBill_Check_In_Delete " + HInterID.ToString(), "h_p_ProcExchWorkBackBill_Check_In_Delete");
+                    if (ds0.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        sReturn = ds0.Tables[0].Rows[0]["HBackRemark"].ToString();
+                        oCN.RollBack();
+                        return false;
+                    }
+
+                    oCN.RunProc("exec h_p_Sc_ProcessExchangeBill_SetRemark " + HProcExchInterID.ToString()); //璁剧疆 澶囨敞 涓� 宸ヨ壓娴�
+                    oCN.RunProc("exec h_p_Sc_ProcessExchangeBill_SetUpdate " + HProcExchInterID.ToString()); //璁剧疆 鏈亾 棣栭亾 杞� 绛変俊鎭�   鍣ㄥ叿娓呭崟  宸ヨ壓鍙傛暟娓呭崟锛�
+                    DataSet ds = new DataSet();
+                    //璁剧疆鏉$爜鍙�  鍥炲~ 棰嗘枡鎵规
+                    ds = oCN.RunProcReturn("exec h_p_Mes_ProcessExchangeBackBarCode " + HProcExchInterID.ToString(), "h_p_Mes_ProcessExchangeBackBarCode");
+                    if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
+                    {
+                        sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]).ToString();
+                        oCN.RollBack();
+                        return false;
+                    }
+
+                    //鎺у埗鍏宠仈鏁伴噺
+                    ds = null;
+                    ds = oCN.RunProcReturn("exec h_p_Sc_ProcessExchangeBill_Checkqty " + HProcExchInterID.ToString(), "h_p_Sc_ProcessExchangeBill_Checkqty");
+                    if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
+                    {
+                        sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]).ToString();
+                        oCN.RollBack();
+                        return false;
+                    }
+                    oCN.Commit();
+                    return true;
+                }
+                else
+                {
+                    sReturn = "鏈缃彲璇嗗埆鐨勬搷浣滅被鍨�!";
+                    oCN.RollBack();
+                    return false;
+                }
             }
             catch (Exception e)
             {
@@ -396,7 +534,471 @@
                 return false; ;
             }
         }
+        //#endregion
+
+        #region 宸ュ簭杩斿伐鐢宠鍗� 瀹℃牳/鍙嶅鏍稿姛鑳�
+        [Route("Sc_ProcExchWorkBackBill/CheckSc_ProcExchWorkBackBill")]
+        [HttpGet]
+        public object CheckSc_ProcExchWorkBackBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Sc_ProcExchWorkBackBill_Check", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬鏍�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (string.IsNullOrWhiteSpace(HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ClsPub.CurUserName = user;
+                BillOld.MvarItemKey = "Sc_ProcExchWorkBackBillMain";
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 瀹℃牳  2  鍙嶅鏍�
+                if (Type == 1)
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳
+                    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]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶉渶瑕佸啀瀹℃牳!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+
+
+                    //瀹℃牳鍓嶆帶鍒�
+                    string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
+                    sql = "exec h_p_Sc_ProcExchWorkBackBill_BeforeCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql, "h_p_Sc_ProcExchWorkBackBill_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;
+                        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 (!BillOld.CheckBill(Int64.Parse(HInterID), HBillNo, "h_p_Sc_ProcExchWorkBackBill_AfterCheckCtrl", user, 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 (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;
+                        }
+                    }
+
+                    //鍙嶅鏍稿墠鎺у埗
+                    string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
+                    sql = "exec h_p_Sc_ProcExchWorkBackBill_BeforeUnCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql, "h_p_Sc_ProcExchWorkBackBill_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;
+                    }
+
+                    //鍙嶅鏍稿崟鎹�
+                    if (BillOld.AbandonCheck(Int64.Parse(HInterID), HBillNo, "h_p_Sc_ProcExchWorkBackBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo))
+                    {
+                        //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                        //DataSet DSet = oCn.RunProcReturn("exec h_p_Sc_ICMOBill_AbandonCheckCtrl " + int.Parse(HInterID), "h_p_Sc_ICMOBill_AbandonCheckCtrl");
+                        ////if (DBUtility.ClsPub.isInt(DSet.Tables[0].Rows[0]["Hback"]) != 0)
+                        ////{
+                        ////    objJsonResult.code = "0";
+                        ////    objJsonResult.count = 1;
+                        ////    objJsonResult.Message = "璇ヤ换鍔″崟宸蹭笅鎺ㄦ祦杞崱锛屼笉鍏佽鍙嶅鏍�" + DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[0]["HBackRemark"]);
+                        ////    objJsonResult.data = null;
+                        ////    return objJsonResult;
+                        ////}
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
         #endregion
 
+        #region 宸ヨ壓璺嚎鍗曞叧闂�/鍙嶅叧闂姛鑳�
+        [Route("Sc_ProcExchWorkBackBill/CloseSc_ProcExchWorkBackBill")]
+        [HttpGet]
+        public object CloseSc_ProcExchWorkBackBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Sc_ProcExchWorkBackBill_Close", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬叧闂�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (string.IsNullOrWhiteSpace(HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ClsPub.CurUserName = user;
+                BillOld.MvarItemKey = "Sc_ProcExchWorkBackBillMain";
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 鍏抽棴  2  鍙嶅叧闂�
+                if (Type == 1)
+                {
+                    //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍏抽棴
+                    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]["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.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 (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;
+                    }
+                }
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鎺掑崟澧欐煡璇㈠垪琛�
+        [Route("Sc_ProcExchWorkBackBill/SingleRowWallList")]
+        [HttpGet]
+        public object SingleRowWallList(string sWhere, string user)
+        {
+            try
+            {
+                DataTable dt1 = new DataTable("DataSouce");
+                DataTable dt2 = new DataTable("DataColor");
+                List<object> columnNameList = new List<object>();
+
+                string sql = "exec h_p_Sc_SingleRowWall  " + sWhere;
+                ds = oCN.RunProcReturn(sql, "DataSouce");
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    dt1.Columns.Add(col.ColumnName);
+                    dt2.Columns.Add(col.ColumnName);
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                if (ds.Tables.Count == 2)
+                {
+
+                    int[] num2 = new int[ds.Tables[0].Columns.Count];//璁板綍姣忎竴鍒楄幏鍙栨湁鍊肩殑琛屾暟
+
+                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
+                    {
+                        int num = 0;//璁板綍娌℃湁鏁版嵁琛岀殑鍒楁暟
+                        int[] num3 = new int[ds.Tables[0].Columns.Count];//璁板綍姣忎竴鍒楁病鏈夋暟鎹殑琛屾暟
+
+                        DataRow dtrow = dt1.NewRow();
+                        for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
+                        {
+                            int num1 = 0;//璁板綍鏈夊灏戞婊¤冻涓嶄负绌虹殑鏉′欢
+                            DataColumn col = ds.Tables[0].Columns[j];
+                            for (int k = 0; k < ds.Tables[0].Rows.Count; k++)
+                            {
+                                DataRow item = ds.Tables[0].Rows[k];
+                                if (item[col.ColumnName.ToString()].ToString() != "")
+                                {
+                                    num1 += 1;
+                                    if (num1 > num2[j])
+                                    {
+                                        dtrow[col.ColumnName.ToString()] = item[col.ColumnName.ToString()].ToString();
+                                        num2[j] += 1;
+                                        break;
+                                    }
+                                    else
+                                    {
+                                        num3[j] += 1;
+                                    }
+                                }
+                                else
+                                {
+                                    num3[j] += 1;
+                                }
+                                if (num3[j] == ds.Tables[0].Rows.Count)
+                                {
+                                    num += 1;
+                                }
+                            }
+                        }
+                        if (num == ds.Tables[0].Columns.Count)
+                        {
+                            break;
+                        }
+                        dt1.Rows.Add(dtrow);
+                    }
+
+                    int[] nums2 = new int[ds.Tables[1].Columns.Count];//璁板綍姣忎竴鍒楄幏鍙栨湁鍊肩殑琛屾暟
+
+                    for (int i = 0; i < ds.Tables[1].Rows.Count; i++)
+                    {
+                        int num = 0;//璁板綍娌℃湁鏁版嵁琛岀殑鍒楁暟
+                        int[] num3 = new int[ds.Tables[1].Columns.Count];//璁板綍姣忎竴鍒楁病鏈夋暟鎹殑琛屾暟
+
+                        DataRow row = ds.Tables[1].Rows[i];
+                        DataRow dtrow = dt2.NewRow();
+                        for (int j = 0; j < ds.Tables[1].Columns.Count; j++)
+                        {
+                            int num1 = 0;//璁板綍鏈夊灏戞婊¤冻涓嶄负绌虹殑鏉′欢
+                            DataColumn col = ds.Tables[1].Columns[j];
+                            for (int k = 0; k < ds.Tables[1].Rows.Count; k++)
+                            {
+                                DataRow item = ds.Tables[1].Rows[k];
+                                if (item[col.ColumnName.ToString()].ToString() != "")
+                                {
+                                    num1 += 1;
+                                    if (num1 > nums2[j])
+                                    {
+                                        dtrow[col.ColumnName.ToString()] = item[col.ColumnName.ToString()].ToString();
+                                        nums2[j] += 1;
+                                        break;
+                                    }
+                                    else
+                                    {
+                                        num3[j] += 1;
+                                    }
+                                }
+                                else
+                                {
+                                    num3[j] += 1;
+                                }
+                                if (num3[j] == ds.Tables[0].Rows.Count)
+                                {
+                                    num += 1;
+                                }
+                            }
+                        }
+                        if (num == ds.Tables[0].Columns.Count)
+                        {
+                            break;
+                        }
+                        dt2.Rows.Add(dtrow);
+                    }
+
+                    ds.Tables.Clear();
+                    ds.Tables.Add(dt1);
+                    ds.Tables.Add(dt2);
+                }
+                else {
+                    int[] num2 = new int[ds.Tables[0].Columns.Count];//璁板綍姣忎竴鍒楄幏鍙栨湁鍊肩殑琛屾暟
+
+                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
+                    {
+                        int num = 0;//璁板綍娌℃湁鏁版嵁琛岀殑鍒楁暟
+                        int[] num3 = new int[ds.Tables[0].Columns.Count];//璁板綍姣忎竴鍒楁病鏈夋暟鎹殑琛屾暟
+
+                        DataRow dtrow = dt1.NewRow();
+                        for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
+                        {
+                            int num1 = 0;//璁板綍鏈夊灏戞婊¤冻涓嶄负绌虹殑鏉′欢
+                            DataColumn col = ds.Tables[0].Columns[j];
+                            for (int k = 0; k < ds.Tables[0].Rows.Count; k++)
+                            {
+                                DataRow item = ds.Tables[0].Rows[k];
+                                if (item[col.ColumnName.ToString()].ToString() != "")
+                                {
+                                    num1 += 1;
+                                    if (num1 > num2[j])
+                                    {
+                                        dtrow[col.ColumnName.ToString()] = item[col.ColumnName.ToString()].ToString();
+                                        num2[j] += 1;
+                                        break;
+                                    }
+                                    else
+                                    {
+                                        num3[j] += 1;
+                                    }
+                                }
+                                else
+                                {
+                                    num3[j] += 1;
+                                }
+                                if (num3[j] == ds.Tables[0].Rows.Count)
+                                {
+                                    num += 1;
+                                }
+                            }
+                        }
+                        if (num == ds.Tables[0].Columns.Count)
+                        {
+                            break;
+                        }
+                        dt1.Rows.Add(dtrow);
+                    }
+
+                    ds.Tables.Clear();
+                    ds.Tables.Add(dt1);
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.list = columnNameList;
+                objJsonResult.data = ds;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1