/// <summary> /// 超级管理员岗位不能删除 /// </summary> /// <param name="admin"></param> /// <param name="errorMsg"></param> /// <returns></returns> public bool IsAllowDelete(P_Role role) { string sql = $@" select r.isSuperAdmin from P_Role as r where r.iRoleID= {role.iRoleID} "; using (var conn = ConnectionFactory.GetDBConn(ConnectionFactory.DBConnNames.GisPlateform)) { try { List <dynamic> list = conn.Query <dynamic>(sql).ToList(); if (list.Count > 0 && list[0].isSuperAdmin == true) { return(true); } else { return(false); } } catch (Exception e) { return(false); } } }
/// <summary> /// 新增 /// </summary> /// <param name="value"></param> /// <returns></returns> public MessageEntity Post([FromBody] P_Role value) { if (value == null) { return(MessageEntityTool.GetMessage(ErrorType.FieldError)); } return(_roleDAL.Add(value)); }
/// <summary> /// 修改 /// </summary> /// <param name="iRoleID"></param> /// <param name="value"></param> /// <returns></returns> public MessageEntity Put(int iRoleID, [FromBody] P_Role value) { if (value == null) { return(MessageEntityTool.GetMessage(ErrorType.FieldError)); } value.iRoleID = iRoleID; return(_roleDAL.Update(value)); }
public MessageEntity Update(P_Role role) { if (IsExist(role)) { return(MessageEntityTool.GetMessage(ErrorType.OprationError, "", "已存在相同角色名称")); } base.UpdateEntity(role, ConnectionFactory.DBConnNames.GisPlateform, out MessageEntity messageEntity); return(messageEntity); }
public MessageEntity Delete(P_Role role) { //不允许删除 if (IsAllowDelete(role)) { return(MessageEntityTool.GetMessage(ErrorType.OprationError, "", "超级管理员不允许删除")); } if (IsExistUser(role)) { return(MessageEntityTool.GetMessage(ErrorType.OprationError, "", "该岗位下存在用户,不允许删除")); } base.DeleteEntity(role, ConnectionFactory.DBConnNames.GisPlateform, out MessageEntity messageEntity); return(messageEntity); }
public Model.P_Role ToPOCO() { var o = new P_Role() { ID = this.ID, Name = this.Name, IsActive = this.IsActive, Remark = this.Remark, SN = this.SN, DepID = this.DepID, }; return(o); }
//获取combobox角色类型 public object GetRoleTypeList() { List <P_Role> list = new List <P_Role>(); StringBuilder strSQL = new StringBuilder(); strSQL.Append(@"select ID,Name from P_Role where IsActive = 1"); DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.MainConnectionString, CommandType.Text, strSQL.ToString(), null); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { P_Role info = new P_Role(); info.ID = Convert.ToInt32(dr["ID"]); info.Name = dr["Name"].ToString(); list.Add(info); } } return(list); }
//获取车辆分站 public object GetStationList() { List <P_Role> list = new List <P_Role>(); StringBuilder sb = new StringBuilder(); sb.Append(@"select 编码,名称 from TStation where 是否有效 = 1"); DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.AttemperConnectionString, CommandType.Text, sb.ToString(), null); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { P_Role info = new P_Role(); info.ID = Convert.ToInt32(dr["编码"]); info.Name = dr["名称"].ToString(); list.Add(info); } } return(list); }
public bool IsExist(P_Role role) { using (var conn = ConnectionFactory.GetDBConn(ConnectionFactory.DBConnNames.GisPlateform)) { try { string sql = $@"select count(0) as count from P_Role p where p.iRoleID <> {role.iRoleID} and p.cRoleName = '{role.cRoleName} '"; List <dynamic> pointcc = conn.Query <dynamic>(sql).ToList(); if (pointcc[0].count > 0) { return(true); } else { return(false); } } catch (Exception e) { return(false); } } }