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

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

            TravelAgent.Model.AdminList model = new TravelAgent.Model.AdminList();
            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.UserName = ds.Tables[0].Rows[0]["UserName"].ToString();
                model.UserPwd  = ds.Tables[0].Rows[0]["UserPwd"].ToString();
                model.ReadName = ds.Tables[0].Rows[0]["ReadName"].ToString();
                model.RoleId   = Convert.ToInt32(ds.Tables[0].Rows[0]["RoleId"].ToString());
                model.IsLock   = Convert.ToInt32(ds.Tables[0].Rows[0]["IsLock"].ToString());
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(TravelAgent.Model.AdminList model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AdminList set ");
            strSql.Append("UserName=@UserName,");
            strSql.Append("UserPwd=@UserPwd,");
            strSql.Append("ReadName=@ReadName,");
            strSql.Append("RoleId=@RoleId,");
            strSql.Append("IsLock=@IsLock");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserName", SqlDbType.VarChar),
                new SqlParameter("@UserPwd",  SqlDbType.VarChar),
                new SqlParameter("@ReadName", SqlDbType.VarChar),
                new SqlParameter("@RoleId",   SqlDbType.Int),
                new SqlParameter("@IsLock",   SqlDbType.Int),
                new SqlParameter("@Id",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.UserName;
            parameters[1].Value = model.UserPwd;
            parameters[2].Value = model.ReadName;
            parameters[3].Value = model.RoleId;
            parameters[4].Value = model.IsLock;
            parameters[5].Value = model.Id;

            return(DbHelperSQL.ExecuteSql(strSql.ToString(), parameters));
        }
Example #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TravelAgent.Model.AdminList GetAccountByUser(string username, string password)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from AdminList ");
            strSql.Append(" where UserName=@UserName and UserPwd=@UserPwd");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserName", SqlDbType.VarChar),
                new SqlParameter("@UserPwd",  SqlDbType.VarChar)
            };
            parameters[0].Value = username;
            parameters[1].Value = password;

            TravelAgent.Model.AdminList model = new TravelAgent.Model.AdminList();
            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.UserName = ds.Tables[0].Rows[0]["UserName"].ToString();
                model.UserPwd  = ds.Tables[0].Rows[0]["UserPwd"].ToString();
                model.ReadName = ds.Tables[0].Rows[0]["ReadName"].ToString();
                model.RoleId   = Convert.ToInt32(ds.Tables[0].Rows[0]["RoleId"].ToString());
                model.IsLock   = Convert.ToInt32(ds.Tables[0].Rows[0]["IsLock"].ToString());
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public TravelAgent.Model.AdminList GetAccountByUser(string username, string password)
 {
     TravelAgent.Model.AdminList admin = AdminDAL.GetAccountByUser(username, password);
     if (admin != null)
     {
         admin.Role = RoleDAL.GetModel(admin.RoleId);
     }
     return(admin);
 }
Example #5
0
 void ManagePage_Load(object sender, EventArgs e)
 {
     if (Session["LoginUser"] == null)
     {
         Response.Write("<script>parent.location.href='/admin/Login.aspx'</script>");
         Response.End();
     }
     else
     {
         Admin = (TravelAgent.Model.AdminList)Session["LoginUser"];
     }
 }
Example #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.IsPostBack)
     {
         if (Request["txtUsername"] != null)
         {
             TravelAgent.Model.AdminList admin = new TravelAgent.Model.AdminList();
             admin.UserName = Request["txtUsername"];
             admin.UserPwd  = Request["txtPassword"];
             admin.ReadName = Request["txtTrueName"];
             admin.RoleId   = Convert.ToInt32(Request["ddlRole"]);
             admin.IsLock   = Request["chkIsLock"] == null ? 0 : 1;
             int adminid = Convert.ToInt32(Request["hidId"]);
             if (adminid == 0)
             {
                 if (AdminBll.Add(admin) > 0)
                 {
                     Response.Write("true");
                 }
                 else
                 {
                     Response.Write("false");
                 }
             }
             else
             {
                 admin.Id = adminid;
                 if (AdminBll.Update(admin) > 0)
                 {
                     Response.Write("true");
                 }
                 else
                 {
                     Response.Write("false");
                 }
             }
         }
         if (Request["admin_id"] != null)
         {
             if (AdminBll.Delete(Convert.ToInt32(Request["admin_id"])) > 0)
             {
                 Response.Write("true");
             }
             else
             {
                 Response.Write("false");
             }
         }
     }
 }
Example #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.IsPostBack)
     {
         BindRole();
         if (Request.QueryString["id"] != null)
         {
             int adminid = Convert.ToInt32(Request.QueryString["id"]);
             TravelAgent.Model.AdminList admin = AdminBll.GetModel(adminid);
             if (admin != null)
             {
                 this.hidId.Value           = adminid.ToString();
                 this.ddlRole.SelectedValue = admin.RoleId.ToString();
                 this.txtUsername.Text      = admin.UserName;
                 this.txtPassword.Attributes.Add("value", admin.UserPwd);
                 this.txtTrueName.Text  = admin.ReadName;
                 this.chkIsLock.Checked = admin.IsLock == 1;
             }
         }
     }
 }
Example #8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(TravelAgent.Model.AdminList model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into AdminList(");
            strSql.Append("UserName,UserPwd,ReadName,RoleId,IsLock)");
            strSql.Append(" values (");
            strSql.Append("@UserName,@UserPwd,@ReadName,@RoleId,@IsLock)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserName", SqlDbType.VarChar),
                new SqlParameter("@UserPwd",  SqlDbType.VarChar),
                new SqlParameter("@ReadName", SqlDbType.VarChar),
                new SqlParameter("@RoleId",   SqlDbType.Int),
                new SqlParameter("@IsLock",   SqlDbType.Int)
            };
            parameters[0].Value = model.UserName;
            parameters[1].Value = model.UserPwd;
            parameters[2].Value = model.ReadName;
            parameters[3].Value = model.RoleId;
            parameters[4].Value = model.IsLock;
            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Example #9
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(TravelAgent.Model.AdminList model)
 {
     return(AdminDAL.Update(model));
 }
Example #10
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(TravelAgent.Model.AdminList model)
 {
     AdminDAL.Add(model);
     return(AdminDAL.GetMaxID("Id"));
 }