|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  | #region 用户关联客户保存 | 
|---|
|  |  |  | [Route("Xt_User/SaveUserCustomer")] | 
|---|
|  |  |  | [HttpPost] | 
|---|
|  |  |  | public object SaveUserCustomer([FromBody] JObject msg) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var _value = msg["msg"].ToString(); | 
|---|
|  |  |  | string msg1 = _value.ToString(); | 
|---|
|  |  |  | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
|---|
|  |  |  | string msg2 = sArray[0].ToString(); | 
|---|
|  |  |  | string msg3 = sArray[1].ToString(); | 
|---|
|  |  |  | string msg4 = sArray[2].ToString(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log_second("Gy_UserRelationCustomer_Edit", 1, false, msg4)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "无编辑权限!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ListModels oListModels = new ListModels(); | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<Models.Gy_UserCustomer> lsmain = new List<Models.Gy_UserCustomer>(); | 
|---|
|  |  |  | msg2 = msg2.Substring(1, msg2.Length - 2); | 
|---|
|  |  |  | msg2 = msg2.Replace("\\", ""); | 
|---|
|  |  |  | msg2 = msg2.Replace("\n", "");  //\n | 
|---|
|  |  |  | lsmain = oListModels.getObjectByJson_Gy_UserCustomer(msg2); | 
|---|
|  |  |  | oCN.BeginTran(); | 
|---|
|  |  |  | //删除已经关联的数据 | 
|---|
|  |  |  | oCN.RunProc("Delete From Gy_UserCustomerRelation  where HUserID='" + msg3.ToString() + "'"); | 
|---|
|  |  |  | foreach (Models.Gy_UserCustomer oItem in lsmain) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //重新写入关联数据 | 
|---|
|  |  |  | oCN.RunProc("insert into Gy_UserCustomerRelation (HCusID,HUserID) values ('" + oItem.HCusID + "','" + msg3.ToString() + "')"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | oCN.Commit(); | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "保存成功!"; | 
|---|
|  |  |  | //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); | 
|---|
|  |  |  | objJsonResult.data = 1; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "保存失败!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = 1; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 用户关联客户 文件上传 | 
|---|
|  |  |  | [Route("Xt_User/Gy_UserCustomer_ImportByExcel")] | 
|---|
|  |  |  | [HttpPost] | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 用户关联客户保存 | 
|---|
|  |  |  | [Route("Xt_User/SaveUserCustomer")] | 
|---|
|  |  |  | [HttpPost] | 
|---|
|  |  |  | public object SaveUserCustomer([FromBody] JObject msg) | 
|---|
|  |  |  | #region 用户关联客户维护列表 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | ///参数:string sql。 | 
|---|
|  |  |  | ///返回值:object。 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Route("Xt_User/UserRelationCustomerlist")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object UserRelationCustomerlist(string sWhere, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var _value = msg["msg"].ToString(); | 
|---|
|  |  |  | string msg1 = _value.ToString(); | 
|---|
|  |  |  | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
|---|
|  |  |  | string msg2 = sArray[0].ToString(); | 
|---|
|  |  |  | string msg3 = sArray[1].ToString(); | 
|---|
|  |  |  | string msg4 = sArray[2].ToString(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log_second("Gy_UserRelationCustomer_Edit", 1, false, msg4)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "无编辑权限!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ListModels oListModels = new ListModels(); | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<Models.Gy_UserCustomer> lsmain = new List<Models.Gy_UserCustomer>(); | 
|---|
|  |  |  | msg2 = msg2.Substring(1, msg2.Length - 2); | 
|---|
|  |  |  | msg2 = msg2.Replace("\\", ""); | 
|---|
|  |  |  | msg2 = msg2.Replace("\n", "");  //\n | 
|---|
|  |  |  | lsmain = oListModels.getObjectByJson_Gy_UserCustomer(msg2); | 
|---|
|  |  |  | oCN.BeginTran(); | 
|---|
|  |  |  | //删除已经关联的数据 | 
|---|
|  |  |  | oCN.RunProc("Delete From Gy_UserCustomerRelation  where HUserID='" + msg3.ToString() + "'"); | 
|---|
|  |  |  | foreach (Models.Gy_UserCustomer oItem in lsmain) | 
|---|
|  |  |  | List<object> columnNameList = new List<object>(); | 
|---|
|  |  |  | //查看权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_Query", 1, false, user)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //重新写入关联数据 | 
|---|
|  |  |  | oCN.RunProc("insert into Gy_UserCustomerRelation (HCusID,HUserID) values ('" + oItem.HCusID + "','" + msg3.ToString() + "')"); | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "无查看权限!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | oCN.Commit(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string sql = ""; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (sWhere == null || sWhere.Equals("")) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | sql = "select * from h_v_Gy_UserCustomerRelationList_Query order by 用户代码 asc,客户代码 asc"; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | sql = "select * from h_v_Gy_UserCustomerRelationList_Query where 1=1 "; | 
|---|
|  |  |  | sql = sql + sWhere + " order by 用户代码 asc,客户代码 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));//获取到DataColumn列对象的列名 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "保存成功!"; | 
|---|
|  |  |  | //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); | 
|---|
|  |  |  | objJsonResult.data = 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 = "保存失败!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = 1; | 
|---|
|  |  |  | objJsonResult.Message = "Exception!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  | #region 用户关联客户维护 删除 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | ///参数:string 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> | 
|---|
|  |  |  | ///参数:string 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();        //用户代码 | 
|---|
|  |  |  | string HUserName = item["HUserName"].ToString();    //用户名称 | 
|---|
|  |  |  | string HCusID = item["HCusID"].ToString();          //客户内码 | 
|---|
|  |  |  | string HCusNumber = item["HCusNumber"].ToString();  //客户代码 | 
|---|
|  |  |  | 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();        //用户代码 | 
|---|
|  |  |  | string HUserName = item["HUserName"].ToString();    //用户名称 | 
|---|
|  |  |  | string HCusID = item["HCusID"].ToString();          //客户内码 | 
|---|
|  |  |  | string HCusNumber = item["HCusNumber"].ToString();  //客户代码 | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | string HProcID = item["HProcID"].ToString();//工序ID | 
|---|
|  |  |  | string HUserID = item["用户代码"].ToString();//用户代码 | 
|---|
|  |  |  | string czymc = item["用户名称"].ToString();//用户名称 | 
|---|
|  |  |  | string HNumber = item["工序代码"].ToString();//供应商代码 | 
|---|
|  |  |  | string HName = item["工序名称"].ToString();//供应商名称 | 
|---|
|  |  |  | string HNumber = item["工序代码"].ToString();//工序代码 | 
|---|
|  |  |  | string HName = item["工序名称"].ToString();//工序名称 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var ds = oCN.RunProcReturn("select * from Gy_UserByProcess where  HProcID='" + HProcID + "'and HUserID='" + HUserID + "'", "Gy_UserByProcess"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region  用户关联工序列表查询 | 
|---|
|  |  |  | [Route("Xt_User/UserProcesslist")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object UserProcesslist(string sWhere, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<object> columnNameList = new List<object>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string sql1 = "select * from h_v_Gy_UserProcess where 1 = 1"; | 
|---|
|  |  |  | string sql = sql1 + sWhere + " order by 用户代码 "; | 
|---|
|  |  |  | 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));//获取到DataColumn列对象的列名 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|