示例#1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TravelAgent.Model.AdminRole GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from AdminRole ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            TravelAgent.Model.AdminRole model = new TravelAgent.Model.AdminRole();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                model.roleName = ds.Tables[0].Rows[0]["roleName"].ToString();
                model.roleAuth = ds.Tables[0].Rows[0]["roleAuth"].ToString();
                model.roleInfo = ds.Tables[0].Rows[0]["roleInfo"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.IsPostBack)
     {
         if (Request["rolename"] != null)
         {
             TravelAgent.Model.AdminRole role = new TravelAgent.Model.AdminRole();
             role.roleName = Request["rolename"];
             role.roleInfo = Request["roleinfo"];
             role.roleAuth = Request["roleauth"];
             int roleid = Request["roleid"] == "" ? 0 : Convert.ToInt32(Request["roleid"]);
             if (roleid == 0)
             {
                 if (RoleBll.Add(role) > 0)
                 {
                     Response.Write("true");
                 }
                 else
                 {
                     Response.Write("false");
                 }
             }
             else
             {
                 role.Id=roleid;
                 if (RoleBll.Update(role) > 0)
                 {
                     Response.Write("true");
                 }
                 else
                 {
                     Response.Write("false");
                 }
             }
         }
         if (Request["role_id"] != null)
         {
             if (RoleBll.Delete(Convert.ToInt32(Request["role_id"])) > 0)
             {
                 Response.Write("true");
             }
             else
             {
                 Response.Write("false");
             }
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.IsPostBack)
     {
         if (Request.QueryString["roleid"] != null)
         {
             int roleid = Convert.ToInt32(Request.QueryString["roleid"]);
             TravelAgent.Model.AdminRole role = RoleBll.GetModel(roleid);
             if (role != null)
             {
                 this.txtRole.Text      = role.roleName;
                 this.txtRoleInfo.Value = role.roleInfo;
                 this.hidroleid.Value   = roleid.ToString();
                 this.hidauth.Value     = role.roleAuth;
             }
         }
     }
 }
示例#4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(TravelAgent.Model.AdminRole model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into AdminRole(");
            strSql.Append("roleName,roleAuth,roleInfo)");
            strSql.Append(" values (");
            strSql.Append("@roleName,@roleAuth,@roleInfo)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@roleName", SqlDbType.VarChar),
                new SqlParameter("@roleAuth", SqlDbType.VarChar),
                new SqlParameter("@roleInfo", SqlDbType.VarChar)
            };
            parameters[0].Value = model.roleName;
            parameters[1].Value = model.roleAuth;
            parameters[2].Value = model.roleInfo;
            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
示例#5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(TravelAgent.Model.AdminRole model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AdminRole set ");
            strSql.Append("roleName=@roleName,");
            strSql.Append("roleAuth=@roleAuth,");
            strSql.Append("roleInfo=@roleInfo");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@roleName", SqlDbType.VarChar),
                new SqlParameter("@roleAuth", SqlDbType.VarChar),
                new SqlParameter("@roleInfo", SqlDbType.VarChar),
                new SqlParameter("@Id",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.roleName;
            parameters[1].Value = model.roleAuth;
            parameters[2].Value = model.roleInfo;
            parameters[3].Value = model.Id;

            return(DbHelperSQL.ExecuteSql(strSql.ToString(), parameters));
        }
示例#6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(TravelAgent.Model.AdminRole model)
 {
     return(RoleDAL.Update(model));
 }
示例#7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(TravelAgent.Model.AdminRole model)
 {
     RoleDAL.Add(model);
     return(RoleDAL.GetMaxID("Id"));
 }