|  |  |  | 
|---|
|  |  |  | using Newtonsoft.Json; | 
|---|
|  |  |  | using Newtonsoft.Json.Linq; | 
|---|
|  |  |  | using Pub_Class; | 
|---|
|  |  |  | using SyntacticSugar.constant; | 
|---|
|  |  |  | using System; | 
|---|
|  |  |  | using System.Collections; | 
|---|
|  |  |  | using System.Collections.Generic; | 
|---|
|  |  |  | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取当前用户身份列表 | 
|---|
|  |  |  | string sql = "select HLev from System_UserGroupInfo u " + | 
|---|
|  |  |  | " left join System_UserGroup r " + | 
|---|
|  |  |  | "on u.GroupId = r.GroupID where u.UserId = '" + HCzybm + "'"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //用户身份判断 | 
|---|
|  |  |  | DataSet hLev = oCN.RunProcReturn(sql, "System_UserGroupInfo"); | 
|---|
|  |  |  | foreach(DataRow dr in hLev.Tables[0].Rows) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (!dr["HLev"].Equals(RoleConstant.EMPLOYEE)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = CodeConstant.FAIL; | 
|---|
|  |  |  | objJsonResult.count = CountConstant.FAIL; | 
|---|
|  |  |  | objJsonResult.Message = "管理员身份不允许删除!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.BeginTran(); | 
|---|
|  |  |  | //删除用户信息 | 
|---|
|  |  |  | oCN.RunProc("delete from  Gy_Czygl where Czybm='" + HCzybm + "'"); | 
|---|
|  |  |  | 
|---|
|  |  |  | ",HWhID,HWHName,HSupID,HSupName " + | 
|---|
|  |  |  | ",HSCWHID,HSCWHName " + | 
|---|
|  |  |  | ",HCloudUserName,HCloudUserPsd,HUSEORGID,HProcID" + | 
|---|
|  |  |  | ",HGroupID,HSourceID) " + | 
|---|
|  |  |  | ",HGroupID,HSourceID,HCheckEmpID,HWorkCenterID,HICNumber,HDingDingUserID) " + | 
|---|
|  |  |  | "values ('" + lsmain[0].Czybm.ToString() + "','" + lsmain[0].Czymc.ToString() + "','" + ClsPub.StrToPsd(lsmain[0].Czmm.ToString()) + "','" + lsmain[0].Explain.ToString() + "','" + lsmain[0].HEmpID.ToString() + "',"+ lsmain[0].HK3UserID.ToString() + "" + | 
|---|
|  |  |  | ","+ lsmain[0].HKeeperID.ToString() + ",'"+ lsmain[0].HKeeper.ToString() + "',"+ lsmain[0].HSecManagerID.ToString() + ",'"+ lsmain[0].HSecManager.ToString() + "'" + | 
|---|
|  |  |  | "," + lsmain[0].HSellManID.ToString() + ",'" + lsmain[0].HSellMan.ToString() + "'," + lsmain[0].HDeptID.ToString() + ",'" + lsmain[0].HDept.ToString() + "'" + | 
|---|
|  |  |  | "," + lsmain[0].HWhID.ToString() + ",'" + lsmain[0].HWHName.ToString() + "'," + lsmain[0].HSupID.ToString() + ",'" + lsmain[0].HSupName.ToString() + "'" + | 
|---|
|  |  |  | "," + lsmain[0].HSCWHID.ToString() + ",'" + lsmain[0].HSCWHName.ToString() + "'" + | 
|---|
|  |  |  | ",'" + lsmain[0].HCloudUserName.ToString() + "','" + lsmain[0].HCloudUserPsd.ToString() + "',"+ lsmain[0].HOrgID.ToString() + "," + lsmain[0].HProcID.ToString() + "" + | 
|---|
|  |  |  | ","+ lsmain[0].HGroupID.ToString() + ","+ lsmain[0].HSourceID.ToString() + ")"); | 
|---|
|  |  |  | ","+ lsmain[0].HGroupID.ToString() + ","+ lsmain[0].HSourceID.ToString() + "," + lsmain[0].HCheckEmpID.ToString() + "," + lsmain[0].HWorkCenterID.ToString() + ",'" + lsmain[0].HICNumber + "','" + lsmain[0].HDingDingUserID + "'" + ")"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //新增后查询  确保数据添加成功 | 
|---|
|  |  |  | ds = oCN.RunProcReturn("Select * from  Gy_Czygl where Czybm='" + lsmain[0].Czybm.ToString() + "'", "Gy_Czygl"); | 
|---|
|  |  |  | 
|---|
|  |  |  | ",HDeptID=" + lsmain[0].HDeptID.ToString() + | 
|---|
|  |  |  | ",HDept='" + lsmain[0].HDept.ToString() + "'" + | 
|---|
|  |  |  | ",HWhID=" + lsmain[0].HWhID.ToString() + | 
|---|
|  |  |  | ",HCheckEmpID=" + lsmain[0].HCheckEmpID.ToString() + | 
|---|
|  |  |  | ",HWHName='" + lsmain[0].HWHName.ToString() + "'" + | 
|---|
|  |  |  | ",HSCWHID=" + lsmain[0].HSCWHID.ToString() + | 
|---|
|  |  |  | ",HSCWHName='" + lsmain[0].HSCWHName.ToString() + "'" + | 
|---|
|  |  |  | 
|---|
|  |  |  | ",HProcID=" + lsmain[0].HProcID.ToString() + | 
|---|
|  |  |  | ",HSourceID=" + lsmain[0].HSourceID.ToString() + | 
|---|
|  |  |  | ",HGroupID=" + lsmain[0].HGroupID.ToString() + | 
|---|
|  |  |  | ",HWorkCenterID=" + lsmain[0].HWorkCenterID.ToString() + | 
|---|
|  |  |  | ",HSupName='" + lsmain[0].HSupName.ToString() + "'" + | 
|---|
|  |  |  | ",HCloudUserName='" + lsmain[0].HCloudUserName.ToString() + "'" + | 
|---|
|  |  |  | ",HCloudUserPsd='" + lsmain[0].HCloudUserPsd.ToString() + "'" + | 
|---|
|  |  |  | ",HUSEORGID=" + lsmain[0].HOrgID.ToString() + | 
|---|
|  |  |  | ",HICNumber='" + lsmain[0].HICNumber + "'" + | 
|---|
|  |  |  | ",HDingDingUserID='" + lsmain[0].HDingDingUserID + "'" + | 
|---|
|  |  |  | "  where  Czybm='" + lsmain[0].Czybm.ToString() + "'"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | 
|---|
|  |  |  | ",HSellMan='" + lsmain[0].HSellMan.ToString() + "'" + | 
|---|
|  |  |  | ",HDeptID=" + lsmain[0].HDeptID.ToString() + | 
|---|
|  |  |  | ",HDept='" + lsmain[0].HDept.ToString() + "'" + | 
|---|
|  |  |  | ",HCheckEmpID=" + lsmain[0].HCheckEmpID.ToString() + | 
|---|
|  |  |  | ",HWhID=" + lsmain[0].HWhID.ToString() + | 
|---|
|  |  |  | ",HWHName='" + lsmain[0].HWHName.ToString() + "'" + | 
|---|
|  |  |  | ",HSCWHID=" + lsmain[0].HSCWHID.ToString() + | 
|---|
|  |  |  | 
|---|
|  |  |  | ",HProcID=" + lsmain[0].HProcID.ToString() + | 
|---|
|  |  |  | ",HSourceID=" + lsmain[0].HSourceID.ToString() + | 
|---|
|  |  |  | ",HGroupID=" + lsmain[0].HGroupID.ToString() + | 
|---|
|  |  |  | ",HWorkCenterID=" + lsmain[0].HWorkCenterID.ToString() + | 
|---|
|  |  |  | ",HSupName='" + lsmain[0].HSupName.ToString() + "'" + | 
|---|
|  |  |  | ",HCloudUserName='" + lsmain[0].HCloudUserName.ToString() + "'" + | 
|---|
|  |  |  | ",HCloudUserPsd='" + lsmain[0].HCloudUserPsd.ToString() + "'" + | 
|---|
|  |  |  | ",HUSEORGID=" + lsmain[0].HOrgID.ToString() + | 
|---|
|  |  |  | ",HICNumber='" + lsmain[0].HICNumber + "'" + | 
|---|
|  |  |  | ",HDingDingUserID='" + lsmain[0].HDingDingUserID + "'" + | 
|---|
|  |  |  | "  where  Czybm='" + lsmain[0].Czybm.ToString() + "'"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 用户关联组织保存 | 
|---|
|  |  |  | [Route("Xt_User/SaveUserByOrg")] | 
|---|
|  |  |  | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "保存失败!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = 1; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #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 用户关联班组维护列表 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | ///参数:string sql。 | 
|---|
|  |  |  | ///返回值:object。 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Route("Xt_User/Gy_UserGroupRelationList")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object Gy_UserGroupRelationList(string sWhere, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<object> columnNameList = new List<object>(); | 
|---|
|  |  |  | //查看权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_Group_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_UserGroupRelationList_Query order by 用户代码 asc,班组代码 asc"; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_UserGroupRelationList_Query"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | sql = "select * from h_v_Gy_UserGroupRelationList_Query where 1=1 "; | 
|---|
|  |  |  | sql = sql + sWhere + " order by 用户代码 asc,班组代码 asc"; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_UserGroupRelationList_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 用户关联班组保存 | 
|---|
|  |  |  | [Route("Xt_User/SaveUserGroup")] | 
|---|
|  |  |  | [HttpPost] | 
|---|
|  |  |  | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "保存失败!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = 1; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 用户关联班组维护 删除 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | ///参数:string HInterID。 | 
|---|
|  |  |  | ///返回值:object。 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Route("Xt_User/UserGroupRelationList_Drop")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object UserGroupRelationList_Drop(string HInterID, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string s = ""; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查看权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_Group_Delete", 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_UserGroupRelation 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "保存失败!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = 1; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 用户关联部门查询 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | ///参数:string sql。 | 
|---|
|  |  |  | ///返回值:object。 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Route("Xt_User/UserRelationDeptlist")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object UserRelationDeptlist(string sWhere, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<object> columnNameList = new List<object>(); | 
|---|
|  |  |  | //查看权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationDept_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_UserDeptRelationList_Query order by 用户代码 asc,部门代码 asc"; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_UserDeptRelationList_Query"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | sql = "select * from h_v_Gy_UserDeptRelationList_Query where 1=1 "; | 
|---|
|  |  |  | sql = sql + sWhere + " order by 用户代码 asc,部门代码 asc"; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_UserDeptRelationList_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 用户关联部门 根据用户ID查找 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | ///参数:string sql。 | 
|---|
|  |  |  | ///返回值:object。 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Route("Xt_User/UserRelationDeptlist_EditInit")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object UserRelationDeptlist_EditInit(int HItemID, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<object> columnNameList = new List<object>(); | 
|---|
|  |  |  | //查看权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationDept_Query", 1, false, user)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "无查看权限!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string sql = "select * from h_v_Gy_UserDeptRelationList_Query where HItemID = " + HItemID; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_UserDeptRelationList_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 用户关联部门 删除 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | ///参数:string HInterID。 | 
|---|
|  |  |  | ///返回值:object。 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Route("Xt_User/UserRelationDeptlist_Drop")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object UserRelationDeptlist_Drop(string HInterID, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string s = ""; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查看权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationDept_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_UserDeptRelation 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string sql = "select * from h_v_Gy_UserByWorkStationRelationList_Query where HItemID = " + HItemID; | 
|---|
|  |  |  | string sql = "select * from h_v_Gy_UserByWorkStationRelationList_Query where 用户代码 = '" + HItemID + "'"; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_UserByWorkStationRelationList_Query"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | LogService.Write(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/UserRelationEmployeelist")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object UserRelationEmployeelist(string sWhere, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<object> columnNameList = new List<object>(); | 
|---|
|  |  |  | //查看权限 | 
|---|
|  |  |  | //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationEmployee_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_UserEmployeeRelationList_Query order by 用户代码 asc,职员代码 asc"; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_UserEmployeeRelationList_Query"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | sql = "select * from h_v_Gy_UserEmployeeRelationList_Query where 1=1 "; | 
|---|
|  |  |  | sql = sql + sWhere + " order by 用户代码 asc,职员代码 asc"; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_UserEmployeeRelationList_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/UserRelationEmployeelist_Drop")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object UserRelationEmployeelist_Drop(string HInterID, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string s = ""; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查看权限 | 
|---|
|  |  |  | //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationEmployee_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_UserEmployeeRelation 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/UserRelationEmployeelist_EditInit")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object UserRelationEmployeelist_EditInit(int HItemID, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<object> columnNameList = new List<object>(); | 
|---|
|  |  |  | //查看权限 | 
|---|
|  |  |  | //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationEmployee_Query", 1, false, user)) | 
|---|
|  |  |  | //{ | 
|---|
|  |  |  | //    objJsonResult.code = "0"; | 
|---|
|  |  |  | //    objJsonResult.count = 0; | 
|---|
|  |  |  | //    objJsonResult.Message = "无查看权限!"; | 
|---|
|  |  |  | //    objJsonResult.data = null; | 
|---|
|  |  |  | //    return objJsonResult; | 
|---|
|  |  |  | //} | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string sql = "select * from h_v_Gy_UserEmployeeRelationList_Query where HItemID = " + HItemID; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_UserEmployeeRelationList_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/UserRelationEmployeelist_Save")] | 
|---|
|  |  |  | [HttpPost] | 
|---|
|  |  |  | public object UserRelationEmployeelist_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_UserRelationEmployee_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 HEmpID = item["HEmpID"].ToString();          //客户内码 | 
|---|
|  |  |  | string HEmpNumber = item["HEmpNumber"].ToString();  //客户代码 | 
|---|
|  |  |  | string HEmpName = item["HEmpName"].ToString();      //客户名称 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sql = "select * from Gy_UserEmployeeRelation where HUserID = '" + HUserID + "' and HEmployeeID = " + HEmpID; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "Gy_UserEmployeeRelation"); | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | sql = "insert into Gy_UserEmployeeRelation(HUserID,HEmployeeID)" + | 
|---|
|  |  |  | "values(" + | 
|---|
|  |  |  | "'" + HUserID + "'" + | 
|---|
|  |  |  | "," + HEmpID + "" + | 
|---|
|  |  |  | ")"; | 
|---|
|  |  |  | oCN.RunProc(sql); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | err += "第" + i + "行:用户【" + HUserName + "】已经关联职员【" + HEmpName + "】"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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 HEmpID = item["HEmpID"].ToString();          //职员内码 | 
|---|
|  |  |  | string HEmpNumber = item["HEmpNumber"].ToString();  //职员代码 | 
|---|
|  |  |  | string HEmpName = item["HEmpName"].ToString();      //职员名称 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sql = "select * from Gy_UserEmployeeRelation where HItemID = " + HItemID; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "Gy_UserEmployeeRelation"); | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count > 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | sql = "select * from Gy_UserEmployeeRelation where HUserID = '" + HUserID + "' and HEmployeeID = " + HEmpID + " and HItemID <> " + HItemID; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "Gy_UserEmployeeRelation"); | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | sql = "update Gy_UserEmployeeRelation set " + | 
|---|
|  |  |  | "HUserID = '" + HUserID + "' " + | 
|---|
|  |  |  | ",HEmployeeID = " + HEmpID + " " + | 
|---|
|  |  |  | "where HItemID = " + HItemID; | 
|---|
|  |  |  | oCN.RunProc(sql); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | err += "第" + i + "行:用户【" + HUserName + "】已经关联职员【" + HEmpName + "】"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判定该用户与客户是否已经关联 | 
|---|
|  |  |  | sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID; | 
|---|
|  |  |  | //判定客户是否已经关联用户 | 
|---|
|  |  |  | sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " + | 
|---|
|  |  |  | " from Gy_UserCustomerRelation as a" + | 
|---|
|  |  |  | " left join Gy_Czygl as b on a.HUserID = b.Czybm " + | 
|---|
|  |  |  | " left join Gy_Customer as c on a.HCusID = c.HItemID " + | 
|---|
|  |  |  | " where a.HCusID = " + HCusID; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count > 0) | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["HUserID"].ToString()!= HUserID) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | err += "用户已经关联该客户;"; | 
|---|
|  |  |  | err += "用户【" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "】已经关联客户【" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "】;"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判定该用户与客户是否已经关联 | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" + | 
|---|
|  |  |  | sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " + | 
|---|
|  |  |  | " from Gy_UserCustomerRelation as a" + | 
|---|
|  |  |  | " left join Gy_Czygl as b on a.HUserID = b.Czybm " + | 
|---|
|  |  |  | " left join Gy_Customer as c on a.HCusID = c.HItemID " + | 
|---|
|  |  |  | " where a.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); | 
|---|
|  |  |  | oCN.RunProc(sql); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | err += "第" + i + "行:用户【" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "】已经关联客户【" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "】,客户不可被多个用户关联!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | i++; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | i++; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if(saveType == "2") | 
|---|
|  |  |  | //判断是否存在错误 | 
|---|
|  |  |  | if (err.Length > 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RollBack(); | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "导入错误:" + err; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if(saveType == "2") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.BeginTran(); | 
|---|
|  |  |  | string err = ""; | 
|---|
|  |  |  | 
|---|
|  |  |  | string HOrgNumber = item["组织代码"].ToString(); | 
|---|
|  |  |  | string HOrgName = item["组织名称"].ToString(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " + | 
|---|
|  |  |  | " from Gy_UserCustomerRelation as a" + | 
|---|
|  |  |  | " left join Gy_Czygl as b on a.HUserID = b.Czybm " + | 
|---|
|  |  |  | " left join Gy_Customer as c on a.HCusID = c.HItemID " + | 
|---|
|  |  |  | " where a.HCusID = " + HCusID; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["HUserID"].ToString()!=HUserID) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" + | 
|---|
|  |  |  | "values(" + | 
|---|
|  |  |  | "'" + HUserID + "'" + | 
|---|
|  |  |  | "," + HCusID + "" + | 
|---|
|  |  |  | ")"; | 
|---|
|  |  |  | oCN.RunProc(sql); | 
|---|
|  |  |  | err += "第" + i + "行:用户【" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "】已经关联客户【" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "】,客户不可被多个用户关联!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | err += "第" + i + "行:用户已经关联该客户!"; | 
|---|
|  |  |  | 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++; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | string HCusName = item["HCusName"].ToString();      //客户名称 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID; | 
|---|
|  |  |  | sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " + | 
|---|
|  |  |  | " from Gy_UserCustomerRelation as a" + | 
|---|
|  |  |  | " left join Gy_Czygl as b on a.HUserID = b.Czybm " + | 
|---|
|  |  |  | " left join Gy_Customer as c on a.HCusID = c.HItemID " + | 
|---|
|  |  |  | " where a.HCusID = " + HCusID; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | err += "第" + i + "行:用户【" + HUserName + "】已经关联客户【" + HCusName + "】"; | 
|---|
|  |  |  | err += "第" + i + "行:用户【" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "】已经关联客户【" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "】,客户不可被多个用户关联!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | i++; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " + | 
|---|
|  |  |  | " from Gy_UserCustomerRelation as a" + | 
|---|
|  |  |  | " left join Gy_Czygl as b on a.HUserID = b.Czybm " + | 
|---|
|  |  |  | " left join Gy_Customer as c on a.HCusID = c.HItemID " + | 
|---|
|  |  |  | " where a.HCusID = " + HCusID + " and a.HItemID <> " + HItemID; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation"); | 
|---|
|  |  |  | if(ds.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | err += "第" + i + "行:用户【" + HUserName + "】已经关联客户【" + HCusName + "】"; | 
|---|
|  |  |  | err += "第" + i + "行:用户【" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "】已经关联客户【" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "】,客户不可被多个用户关联!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 用户关联供应商维护列表 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | ///参数:string sql。 | 
|---|
|  |  |  | ///返回值:object。 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Route("Xt_User/Gy_UserSupplierRelationList")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object Gy_UserSupplierRelationList(string sWhere, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<object> columnNameList = new List<object>(); | 
|---|
|  |  |  | //查看权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_UserSupplierRelationList", 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_UserSupplierRelationList_Query order by 用户代码 asc,供应商代码 asc"; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_UserSupplierRelationList_Query"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | sql = "select * from h_v_Gy_UserSupplierRelationList_Query where 1=1 "; | 
|---|
|  |  |  | sql = sql + sWhere + " order by 用户代码 asc,供应商代码 asc"; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_UserSupplierRelationList_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/UserSupplierRelationList_Drop")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object UserSupplierRelationList_Drop(string HInterID, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string s = ""; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查看权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_UserSupplierRelation_Delete", 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_UserSupplierRelation 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 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|