| | |
| | | #endregion |
| | | |
| | | #region [组织架构删除] |
| | | public static ToMessage DeleteOrganization(int orgid,string orgcode) |
| | | public static ToMessage DeleteOrganization(int orgid, string orgcode) |
| | | { |
| | | var sql = ""; |
| | | var cont = 0; |
| | |
| | | return mes; |
| | | } |
| | | sql = @"delete TOrganization where id=@orgid"; |
| | | dynamicParams.Add(@"orgid", orgid); |
| | | cont = DapperHelper.SQL(sql, dynamicParams); |
| | | if (cont > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "删除操作成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "删除操作失败!"; |
| | | mes.data = null; |
| | | } |
| | | |
| | | dynamicParams.Add(@"orgid", orgid); |
| | | cont = DapperHelper.SQL(sql, dynamicParams); |
| | | if (cont > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "删除操作成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "删除操作失败!"; |
| | | mes.data = null; |
| | | } |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | |
| | | |
| | | #region[用户清单数据查询] |
| | | public static ToMessage UserSearch(string UserCode, string UserName, string StuOrg,string description, string wagetype, string Enable, int startNum, int endNum, string prop, string order) |
| | | public static ToMessage UserSearch(string UserCode, string UserName, string StuOrg, string description, string wagetype, string Enable, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | |
| | | #endregion |
| | | |
| | | #region[用户所属班组] |
| | | public static ToMessage UserGroup(string stu_torgcode,string description) |
| | | public static ToMessage UserGroup(string stu_torgcode, string description) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | |
| | | public static ToMessage AddUpdateUser(string UserId, string UserCode, string UserName, string Password, string Enable, string StuOrg, string groupcode, string wagetype, string Mobile, string Email, string Operator, string OperType) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | List<object> list = new List<object>(); |
| | | var sql = ""; |
| | | try |
| | | { |
| | | if (OperType == "Add") |
| | |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | |
| | | var sql = @"insert into TUser(usercode,username,password,enable,mobile,lm_date,email,lm_user,stu_torgcode,wagetype,usergroup_code) |
| | | //写入用户表 |
| | | sql = @"insert into TUser(usercode,username,password,enable,mobile,lm_date,email,lm_user,stu_torgcode,wagetype,usergroup_code) |
| | | values(@UserCode,@UserName,@password,@Enable,@Mobile,@CreateDate,@Email,@Operator,@StuOrg,@wagetype,@groupcode)"; |
| | | dynamicParams.Add("@UserCode", UserCode); |
| | | dynamicParams.Add("@UserName", UserName); |
| | | dynamicParams.Add("@password", Password); |
| | | dynamicParams.Add("@Enable", Enable); |
| | | dynamicParams.Add("@Mobile", Mobile); |
| | | dynamicParams.Add("@CreateDate", DateTime.Now.ToString()); |
| | | dynamicParams.Add("@Email", Email); |
| | | dynamicParams.Add("@Operator", Operator); |
| | | dynamicParams.Add("@StuOrg", StuOrg); |
| | | dynamicParams.Add("@wagetype", wagetype); |
| | | dynamicParams.Add("@groupcode", groupcode); |
| | | int cont = DapperHelper.SQL(sql, dynamicParams); |
| | | if (cont > 0) |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | UserCode = UserCode, |
| | | UserName = UserName, |
| | | password = Password, |
| | | Enable = Enable, |
| | | Mobile = Mobile, |
| | | CreateDate = DateTime.Now.ToString(), |
| | | Email = Email, |
| | | Operator = Operator, |
| | | StuOrg = StuOrg, |
| | | wagetype = wagetype, |
| | | groupcode = groupcode |
| | | } |
| | | }); |
| | | //写入用户班组关联表 |
| | | sql = @"insert into TGroupUser(group_code,user_code) |
| | | values(@groupcode,@usercode)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | usercode = UserCode, |
| | | groupcode = groupcode |
| | | } |
| | | }); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | |
| | | } |
| | | if (OperType == "Update") |
| | | { |
| | | var sql = @"update TUser set username=@UserName,password=@password,enable=@Enable,mobile=@Mobile,lm_user=@Operator,email=@Email,stu_torgcode=@StuOrg,wagetype=@wagetype,usergroup_code=@groupcode,lm_date=@CreateDate where id=@UserId"; |
| | | dynamicParams.Add("@UserId", UserId); |
| | | dynamicParams.Add("@UserName", UserName); |
| | | dynamicParams.Add("@password", Password); |
| | | dynamicParams.Add("@Enable", Enable); |
| | | dynamicParams.Add("@Mobile", Mobile); |
| | | dynamicParams.Add("@CreateDate", DateTime.Now.ToString()); |
| | | dynamicParams.Add("@Email", Email); |
| | | dynamicParams.Add("@Operator", Operator); |
| | | dynamicParams.Add("@StuOrg", StuOrg); |
| | | dynamicParams.Add("@wagetype", wagetype); |
| | | dynamicParams.Add("@groupcode", groupcode); |
| | | int cont = DapperHelper.SQL(sql, dynamicParams); |
| | | if (cont > 0) |
| | | //修改用户表 |
| | | sql = @"update TUser set username=@UserName,password=@password,enable=@Enable,mobile=@Mobile,lm_user=@Operator,email=@Email,stu_torgcode=@StuOrg,wagetype=@wagetype,usergroup_code=@groupcode,lm_date=@CreateDate where id=@UserId"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | UserId = UserId, |
| | | UserName = UserName, |
| | | password = Password, |
| | | Enable = Enable, |
| | | Mobile = Mobile, |
| | | CreateDate = DateTime.Now.ToString(), |
| | | Email = Email, |
| | | Operator = Operator, |
| | | StuOrg = StuOrg, |
| | | wagetype = wagetype, |
| | | groupcode = groupcode |
| | | } |
| | | }); |
| | | //更新用户班组关联表 |
| | | sql = @"update TGroupUser set group_code=@groupcode where user_code=@usercode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | usercode = UserCode, |
| | | groupcode = groupcode |
| | | } |
| | | }); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | |
| | | dynamicParams.Add("@userid", userid); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | |
| | | //删除用户班组关联表 |
| | | sql = @"delete TGroupUser where user_code=@usercode"; |
| | | list.Add(new { str = sql, parm = new { usercode = data.Rows[0]["USERCODE"].ToString() } }); |
| | | //删除用户角色关联表 |
| | | sql = @"delete TUserRoleRelation where user_code=@usercode"; |
| | | list.Add(new { str = sql, parm = new { usercode = data.Rows[0]["USERCODE"].ToString() } }); |
| | | |
| | |
| | | #endregion |
| | | |
| | | #region[用户清单关联角色查询] |
| | | public static ToMessage UserAssociationRole(string usercode,string stu_torgcode,string description) |
| | | public static ToMessage UserAssociationRole(string usercode, string stu_torgcode, string description) |
| | | { |
| | | string sql = ""; |
| | | string search = ""; |
| | |
| | | where C.user_code=@usercode |
| | | ) B |
| | | on A.roletype_code=B.roletype_code |
| | | where A.is_delete='0' "+search; |
| | | where A.is_delete='0' " + search; |
| | | dynamicParams.Add("@usercode", usercode); |
| | | var data = DapperHelper.select<TreeObejct>(sql, dynamicParams); |
| | | for (int i = 0; i < data.Count; i++) |
| | |
| | | #endregion |
| | | |
| | | #region[用户清单关联角色保存] |
| | | public static ToMessage SaveUserAssoctRole(string usercode,string stu_torgcode,string description, List<RoleUserSubmit> json) |
| | | public static ToMessage SaveUserAssoctRole(string usercode, string stu_torgcode, string description, List<RoleUserSubmit> json) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | |
| | | for (int j = 0; j < json[i].Data.Count; j++) |
| | | { |
| | | sql = @"insert into TUserRoleRelation(user_code,role_code,torg_code) values(@usercode,@role_code,@stu_torgcode)"; |
| | | list.Add(new { str = sql, parm = new { usercode = usercode, stu_torgcode= stu_torgcode, role_code = json[i].Data[j] } }); |
| | | list.Add(new { str = sql, parm = new { usercode = usercode, stu_torgcode = stu_torgcode, role_code = json[i].Data[j] } }); |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | #region[用户组列表查询] |
| | | public static ToMessage UserGroupSearch(string stu_torgcode, string description,int startNum, int endNum, string prop, string order) |
| | | public static ToMessage UserGroupSearch(string groupcode, string groupname, string stu_torgcode, string description, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | |
| | | default: |
| | | break; |
| | | } |
| | | if (groupcode != "" && groupcode != null) |
| | | { |
| | | search += " and G.group_code like '%'+@groupcode+'%' "; |
| | | dynamicParams.Add("@groupcode", groupcode); |
| | | } |
| | | if (groupname != "" && groupname != null) |
| | | { |
| | | search += " and G.group_name like '%'+@groupname+'%' "; |
| | | dynamicParams.Add("@groupname", groupname); |
| | | } |
| | | var sql = @"select torg_code,parent.org_name,group_code,group_name,G.description |
| | | from TGroup G |
| | | left join TOrganization parent on G.torg_code=parent.org_code |
| | | left join TOrganization as child on parent.parent_id=child.id |
| | | where G.is_delete<>'1' "+search; |
| | | where G.is_delete<>'1' " + search; |
| | | var data = DapperHelper.GetPageList<object>(sql, dynamicParams, prop, order, startNum, endNum, out total); |
| | | mes.code = "200"; |
| | | mes.Message = "查询成功!"; |
| | |
| | | #endregion |
| | | |
| | | #region[用户组新增] |
| | | public static ToMessage UserGroupAdd(List<StepDefect> json, string username) |
| | | public static ToMessage UserGroupAdd(string type, List<GroupUser> json, string username) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | |
| | | try |
| | | { |
| | | list.Clear(); |
| | | //循环写入用户组表 |
| | | for (int i = 0; i < json.Count; i++) |
| | | if (type == "Add") |
| | | { |
| | | var sql0 = @"select * from TGroup where group_code=@group_code and torg_code=@torg_code"; |
| | | dynamicParams.Add("@group_code", json[i].code); |
| | | dynamicParams.Add("@torg_code", json[i].storg_code); |
| | | var data = DapperHelper.selectdata(sql0, dynamicParams); |
| | | //判断用户组编码是否唯一 |
| | | sql = @"select * from TGroup where group_code=@group_code and torg_code=@torg_code"; |
| | | dynamicParams.Add("@group_code", json[0].code); |
| | | dynamicParams.Add("@torg_code", json[0].storg_code); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "操作失败,编码重复!"; |
| | | mes.Message = "操作失败,用户组编码重复!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | sql = @"insert into TGroup(group_code,group_name,description,lm_user,lm_date,torg_code) values(@groupcode,@groupename,@description,@lm_user,@lm_date,@torg_code)"; |
| | | else |
| | | { |
| | | //写入用户组表 |
| | | sql = @"insert into TGroup(group_code,group_name,description,lm_user,lm_date,torg_code) values(@groupcode,@groupename,@description,@lm_user,@lm_date,@torg_code)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | groupcode = json[0].code, |
| | | groupename = json[0].name, |
| | | description = json[0].flag, |
| | | lm_user = username, |
| | | lm_date = DateTime.Now.ToString(), |
| | | torg_code = json[0].storg_code |
| | | } |
| | | }); |
| | | //写入用户组关系表 |
| | | for (int i = 0; i < json[0].children.Count; i++) |
| | | { |
| | | sql = @"insert into TGroupUser(group_code,user_code) values(@groupcode,@usercode)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | groupcode = json[0].code, |
| | | usercode = json[0].children[i].usercode |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "操作成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "操作失败!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //修改用户组表 |
| | | sql = @"update TGroup set group_name=@groupename,lm_user=@lm_user,lm_date=@lm_date,description=@description,torg_code=@torg_code where group_code=@groupcode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | groupcode = json[i].code, |
| | | groupename = json[i].name, |
| | | description = json[i].flag, |
| | | groupcode = json[0].code, |
| | | groupename = json[0].name, |
| | | description = json[0].flag, |
| | | lm_user = username, |
| | | lm_date = DateTime.Now.ToString(), |
| | | torg_code = json[i].storg_code |
| | | torg_code = json[0].storg_code |
| | | } |
| | | }); |
| | | } |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "操作成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "操作失败!"; |
| | | mes.data = null; |
| | | //删除用户组关系表 |
| | | sql = @"delete TGroupUser where group_code=@groupcode"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | groupcode = json[0].code |
| | | } |
| | | }); |
| | | //修改用户组关系表 |
| | | for (int i = 0; i < json[0].children.Count; i++) |
| | | { |
| | | sql = @"insert into TGroupUser(group_code,user_code) values(@groupcode,@usercode)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | groupcode = json[0].code, |
| | | usercode = json[0].children[i].usercode |
| | | } |
| | | }); |
| | | } |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "操作成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "操作失败!"; |
| | | mes.data = null; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | try |
| | | { |
| | | list.Clear(); |
| | | sql = @"select * from TUser where is_delete<>'1' and usergroup_code=@UserGrupCode"; |
| | | //判断当前用户组是否存在开报工记录 |
| | | sql = @"select * from TK_Wrk_RecordSub where usergroup_code=@UserGrupCode"; |
| | | dynamicParams.Add("@UserGrupCode", UserGrupCode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "该用户组下有关联的用户,不允许删除!"; |
| | | mes.Message = "该用户组已经有报工,不允许删除!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | sql = @"delete TGroup where group_code=@UserGrupCode"; |
| | | list.Add(new { str = sql, parm = new { UserGrupCode = UserGrupCode } }); |
| | | sql = @"delete TGroupUser where group_code=@UserGrupCode"; |
| | | list.Add(new { str = sql, parm = new { UserGrupCode = UserGrupCode } }); |
| | | |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region[用户组查看关联人员] |
| | | public static ToMessage GroupUserProject(string groupcode) |
| | | { |
| | | var sql = ""; |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |
| | | { |
| | | sql = @"select U.usercode,U.username from TGroupUser GU |
| | | left join TUser U on GU.user_code=U.usercode |
| | | where GU.group_code=@groupcode"; |
| | | dynamicParams.Add("@groupcode", groupcode); |
| | | var data = DapperHelper.selectdata(sql, dynamicParams); |
| | | if (data.Rows.Count > 0) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "查询成功!"; |
| | | mes.data = data; |
| | | return mes; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "该班组下无指定用户!"; |
| | | mes.data = null; |
| | | return mes; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = e.Message; |
| | | mes.data = null; |
| | | } |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | |
| | | #region[角色类型查询] |
| | | public static ToMessage RoleTypeSearch(string stu_torgcode, string description,int startNum, int endNum, string prop, string order) |
| | | public static ToMessage RoleTypeSearch(string stu_torgcode, string description, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | |
| | | { |
| | | roletypecode = json[i].code, |
| | | roletypename = json[i].name, |
| | | torg_code= json[i].flag |
| | | torg_code = json[i].flag |
| | | } |
| | | }); |
| | | } |
| | |
| | | #endregion |
| | | |
| | | #region[角色类型下拉接口] |
| | | public static ToMessage RoleTypeSelect(string stu_torgcode,string description) |
| | | public static ToMessage RoleTypeSelect(string stu_torgcode, string description) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | |
| | | #endregion |
| | | |
| | | #region[角色清单查询] |
| | | public static ToMessage RoleSearch(string stu_torgcode,string description,string RoleCode, string RoleName, string RoleTypeCode, string CreateUser, int startNum, int endNum, string prop, string order) |
| | | public static ToMessage RoleSearch(string stu_torgcode, string description, string RoleCode, string RoleName, string RoleTypeCode, string CreateUser, int startNum, int endNum, string prop, string order) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | string search = ""; |
| | |
| | | #endregion |
| | | |
| | | #region[角色清单新增编辑] |
| | | public static ToMessage AddUpdateRole(string RoleId, string RoleCode, string RoleName,string stu_torgcode, string RoleTypeCode, string description, string Usercode, string OperType) |
| | | public static ToMessage AddUpdateRole(string RoleId, string RoleCode, string RoleName, string stu_torgcode, string RoleTypeCode, string description, string Usercode, string OperType) |
| | | { |
| | | var dynamicParams = new DynamicParameters(); |
| | | try |