|  |  | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  |         #region 用户关联组织维护列表 | 
 |  |  |         /// <summary> | 
 |  |  |         ///参数:string sql。 | 
 |  |  |         ///返回值:object。 | 
 |  |  |         /// </summary> | 
 |  |  |         [Route("Xt_User/UserRelationOrganizationList")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object UserRelationOrganizationList(string sWhere, string user) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 List<object> columnNameList = new List<object>(); | 
 |  |  |                 //查看权限 | 
 |  |  |                 //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationOrganization_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_UserOrganizationRelationList_Query order by 用户代码 asc,组织代码 asc"; | 
 |  |  |                     ds = oCN.RunProcReturn(sql, "h_v_Gy_UserOrganizationRelationList_Query"); | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     sql = "select * from h_v_Gy_UserOrganizationRelationList_Query where 1=1 "; | 
 |  |  |                     sql = sql + sWhere + " order by 用户代码 asc,组织代码 asc"; | 
 |  |  |                     ds = oCN.RunProcReturn(sql, "h_v_Gy_UserOrganizationRelationList_Query"); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //添加列名 | 
 |  |  |                 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 | 
 |  |  |         #region 用户关联组织维护 删除 | 
 |  |  |         /// <summary> | 
 |  |  |         ///参数:string HInterID。 | 
 |  |  |         ///返回值:object。 | 
 |  |  |         /// </summary> | 
 |  |  |         [Route("Xt_User/UserRelationOrganizationlist_Drop")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object UserRelationOrganizationlist_Drop(string HInterID, string user) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 string s = ""; | 
 |  |  |  | 
 |  |  |                 //查看权限 | 
 |  |  |                 //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationOrganization_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_UserORGRelation 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/UserRelationOrganizationList_EditInit")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object UserRelationOrganizationList_EditInit(int HItemID, string user) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 List<object> columnNameList = new List<object>(); | 
 |  |  |                 //查看权限 | 
 |  |  |                 //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationOrganization_Query", 1, false, user)) | 
 |  |  |                 //{ | 
 |  |  |                 //    objJsonResult.code = "0"; | 
 |  |  |                 //    objJsonResult.count = 0; | 
 |  |  |                 //    objJsonResult.Message = "无查看权限!"; | 
 |  |  |                 //    objJsonResult.data = null; | 
 |  |  |                 //    return objJsonResult; | 
 |  |  |                 //} | 
 |  |  |  | 
 |  |  |                 string sql = "select * from h_v_Gy_UserOrganizationRelationList_Query where HItemID = " + HItemID; | 
 |  |  |                 ds = oCN.RunProcReturn(sql, "h_v_Gy_UserOrganizationRelationList_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/UserRelationOrganizationList_Save")] | 
 |  |  |         [HttpPost] | 
 |  |  |         public object UserRelationOrganizationList_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_UserRelationOrganization_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 HOrgID = item["HOrgID"].ToString();          //组织内码 | 
 |  |  |                         string HOrgNumber = item["HOrgNumber"].ToString();  //组织代码 | 
 |  |  |                         string HOrgName = item["HOrgName"].ToString();      //组织名称 | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                         sql = "select * from Gy_UserORGRelation where HUserID = '" + HUserID + "' and HOrgID = " + HOrgID; | 
 |  |  |                         ds = oCN.RunProcReturn(sql, "Gy_UserORGRelation"); | 
 |  |  |                         if (ds.Tables[0].Rows.Count == 0) | 
 |  |  |                         { | 
 |  |  |                             sql = "insert into Gy_UserORGRelation(HUserID,HOrgID)" + | 
 |  |  |                                 "values(" + | 
 |  |  |                                 "'" + HUserID + "'" + | 
 |  |  |                                 "," + HOrgID + "" + | 
 |  |  |                                 ")"; | 
 |  |  |                             oCN.RunProc(sql); | 
 |  |  |                         } | 
 |  |  |                         else | 
 |  |  |                         { | 
 |  |  |                             err += "第" + i + "行:用户【" + HUserName + "】已经关联组织【" + HOrgName + "】"; | 
 |  |  |                         } | 
 |  |  |                         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 HOrgID = item["HOrgID"].ToString();          //组织内码 | 
 |  |  |                         string HOrgNumber = item["HOrgNumber"].ToString();  //组织代码 | 
 |  |  |                         string HOrgName = item["HOrgName"].ToString();      //组织名称 | 
 |  |  |  | 
 |  |  |                         sql = "select * from Gy_UserORGRelation where HItemID = " + HItemID; | 
 |  |  |                         ds = oCN.RunProcReturn(sql, "Gy_UserORGRelation"); | 
 |  |  |                         if (ds.Tables[0].Rows.Count > 0) | 
 |  |  |                         { | 
 |  |  |                             sql = "select * from Gy_UserORGRelation where HUserID = '" + HUserID + "' and HOrgID = " + HOrgID + " and HItemID <> " + HItemID; | 
 |  |  |                             ds = oCN.RunProcReturn(sql, "Gy_UserORGRelation"); | 
 |  |  |                             if (ds.Tables[0].Rows.Count == 0) | 
 |  |  |                             { | 
 |  |  |                                 sql = "update Gy_UserORGRelation set " + | 
 |  |  |                                       "HUserID = '" + HUserID + "' " + | 
 |  |  |                                       ",HOrgID = " + HOrgID + " " + | 
 |  |  |                                       "where HItemID = " + HItemID; | 
 |  |  |                                 oCN.RunProc(sql); | 
 |  |  |                             } | 
 |  |  |                             else | 
 |  |  |                             { | 
 |  |  |                                 err += "第" + i + "行:用户【" + HUserName + "】已经关联组织【" + HOrgName + "】"; | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                         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/UserStocklistPlaylist")] | 
 |  |  |         [HttpGet] |