コード例 #1
0
        public List<Role> GetAllRoles(string sqlWhere)
        {
            List<Role> roles = new List<Role>();
            using (DataCommand cmd = DataCommandManager.GetDataCommand("GetAllRoles"))
            {
                if (!string.IsNullOrEmpty(sqlWhere))
                {
                    cmd.CommandText = cmd.CommandText + " " + sqlWhere;
                }
                using (IDataReader dr = cmd.ExecuteDataReader())
                {
                    while (dr.Read())
                    {
                        Role role = new Role();

                        if (!Convert.IsDBNull(dr["RoleId"]))
                        {
                            role.RoleId = Convert.ToInt32(dr["RoleId"]);
                        }
                        if (!Convert.IsDBNull(dr["RoleName"]))
                        {
                            role.RoleName = dr["RoleName"].ToString();
                        }
                        if (!Convert.IsDBNull(dr["Description"]))
                        {
                            role.Description = dr["Description"].ToString();
                        }
                        roles.Add(role);
                    }
                }
            }
            return roles;
        }
コード例 #2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="roleid"></param>
 /// <returns></returns>
 public Role GetRoleByRoleId(int roleid)
 {
     Role model = new Role();
     //string sql = "select * from Base_Role where RoleId = @PK";
     using (DataCommand cmd = DataCommandManager.GetDataCommand("GetRoleIdByRoleId"))
     {
         cmd.SetParameterValue("@RoleId", roleid);
         using (IDataReader dr = cmd.ExecuteDataReader())
         {
             while (dr.Read())
             {
                 if (!Convert.IsDBNull(dr["RoleId"]))
                 {
                     model.RoleId = (int)dr["RoleId"];
                 }
                 if (!Convert.IsDBNull(dr["RoleName"]))
                 {
                     model.RoleName = (string)dr["RoleName"];
                 }
                 if (!Convert.IsDBNull(dr["SortCode"]))
                 {
                     model.SortCode = (int)dr["SortCode"];
                 }
                 if (!Convert.IsDBNull(dr["Enabled"]))
                 {
                     model.Enabled = (bool)dr["Enabled"];
                 }
                 if (!Convert.IsDBNull(dr["Description"]))
                 {
                     model.Description = (string)dr["Description"];
                 }
             }
         }
     }
     return model;
 }
コード例 #3
0
 public int Update(Role model)
 {
     return _dataAccess.Update(model);
 }
コード例 #4
0
 public int Insert(Role model)
 {
     return _dataAccess.Insert(model);
 }
コード例 #5
0
 public int Update(Role model)
 {
     using (DataCommand cmd = DataCommandManager.GetDataCommand("UpdateRole"))
     {
         cmd.SetParameterValue("@RoleName", model.RoleName);
         cmd.SetParameterValue("@SortCode", model.SortCode);
         cmd.SetParameterValue("@Enabled", model.Enabled);
         cmd.SetParameterValue("@Description", model.Description);
         cmd.SetParameterValue("@RoleId", model.RoleId);
         return cmd.ExecuteNonQuery();
     }
 }
コード例 #6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Insert(Role model)
 {
     using (DataCommand cmd = DataCommandManager.GetDataCommand("InsertRole"))
     {
         cmd.SetParameterValue("@RoleId", KeyGenerator.Instance.GetNextValue("Role"));
         cmd.SetParameterValue("@RoleName", model.RoleName);
         cmd.SetParameterValue("@SortCode", model.SortCode);
         cmd.SetParameterValue("@Enabled", model.Enabled);
         cmd.SetParameterValue("@Description", model.Description);
         return cmd.ExecuteNonQuery();
     }
 }