From fc9411d843982bb4d5d2e1f79c122329df25712c Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期二, 09 一月 2024 15:29:31 +0800
Subject: [PATCH] 1.销售订单子表,生产订单子表,工序流转卡 主表增加订单等级基础选择框 2.盘点方案,客户分类,供应商分类,地区,销售方式,采购方式编辑 及 列表 模块 3. 用户关联仓库列表,用户关联物料列表 的模块(按钮: 新增,编辑,删除(单行),列设置,按钮设置,退出) 4.器具保养统计表,器具维修统计表,器具故障统计表

---
 WebAPI/Controllers/BLL/Xt_UserController.cs | 1329 +++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 1,082 insertions(+), 247 deletions(-)

diff --git a/WebAPI/Controllers/BLL/Xt_UserController.cs b/WebAPI/Controllers/BLL/Xt_UserController.cs
index d305603..2073814 100644
--- a/WebAPI/Controllers/BLL/Xt_UserController.cs
+++ b/WebAPI/Controllers/BLL/Xt_UserController.cs
@@ -765,6 +765,110 @@
         }
         #endregion
 
+        #region  鐢ㄦ埛鍏宠仈浠撳簱鍒楄〃鏌ヨ
+        [Route("Xt_User/Gy_UserStockRelationList")]
+        [HttpGet]
+        public object Gy_UserStockRelationList(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserStockRelation_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql1 = "select * from h_v_Gy_UserStockRelation where 1 = 1";
+                string sql = sql1 + sWhere + " order by 鐢ㄦ埛浠g爜 ";
+                ds = oCN.RunProcReturn(sql, "h_v_Gy_UserStockRelation");
+
+                //娣诲姞鍒楀悕
+                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.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈浠撳簱鍒楄〃 鍒犻櫎
+        /// <summary>
+        ///鍙傛暟锛歴tring HInterID銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/Gy_UserStockRelationDrop")]
+        [HttpGet]
+        public object Gy_UserStockRelationDrop(string HItemID, string user)
+        {
+            try
+            {
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserStockRelation_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (HItemID == null || HItemID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HItemID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "delete from Gy_UserStockRelation where HItemID = " + HItemID;
+                oCN.RunProc(sql);
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         #region 鐢ㄦ埛鍏宠仈浠撳簱淇濆瓨
         [Route("Xt_User/SaveUserStock")]
         [HttpPost]
@@ -1577,6 +1681,109 @@
         }
         #endregion
 
+        #region  鐢ㄦ埛鍏宠仈鐗╂枡鍒楄〃鏌ヨ
+        [Route("Xt_User/Gy_UserMaterList")]
+        [HttpGet]
+        public object Gy_UserMaterList(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserMaterList_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql1 = "select * from h_v_Gy_UserMater where 1 = 1";
+                string sql = sql1 + sWhere + " order by 鐢ㄦ埛浠g爜 ";
+                ds = oCN.RunProcReturn(sql, "h_v_Gy_UserMater");
+
+                //娣诲姞鍒楀悕
+                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.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈鐗╂枡鍒楄〃 鍒犻櫎
+        /// <summary>
+        ///鍙傛暟锛歴tring HInterID銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/Gy_UserMaterRelationDrop")]
+        [HttpGet]
+        public object Gy_UserMaterRelationDrop(string HItemID, string user)
+        {
+            try
+            {
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserMaterList_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (HItemID == null || HItemID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HItemID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "delete from Gy_UserMaterRelation where HItemID = " + HItemID;
+                oCN.RunProc(sql);
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         #region 鐢ㄦ埛鍏宠仈鐗╂枡淇濆瓨
         [Route("Xt_User/SaveUserMater")]
         [HttpPost]
@@ -1720,251 +1927,6 @@
             }
         }
         #endregion
-        #region 鐢ㄦ埛鍏宠仈瀹㈡埛 鏂囦欢涓婁紶
-        [Route("Xt_User/Gy_UserCustomer_ImportByExcel")]
-        [HttpPost]
-        public object Gy_UserCustomer_ImportByExcel()
-        {
-            try
-            {
-                //var WorkBookName = HttpContext.Current.Request["WorkBookName"];
-                //DBUtility.ClsPub.HOrgID = long.Parse(HttpContext.Current.Request["HOrgID"]);
-                //鑾峰彇鏂囦欢鍚嶇О
-                var file = HttpContext.Current.Request.Files[0];
-                //鑾峰彇鏂囦欢鐗╃悊璺緞
-                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
-                //淇濆瓨鏂囦欢
-                file.SaveAs(ExcelPath);
-
-                NpoiHelper np = new NpoiHelper();
-                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
-
-                //鍒犻櫎鏂囦欢
-                File.Delete(ExcelPath);
-
-                //鍒涘缓涓存椂琛�
-                DataTable tb2 = new DataTable("dt2");
-
-                //娣诲姞鍒楀悕
-                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
-                {
-                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
-                }
-
-                //妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁
-                tb2.Columns.Add("HCusID", typeof(Int32));//缁勭粐ID
-                tb2.Columns.Add("HUserID", typeof(Int32));//渚涘簲鍟�
-
-                //娣诲姞鏁版嵁
-                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
-                {
-                    DataRow row = tb2.NewRow();
-                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
-                    {
-                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
-                    }
-                    tb2.Rows.Add(row);
-                }
-
-                //鏌ヨExcel鏂囦欢涓病鏈夌殑鍒�
-                var error = "";
-                if (!tb2.Columns.Contains("瀹㈡埛浠g爜"))
-                {
-                    error += "娌℃湁鎵惧埌銆愬鎴蜂唬鐮併�戠殑鏍囬,";
-                }
-                if (!tb2.Columns.Contains("瀹㈡埛鍚嶇О"))
-                {
-                    error += "娌℃湁鎵惧埌銆愬鎴峰悕绉般�戠殑鏍囬,";
-                }
-                if (!tb2.Columns.Contains("鐢ㄦ埛鍚嶇О"))
-                {
-                    error += "娌℃湁鎵惧埌銆愮敤鎴峰悕绉般�戠殑鏍囬,";
-                }
-                if (error.Length > 0)
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                //鏌ヨ鏁版嵁璧嬬粰鏁版嵁琛�
-                string err = "";
-                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
-                {
-                    string HCusNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀹㈡埛浠g爜"].ToString());
-                    string HCusName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀹㈡埛鍚嶇О"].ToString());
-                    string HUserName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐢ㄦ埛鍚嶇О"].ToString());
-                    int index = i + 1;
-                    string sql = "";
-                    if (HCusNumber != "" && HUserName != "")
-                    {
-                        //鑾峰彇瀹㈡埛鍐呯爜
-                        sql = "select * from Gy_Customer where HNumber = '" + HCusNumber + "'";
-                        string HCusID = "0";
-                        ds = oCN.RunProcReturn(sql, "Gy_Customer");
-                        if (ds.Tables[0].Rows.Count == 0)
-                        {
-                            err += "绗�" + index + "琛�,瀹㈡埛涓嶅瓨鍦�!";
-                            continue;
-                        }
-                        else
-                        {
-                            tb2.Rows[i]["HCusID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
-                            HCusID = ds.Tables[0].Rows[0]["HItemID"].ToString();
-                        }
-
-                        //鑾峰彇鐢ㄦ埛鍐呯爜
-                        sql = "select * from Gy_Czygl where Czymc = '" + HUserName + "'";
-                        string HUserID = "";
-                        ds = oCN.RunProcReturn(sql, "Gy_Czygl");
-                        if (ds.Tables[0].Rows.Count == 0)
-                        {
-                            err += "绗�" + index + "琛�,鐢ㄦ埛涓嶅瓨鍦�!";
-                            continue;
-                        }
-                        else
-                        {
-                            tb2.Rows[i]["HUserID"] = ds.Tables[0].Rows[0]["Czybm"].ToString();
-                            HUserID = ds.Tables[0].Rows[0]["Czybm"].ToString();
-                        }
-
-                        //鍒ゆ柇琛ㄤ腑鏄惁宸茬粡瀛樺湪璇ョ敤鎴峰叧鑱斿鎴�
-                        sql = "select * from Gy_UserCustomerRelation where HCusID = " + HCusID + " and HUserID = '" + HUserID + "'";
-                        ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
-                        if (ds.Tables[0].Rows.Count > 0)
-                        {
-                            err += "绗�" + index + "琛岋紝璇ョ敤鎴蜂笌瀹㈡埛宸茬粡鍏宠仈!";
-                            continue;
-                        }
-                    }
-                    else
-                    {
-                        err += "绗�" + index + "琛�,瀹㈡埛浠g爜鎴栫敤鎴峰悕绉颁负绌�!";
-                        continue;
-                    }
-                }
-                if (err.Length > 0)
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "瀵煎叆閿欒锛�" + err;
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                objJsonResult.code = "1";
-                objJsonResult.count = 1;
-                objJsonResult.Message = error;
-                objJsonResult.data = tb2;
-                return objJsonResult;
-            }
-            catch (Exception e)
-            {
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = "Exception锛�" + e.ToString();
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-        }
-        #endregion
-        #region 鐢ㄦ埛鍏宠仈瀹㈡埛 瀵煎叆(淇濆瓨)
-        [Route("Xt_User/Gy_UserCustomer_ImportByExcel_Save")]
-        [HttpPost]
-        public object Gy_UserCustomer_ImportByExcel_Save([FromBody] JObject sMainSub)
-        {
-            var _value = sMainSub["sMainSub"].ToString();
-            string msg1 = _value.ToString();
-            string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
-            string msg2 = sArray[0].ToString();
-            string user = sArray[1].ToString();
-            try
-            {
-                if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_Edit", 1, false, user))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犲鍏ユ潈闄愶紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
-                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
-
-                foreach (JObject item in Excel)
-                {
-                    Dictionary<string, string> dic = new Dictionary<string, string>();
-                    foreach (var itm in item.Properties())
-                    {
-                        dic.Add(itm.Name, itm.Value.ToString());
-                    }
-                    list.Add(dic);
-                }
-
-                oCN.BeginTran();
-                string err = "";
-                int i = 1;
-                string sql = "";
-                foreach (Dictionary<string, string> item in list)
-                {
-                    string HUserID = item["HUserID"].ToString();//渚涘簲鍟�
-                    string HUserName = item["鐢ㄦ埛鍚嶇О"].ToString();//鐗╂枡ID
-                    string HCusID = item["HCusID"].ToString();//缁勭粐ID
-                    string HCusNumber = item["瀹㈡埛浠g爜"].ToString();
-                    string HCusName = item["瀹㈡埛鍚嶇О"].ToString();
-
-                    sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID;
-                    ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
-                    if (ds.Tables[0].Rows.Count == 0)
-                    {
-                        sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" +
-                            "values(" +
-                            "'" + HUserID + "'" +
-                            "," + HCusID + "" +
-                            ")";
-                        oCN.RunProc(sql);
-                    }
-                    else
-                    {
-                        err += "绗�" + i + "琛岋細鐢ㄦ埛宸茬粡鍏宠仈璇ュ鎴�!";
-                    }
-                    i++;
-                }
-                //鍒ゆ柇鏄惁瀛樺湪閿欒
-                if (err.Length > 0)
-                {
-                    oCN.RollBack();
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "瀵煎叆閿欒锛�"+ err;
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                oCN.Commit();
-                objJsonResult.code = "1";
-                objJsonResult.count = 1;
-                objJsonResult.Message = "瀵煎叆鎴愬姛!";
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-            catch (Exception e)
-            {
-                LogService.Write(e);
-                oCN.RollBack();
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = "Exception锛�" + e.ToString();
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-        }
-        #endregion
-
-
         #region 鐢ㄦ埛鍏宠仈瀹㈡埛淇濆瓨
         [Route("Xt_User/SaveUserCustomer")]
         [HttpPost]
@@ -2017,6 +1979,775 @@
                 objJsonResult.count = 0;
                 objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
                 objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈瀹㈡埛 鏂囦欢涓婁紶
+        [Route("Xt_User/Gy_UserCustomer_ImportByExcel")]
+        [HttpPost]
+        public object Gy_UserCustomer_ImportByExcel()
+        {
+            try
+            {
+                //var WorkBookName = HttpContext.Current.Request["WorkBookName"];
+                //DBUtility.ClsPub.HOrgID = long.Parse(HttpContext.Current.Request["HOrgID"]);
+                //鑾峰彇鏂囦欢鍚嶇О
+                var file = HttpContext.Current.Request.Files[0];
+                //鑾峰彇鏂囦欢鐗╃悊璺緞
+                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
+                //淇濆瓨鏂囦欢
+                file.SaveAs(ExcelPath);
+
+                NpoiHelper np = new NpoiHelper();
+                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
+
+                //鍒犻櫎鏂囦欢
+                File.Delete(ExcelPath);
+
+                //鍒涘缓涓存椂琛�
+                DataTable tb2 = new DataTable("dt2");
+
+                //娣诲姞鍒楀悕
+                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
+                {
+                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
+                }
+
+                //妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁
+                tb2.Columns.Add("瀹㈡埛鍐呯爜", typeof(string));//瀹㈡埛鍐呯爜
+                tb2.Columns.Add("鍒ゅ畾缁撴灉", typeof(string));//鍒ゅ畾缁撴灉
+
+                //娣诲姞鏁版嵁
+                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
+                {
+                    DataRow row = tb2.NewRow();
+                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+                    {
+                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
+                    }
+                    tb2.Rows.Add(row);
+                }
+
+                //鏌ヨExcel鏂囦欢涓病鏈夌殑鍒�
+                var error = "";
+                if (!tb2.Columns.Contains("鐢ㄦ埛浠g爜"))
+                {
+                    error += "娌℃湁鎵惧埌銆愮敤鎴蜂唬鐮併�戠殑鏍囬,";
+                }
+                if (!tb2.Columns.Contains("鐢ㄦ埛鍚嶇О"))
+                {
+                    error += "娌℃湁鎵惧埌銆愮敤鎴峰悕绉般�戠殑鏍囬,";
+                }
+                if (!tb2.Columns.Contains("瀹㈡埛浠g爜"))
+                {
+                    error += "娌℃湁鎵惧埌銆愬鎴蜂唬鐮併�戠殑鏍囬,";
+                }
+                if (!tb2.Columns.Contains("瀹㈡埛鍚嶇О"))
+                {
+                    error += "娌℃湁鎵惧埌銆愬鎴峰悕绉般�戠殑鏍囬,";
+                }
+                if (!tb2.Columns.Contains("缁勭粐浠g爜"))
+                {
+                    error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,";
+                }
+                if (!tb2.Columns.Contains("缁勭粐鍚嶇О"))
+                {
+                    error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,";
+                }
+                if (error.Length > 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //鏌ヨ鏁版嵁璧嬬粰鏁版嵁琛�
+                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+                {
+                    string HUserID = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐢ㄦ埛浠g爜"].ToString());
+                    string HUserName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐢ㄦ埛鍚嶇О"].ToString());
+                    string HCusNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀹㈡埛浠g爜"].ToString());
+                    string HCusName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀹㈡埛鍚嶇О"].ToString());
+                    string HOrgNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+                    string HOrgName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString());
+                    int index = i + 1;
+                    //string sql = "";
+
+                    ////鍒ゅ畾鐢ㄦ埛鏄惁瀛樺湪骞惰缃暟鎹�
+                    //sql = "select * from Gy_Czygl where Czybm = '" + HUserID + "'";
+                    //ds = oCN.RunProcReturn(sql, "Gy_Czygl");
+                    //if (ds.Tables[0].Rows.Count > 0)
+                    //{
+                    //    tb2.Rows[i]["鐢ㄦ埛鍚嶇О"] = ds.Tables[0].Rows[0]["Czymc"];
+                    //}
+                    //else
+                    //{
+                    //    sql = "select * from Gy_Czygl where Czymc = '" + HUserName + "'";
+                    //    ds = oCN.RunProcReturn(sql, "Gy_Czygl");
+                    //    if (ds.Tables[0].Rows.Count > 0)
+                    //    {
+                    //        tb2.Rows[i]["鐢ㄦ埛浠g爜"] = ds.Tables[0].Rows[0]["Czybm"];
+                    //    }
+                    //}
+
+                    ////鍒ゅ畾瀹㈡埛鏄惁瀛樺湪骞惰缃暟鎹�
+                    //sql = "select c.HItemID 瀹㈡埛鍐呯爜,c.HNumber 瀹㈡埛浠g爜,c.HName 瀹㈡埛鍚嶇О,isnull(c.HUSEORGID,0) 缁勭粐鍐呯爜,isnull(o.HNumber,'') 缁勭粐浠g爜,isnull(o.Hname,'') 缁勭粐鍚嶇О from " +
+                    //    "Gy_Customer as c " +
+                    //    "left join Xt_ORGANIZATIONS o on c.HUSEORGID = o.HItemID " +
+                    //    "where " +
+                    //        "c.HNumber = '" + HCusNumber + "' " +
+                    //        "and isnull(o.HNumber,'')<>'' and isnull(o.HNumber,'') = '" + HOrgNumber + "'";
+                    //ds = oCN.RunProcReturn(sql, "Gy_Customer");
+                    //if(ds.Tables[0].Rows.Count > 0)
+                    //{
+                    //    tb2.Rows[i]["瀹㈡埛鍐呯爜"] = ds.Tables[0].Rows[0]["瀹㈡埛鍐呯爜"];
+                    //    tb2.Rows[i]["瀹㈡埛鍚嶇О"] = ds.Tables[0].Rows[0]["瀹㈡埛鍚嶇О"];
+                    //    tb2.Rows[i]["缁勭粐鍚嶇О"] = ds.Tables[0].Rows[0]["缁勭粐鍚嶇О"];
+                    //}
+                    //else
+                    //{
+                    //    sql = "select c.HItemID 瀹㈡埛鍐呯爜,c.HNumber 瀹㈡埛浠g爜,c.HName 瀹㈡埛鍚嶇О,isnull(c.HUSEORGID,0) 缁勭粐鍐呯爜,isnull(o.HNumber,'') 缁勭粐浠g爜,isnull(o.Hname,'') 缁勭粐鍚嶇О from " +
+                    //    "Gy_Customer as c " +
+                    //    "left join Xt_ORGANIZATIONS o on c.HUSEORGID = o.HItemID " +
+                    //    "where " +
+                    //        "c.HNumber = '" + HCusNumber + "' " +
+                    //        "and isnull(o.HName,'')<>'' and isnull(o.HName,'') = '" + HOrgName + "'";
+                    //    ds = oCN.RunProcReturn(sql, "Gy_Customer");
+                    //    if (ds.Tables[0].Rows.Count > 0)
+                    //    {
+                    //        tb2.Rows[i]["瀹㈡埛鍐呯爜"] = ds.Tables[0].Rows[0]["瀹㈡埛鍐呯爜"];
+                    //        tb2.Rows[i]["瀹㈡埛鍚嶇О"] = ds.Tables[0].Rows[0]["瀹㈡埛鍚嶇О"];
+                    //        tb2.Rows[i]["缁勭粐浠g爜"] = ds.Tables[0].Rows[0]["缁勭粐浠g爜"];
+                    //    }
+                    //}
+
+                    tb2.Rows[i]["鍒ゅ畾缁撴灉"] = "";
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = error;
+                objJsonResult.data = tb2;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+        #region 鐢ㄦ埛鍏宠仈瀹㈡埛 瀵煎叆(鏁版嵁楠岃瘉)
+        [Route("Xt_User/Gy_UserCustomer_ImportByExcel_Confirm")]
+        [HttpPost]
+        public object Gy_UserCustomer_ImportByExcel_Confirm([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            string[] importFieldList = sArray[2].ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            try
+            {
+                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+                foreach (JObject item in Excel)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+                //鍒涘缓涓存椂琛ㄥ苟璁剧疆鍒楀悕
+                DataTable tb2 = new DataTable("dt2");
+                tb2.Columns.Add("鐢ㄦ埛浠g爜", typeof(string));
+                tb2.Columns.Add("鐢ㄦ埛鍚嶇О", typeof(string));
+                tb2.Columns.Add("瀹㈡埛鍐呯爜", typeof(string));
+                tb2.Columns.Add("瀹㈡埛浠g爜", typeof(string));
+                tb2.Columns.Add("瀹㈡埛鍚嶇О", typeof(string));
+                tb2.Columns.Add("缁勭粐浠g爜", typeof(string));
+                tb2.Columns.Add("缁勭粐鍚嶇О", typeof(string));
+                tb2.Columns.Add("鍒ゅ畾缁撴灉", typeof(string));
+
+                string error = "";
+                int i = 1;
+                string sql = "";
+                foreach (Dictionary<string, string> item in list)
+                {
+                    //璁板綍鍒ゅ畾缁撴灉
+                    string err = "";
+
+                    DataRow row = tb2.NewRow();
+                    tb2.Rows.Add(row);
+                    string HUserID = item["鐢ㄦ埛浠g爜"].ToString();
+                    string HUserName = item["鐢ㄦ埛鍚嶇О"].ToString();
+                    string HCusID = item["瀹㈡埛鍐呯爜"].ToString();
+                    string HCusNumber = item["瀹㈡埛浠g爜"].ToString();
+                    string HCusName = item["瀹㈡埛鍚嶇О"].ToString();
+                    string HOrgNumber = item["缁勭粐浠g爜"].ToString();
+                    string HOrgName = item["缁勭粐鍚嶇О"].ToString();
+
+                    tb2.Rows[i - 1]["鐢ㄦ埛浠g爜"] = HUserID;
+                    tb2.Rows[i - 1]["鐢ㄦ埛鍚嶇О"] = HUserName;
+                    tb2.Rows[i - 1]["瀹㈡埛鍐呯爜"] = HCusID;
+                    tb2.Rows[i - 1]["瀹㈡埛浠g爜"] = HCusNumber;
+                    tb2.Rows[i - 1]["瀹㈡埛鍚嶇О"] = HCusName;
+                    tb2.Rows[i - 1]["缁勭粐浠g爜"] = HOrgNumber;
+                    tb2.Rows[i - 1]["缁勭粐鍚嶇О"] = HOrgName;
+                    tb2.Rows[i - 1]["鍒ゅ畾缁撴灉"] = "";
+
+                    //鏍规嵁瀵煎叆瀛楁鑾峰彇鐢ㄦ埛鐩稿叧鏁版嵁锛屽苟杩涜鏍¢獙
+                    sql = "";
+                    if (importFieldList[0] == "HUserID")
+                    {
+                        sql = "select * from Gy_Czygl where Czybm = '" + HUserID + "'";
+                    }
+                    else if(importFieldList[0] == "HUserName")
+                    {
+                        sql = "select * from Gy_Czygl where Czymc = '" + HUserName + "'";
+                    }
+                    ds = oCN.RunProcReturn(sql, "Gy_Czygl");
+                    if (ds.Tables[0].Rows.Count == 0)
+                    {
+                        err += "鐢ㄦ埛涓嶅瓨鍦紱";
+                    }
+                    else
+                    {
+                        tb2.Rows[i - 1]["鐢ㄦ埛浠g爜"] = ds.Tables[0].Rows[0]["Czybm"];
+                        tb2.Rows[i - 1]["鐢ㄦ埛鍚嶇О"] = ds.Tables[0].Rows[0]["Czymc"];
+
+                        HUserID = ds.Tables[0].Rows[0]["Czybm"].ToString();
+                        HUserName = ds.Tables[0].Rows[0]["Czymc"].ToString();
+                    }
+
+                    //鏍规嵁瀵煎叆瀛楁鑾峰彇瀹㈡埛鐩稿叧鏁版嵁锛屽苟杩涜鏍¢獙
+                    sql = "";
+                    if (importFieldList[1] == "HOrgNumber")
+                    {
+                        sql = "select * from Xt_ORGANIZATIONS where HNumber = '" + HOrgNumber + "'";
+                    }
+                    else if (importFieldList[1] == "HOrgName")
+                    {
+                        sql = "select * from Xt_ORGANIZATIONS where HName = '" + HOrgName + "'";
+                    }
+                    ds = oCN.RunProcReturn(sql, "Xt_ORGANIZATIONS");
+                    if (ds.Tables[0].Rows.Count == 0)
+                    {
+                        err += "缁勭粐涓嶅瓨鍦紱";
+
+                        HCusID = "0";
+                        tb2.Rows[i - 1]["瀹㈡埛鍐呯爜"] = "0";
+                    }
+                    else
+                    {
+                        tb2.Rows[i - 1]["缁勭粐浠g爜"] = ds.Tables[0].Rows[0]["HNumber"];
+                        tb2.Rows[i - 1]["缁勭粐鍚嶇О"] = ds.Tables[0].Rows[0]["HName"];
+
+                        sql = "select c.* from " +
+                        "Gy_Customer as c " +
+                        "left join Xt_ORGANIZATIONS o on c.HUSEORGID = o.HItemID " +
+                        "where c.HNumber = '" + HCusNumber + "' " +
+                        "and o.HNumber = '" + ds.Tables[0].Rows[0]["HNumber"] + "' " +
+                        "and o.HName = '" + ds.Tables[0].Rows[0]["HName"] + "'";
+                        ds = oCN.RunProcReturn(sql, "Gy_Customer");
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            err += "璇ョ粍缁囦笅瀹㈡埛涓嶅瓨鍦紱";
+                            HCusID = "0";
+                            tb2.Rows[i - 1]["瀹㈡埛鍐呯爜"] = "0";
+                        }
+                        else
+                        {
+                            tb2.Rows[i - 1]["瀹㈡埛鍐呯爜"] = ds.Tables[0].Rows[0]["HItemID"];
+                            tb2.Rows[i - 1]["瀹㈡埛浠g爜"] = ds.Tables[0].Rows[0]["HNumber"];
+                            tb2.Rows[i - 1]["瀹㈡埛鍚嶇О"] = ds.Tables[0].Rows[0]["HName"];
+
+                            HCusID = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+                    }
+
+                    //鍒ゅ畾璇ョ敤鎴蜂笌瀹㈡埛鏄惁宸茬粡鍏宠仈
+                    sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID;
+                    ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                    if (ds.Tables[0].Rows.Count > 0)
+                    {
+                        err += "鐢ㄦ埛宸茬粡鍏宠仈璇ュ鎴凤紱";
+                    }
+
+                    tb2.Rows[i - 1]["鍒ゅ畾缁撴灉"] = err;
+                    error += err;
+
+                    i++;
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = (error.Length>0?"0":"1");
+                objJsonResult.data = tb2;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e);
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+        #region 鐢ㄦ埛鍏宠仈瀹㈡埛 瀵煎叆(淇濆瓨)
+        [Route("Xt_User/Gy_UserCustomer_ImportByExcel_Save")]
+        [HttpPost]
+        public object Gy_UserCustomer_ImportByExcel_Save([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            string saveType = sArray[2].ToString();
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲鍏ユ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+                foreach (JObject item in Excel)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+                if(saveType == "1")
+                {
+                    oCN.BeginTran();
+                    string err = "";
+                    int i = 1;
+                    string sql = "";
+                    foreach (Dictionary<string, string> item in list)
+                    {
+                        string HUserID = item["鐢ㄦ埛浠g爜"].ToString();//渚涘簲鍟�
+                        string HUserName = item["鐢ㄦ埛鍚嶇О"].ToString();//鐗╂枡ID
+                        string HCusID = item["瀹㈡埛鍐呯爜"].ToString();//缁勭粐ID
+                        string HCusNumber = item["瀹㈡埛浠g爜"].ToString();
+                        string HCusName = item["瀹㈡埛鍚嶇О"].ToString();
+                        string HOrgNumber = item["缁勭粐浠g爜"].ToString();
+                        string HOrgName = item["缁勭粐鍚嶇О"].ToString();
+
+                        sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID;
+                        ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" +
+                                "values(" +
+                                "'" + HUserID + "'" +
+                                "," + HCusID + "" +
+                                ")";
+                            oCN.RunProc(sql);
+                        }
+                        else
+                        {
+                            
+                        }
+                        i++;
+                    }
+                }else if(saveType == "2")
+                {
+                    oCN.BeginTran();
+                    string err = "";
+                    int i = 1;
+                    string sql = "";
+                    foreach (Dictionary<string, string> item in list)
+                    {
+                        string HUserID = item["鐢ㄦ埛浠g爜"].ToString();//渚涘簲鍟�
+                        string HUserName = item["鐢ㄦ埛鍚嶇О"].ToString();//鐗╂枡ID
+                        string HCusID = item["瀹㈡埛鍐呯爜"].ToString();//缁勭粐ID
+                        string HCusNumber = item["瀹㈡埛浠g爜"].ToString();
+                        string HCusName = item["瀹㈡埛鍚嶇О"].ToString();
+                        string HOrgNumber = item["缁勭粐浠g爜"].ToString();
+                        string HOrgName = item["缁勭粐鍚嶇О"].ToString();
+
+                        sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID;
+                        ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" +
+                                "values(" +
+                                "'" + HUserID + "'" +
+                                "," + HCusID + "" +
+                                ")";
+                            oCN.RunProc(sql);
+                        }
+                        else
+                        {
+                            err += "绗�" + i + "琛岋細鐢ㄦ埛宸茬粡鍏宠仈璇ュ鎴�!";
+                        }
+                        i++;
+                    }
+                    //鍒ゆ柇鏄惁瀛樺湪閿欒
+                    if (err.Length > 0)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀵煎叆閿欒锛�" + err;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "瀵煎叆鎴愬姛!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e);
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈瀹㈡埛缁存姢鍒楄〃
+        /// <summary>
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserRelationCustomerlist")]
+        [HttpGet]
+        public object UserRelationCustomerlist(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql = "";
+
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    sql = "select * from h_v_Gy_UserCustomerRelationList_Query order by 鐢ㄦ埛浠g爜 asc,瀹㈡埛浠g爜 asc";
+                    ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                }
+                else
+                {
+                    sql = "select * from h_v_Gy_UserCustomerRelationList_Query where 1=1 ";
+                    sql = sql + sWhere + " order by 鐢ㄦ埛浠g爜 asc,瀹㈡埛浠g爜 asc";
+                    ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                }
+
+                //娣诲姞鍒楀悕
+                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.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+        #region 鐢ㄦ埛鍏宠仈瀹㈡埛缁存姢 鍒犻櫎
+        /// <summary>
+        ///鍙傛暟锛歴tring HInterID銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserRelationCustomerlist_Drop")]
+        [HttpGet]
+        public object UserRelationCustomerlist_Drop(string HInterID, string user)
+        {
+            try
+            {
+                string s = "";
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (HInterID == null || HInterID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "delete from Gy_UserCustomerRelation where HItemID = " + HInterID;
+                oCN.RunProc(sql);
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+        #region 鐢ㄦ埛鍏宠仈瀹㈡埛缁存姢 缂栬緫鍒濆鍖�
+        /// <summary>
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserRelationCustomerlist_EditInit")]
+        [HttpGet]
+        public object UserRelationCustomerlist_EditInit(int HItemID, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql = "select * from h_v_Gy_UserCustomerRelationList_Query where HItemID = " + HItemID;
+                ds = oCN.RunProcReturn(sql, "h_v_Gy_UserCustomerRelationList_Query");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+        #region 鐢ㄦ埛鍏宠仈瀹㈡埛缁存姢 淇濆瓨
+        [Route("Xt_User/UserRelationCustomerlist_Save")]
+        [HttpPost]
+        public object UserRelationCustomerlist_Save([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            string saveType = sArray[2].ToString();
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+                foreach (JObject item in Excel)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+                if (saveType == "1")
+                {
+                    oCN.BeginTran();
+                    string err = "";
+                    int i = 1;
+                    string sql = "";
+                    foreach (Dictionary<string, string> item in list)
+                    {
+                        string HItemID = item["HItemID"].ToString();        //
+                        string HUserID = item["HUserID"].ToString();        //鐢ㄦ埛浠g爜
+                        string HUserName = item["HUserName"].ToString();    //鐢ㄦ埛鍚嶇О
+                        string HCusID = item["HCusID"].ToString();          //瀹㈡埛鍐呯爜
+                        string HCusNumber = item["HCusNumber"].ToString();  //瀹㈡埛浠g爜
+                        string HCusName = item["HCusName"].ToString();      //瀹㈡埛鍚嶇О
+
+
+                        sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID;
+                        ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" +
+                                "values(" +
+                                "'" + HUserID + "'" +
+                                "," + HCusID + "" +
+                                ")";
+                            oCN.RunProc(sql);
+                        }
+                        else
+                        {
+                            err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + HUserName + "銆戝凡缁忓叧鑱斿鎴枫��" + HCusName + "銆�";
+                        }
+                        i++;
+                    }
+                    //鍒ゆ柇鏄惁瀛樺湪閿欒
+                    if (err.Length > 0)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛�" + err;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else if (saveType == "3")
+                {
+                    oCN.BeginTran();
+                    string err = "";
+                    int i = 1;
+                    string sql = "";
+                    foreach (Dictionary<string, string> item in list)
+                    {
+                        string HItemID = item["HItemID"].ToString();        //
+                        string HUserID = item["HUserID"].ToString();        //鐢ㄦ埛浠g爜
+                        string HUserName = item["HUserName"].ToString();    //鐢ㄦ埛鍚嶇О
+                        string HCusID = item["HCusID"].ToString();          //瀹㈡埛鍐呯爜
+                        string HCusNumber = item["HCusNumber"].ToString();  //瀹㈡埛浠g爜
+                        string HCusName = item["HCusName"].ToString();      //瀹㈡埛鍚嶇О
+
+                        sql = "select * from Gy_UserCustomerRelation where HItemID = " + HItemID;
+                        ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                        if (ds.Tables[0].Rows.Count > 0)
+                        {
+                            sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID + " and HItemID <> " + HItemID;
+                            ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                            if(ds.Tables[0].Rows.Count == 0)
+                            {
+                                sql = "update Gy_UserCustomerRelation set " +
+                                      "HUserID = '" + HUserID + "' " +
+                                      ",HCusID = " + HCusID + " " +
+                                      "where HItemID = " + HItemID;
+                                oCN.RunProc(sql);
+                            }
+                            else
+                            {
+                                err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + HUserName + "銆戝凡缁忓叧鑱斿鎴枫��" + HCusName + "銆�";
+                            }
+                        }
+                        else
+                        {
+                            err += "绗�" + i + "琛岋細璁板綍涓嶅瓨鍦�!";
+                        }
+                        i++;
+                    }
+                    //鍒ゆ柇鏄惁瀛樺湪閿欒
+                    if (err.Length > 0)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛�" + err;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e);
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
                 return objJsonResult;
             }
         }
@@ -2299,8 +3030,8 @@
                     string HProcID = item["HProcID"].ToString();//宸ュ簭ID
                     string HUserID = item["鐢ㄦ埛浠g爜"].ToString();//鐢ㄦ埛浠g爜
                     string czymc = item["鐢ㄦ埛鍚嶇О"].ToString();//鐢ㄦ埛鍚嶇О
-                    string HNumber = item["宸ュ簭浠g爜"].ToString();//渚涘簲鍟嗕唬鐮�
-                    string HName = item["宸ュ簭鍚嶇О"].ToString();//渚涘簲鍟嗗悕绉�
+                    string HNumber = item["宸ュ簭浠g爜"].ToString();//宸ュ簭浠g爜
+                    string HName = item["宸ュ簭鍚嶇О"].ToString();//宸ュ簭鍚嶇О
 
                     var ds = oCN.RunProcReturn("select * from Gy_UserByProcess where  HProcID='" + HProcID + "'and HUserID='" + HUserID + "'", "Gy_UserByProcess");
 
@@ -2341,5 +3072,109 @@
             }
         }
         #endregion
+
+        #region  鐢ㄦ埛鍏宠仈宸ュ簭鍒楄〃鏌ヨ
+        [Route("Xt_User/UserProcesslist")]
+        [HttpGet]
+        public object UserProcesslist(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserProcessList_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql1 = "select * from h_v_Gy_UserProcess where 1 = 1";
+                string sql = sql1 + sWhere + " order by 鐢ㄦ埛浠g爜 ";
+                ds = oCN.RunProcReturn(sql, "h_v_Gy_UserProcess");
+
+                //娣诲姞鍒楀悕
+                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.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈宸ュ簭鍒楄〃 鍒犻櫎
+        /// <summary>
+        ///鍙傛暟锛歴tring HInterID銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/Gy_UserProcessDrop")]
+        [HttpGet]
+        public object Gy_UserProcessDrop(string HItemID, string user)
+        {
+            try
+            {
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserProcessList_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                if (HItemID == null || HItemID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "delete from Gy_UserByProcess where HItemID = " + HItemID;
+                oCN.RunProc(sql);
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                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