Пример #1
0
    /// <summary>
    /// 增加新的角色到数据库中
    /// </summary>
    /// <param name="RoleInfo">角色</param>
    /// <returns>增加结果状态 成功为true 反之 false</returns>
    public bool Add(M_RoleInfo RoleInfo)
    {
        string strSql = "INSERT INTO ZL_Role(RoleName,Description)VALUES(@RoleName,@Description)";
        SqlParameter[] parameter = new SqlParameter[2];
        parameter[0] = new SqlParameter("@RoleName", SqlDbType.NVarChar, 20);
        parameter[0].Value = RoleInfo.RoleName;
        parameter[1] = new SqlParameter("@Description", SqlDbType.NVarChar, 255);
        parameter[1].Value = RoleInfo.Description;

        return SqlHelper.ExecuteSql(strSql, parameter);
    }
Пример #2
0
        public M_RoleInfo GetModelFromReader(DbDataReader rdr)
        {
            M_RoleInfo model = new M_RoleInfo();

            model.RoleID      = Convert.ToInt32(rdr["RoleID"]);
            model.RoleName    = ConverToStr(rdr["RoleName"]);
            model.Description = ConverToStr(rdr["Description"]);
            model.NodeID      = ConvertToInt(rdr["NodeID"]);
            model.Auth        = ConverToStr(rdr["Auth"]);
            model.CAdminId    = ConvertToInt(rdr["CAdminId"]);
            model.CDate       = ConvertToDate(rdr["CDate"]);
            rdr.Dispose();
            return(model);
        }
Пример #3
0
        public override SqlParameter[] GetParameters()
        {
            M_RoleInfo model = this;

            SqlParameter[] sp = GetSP();
            sp[0].Value = model.RoleID;
            sp[1].Value = model.RoleName;
            sp[2].Value = model.Description;
            sp[3].Value = model.NodeID;
            sp[4].Value = model.Auth;
            sp[5].Value = model.CAdminId;
            sp[6].Value = model.CDate;
            return(sp);
        }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     B_Admin badmin = new B_Admin();
     badmin.CheckMulitLogin();
     if (!badmin.ChkPermissions("RoleEdit"))
     {
         function.WriteErrMsg("没有权限进行此项操作");
     }
     if (!Page.IsPostBack)
     {
         ViewState["RoleID"] = Request.QueryString["RoleID"];
         //判断当前管理员是否存在
         if (B_Admin.IsExist(DataConverter.CLng(ViewState["RoleID"])))
         {
             this.LblTitle.Text = "修改角色";
             this.Literal1.Text = "修改角色";
             role = B_Role.GetRoleById(DataConverter.CLng(ViewState["RoleID"]));
             this.txbRoleName.Text = role.RoleName;
             this.tbRoleInfo.Text = role.Description;
         }
         else
         {
             this.LblTitle.Text = "添加角色";
             this.Literal1.Text = "添加角色";
         }
     }
 }
Пример #5
0
 /// <summary>
 /// 从DataReader中读取管理员记录
 /// </summary>
 /// <param name="rdr">DataReader</param>
 /// <returns>M_RoleInfo 角色</returns>
 private static M_RoleInfo GetRoleInfoFromReader(SqlDataReader rdr)
 {
     M_RoleInfo info = new M_RoleInfo();
     info.RoleID = Convert.ToInt32(rdr["RoleID"]);
     info.RoleName = rdr["RoleName"].ToString();
     info.Description = rdr["Description"].ToString();
     rdr.Close();
     return info;
 }
Пример #6
0
 /// <summary>
 /// 传递参数
 /// </summary>
 /// <param name="adminInfo"></param>
 /// <returns></returns>
 private static SqlParameter[] GetParameters(M_RoleInfo roleInfo)
 {
     SqlParameter[] parameter = new SqlParameter[3];
     parameter[0] = new SqlParameter("@RoleID", SqlDbType.Int, 4);
     parameter[0].Value = roleInfo.RoleID;
     parameter[1] = new SqlParameter("@RoleName", SqlDbType.NVarChar, 50);
     parameter[1].Value = roleInfo.RoleName;
     parameter[2] = new SqlParameter("@Description", SqlDbType.NVarChar, 255);
     parameter[2].Value = roleInfo.Description;
     return parameter;
 }
Пример #7
0
 /// <summary>
 /// 判断是否更新
 /// </summary>
 /// <returns></returns>
 public bool Update(M_RoleInfo roleInfo)
 {
     string sqlStr = "UPDATE ZL_Role SET RoleName=@RoleName,Description=@Description WHERE RoleID=@RoleId";
     SqlParameter[] Params = GetParameters(roleInfo);
     return SqlHelper.ExecuteSql(sqlStr, Params);
 }
Пример #8
0
 // 增加角色
 public static bool Add(M_RoleInfo role)
 {
     return roleMethod.Add(role);
 }
Пример #9
0
 // 更新角色
 public static bool Update(M_RoleInfo role)
 {
     return roleMethod.Update(role);
 }