public List <Permission> GetAllPermissions() { List <Permission> perms = new List <Permission>(); string sql = "select * from Permission"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { ModuleLogic ml = ModuleLogic.GetInstance(); ActionLogic al = ActionLogic.GetInstance(); for (int i = 0; i < dt.Rows.Count; i++) { Permission perm = new Permission(); perm.ID = Convert.ToInt32(dt.Rows[i]["ID"]); perm.Name = dt.Rows[i]["Name"].ToString(); perm.IsExcept = Convert.ToBoolean(dt.Rows[i]["IsExcept"]); perm.TheModule = ml.GetModule(Convert.ToInt32(dt.Rows[i]["TheModule"])); perm.TheAction = al.GetAction(Convert.ToInt32(dt.Rows[i]["TheAction"])); if (dt.Rows[i]["Remark"] != null && dt.Rows[i]["Remark"] != DBNull.Value) { perm.Remark = dt.Rows[i]["Remark"].ToString(); } else { perm.Remark = ""; } perms.Add(perm); } } return(perms); }
public Permission GetPermission(int id) { string sql = "select * from Permission where ID=" + id; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { Permission perm = new Permission(); perm.ID = id; perm.Name = dt.Rows[0]["Name"].ToString(); perm.IsExcept = Convert.ToBoolean(dt.Rows[0]["IsExcept"]); perm.TheModule = ModuleLogic.GetInstance().GetModule(Convert.ToInt32(dt.Rows[0]["TheModule"])); perm.TheAction = ActionLogic.GetInstance().GetAction(Convert.ToInt32(dt.Rows[0]["TheAction"])); if (dt.Rows[0]["Remark"] != null && dt.Rows[0]["Remark"] != DBNull.Value) { perm.Remark = dt.Rows[0]["Remark"].ToString(); } else { perm.Remark = ""; } return(perm); } return(null); }
public static ActionLogic GetInstance() { if (instance == null) { instance = new ActionLogic(); } return(instance); }