Beispiel #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     lxyAuthor.validateAuthor(this, "AdminID");
     DataModel dm = new DataModel();
     admin = dm.GetAdmin(Convert.ToInt32(Session["AdminID"]));
     if (admin == null)
     {
         Response.Redirect("您还未登录,请刷新后登录!");
     }
 }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            string adminNewPWD = context.Request.Params["AdminNewPwd"].ToString();
            string adminCfPwd = context.Request.Params["AdminCfPwd"].ToString();
            JsonData jd = new JsonData();
            int status = 0;
            string msg = "";
            if (adminCfPwd != adminNewPWD)
            {
                msg = "新密码不一致,请确认!";
                //context.Response.Write();
            }
            else
            {
                LxyAdmin admin = new LxyAdmin();
                admin.AdminID = Convert.ToInt32(context.Request.Params["AdminID"]);
                admin.AdminAccount = context.Request.Params["AdminAccount"].ToString();
                admin.AdminPwd = context.Request.Params["AdminPwd"].ToString();
                admin.AdminName = context.Request.Params["AdminName"].ToString();
                admin.AdminLevel = "1";
                DataModel dm =new DataModel();

                if (admin.AdminID != 0)
                {
                    //修改
                    LxyAdmin _admin = dm.GetAdmin(admin.AdminID);
                    if (admin.AdminPwd != _admin.AdminPwd)
                    {
                        msg = "原密码错误!";
                    }
                    else
                    {
                        admin.AdminID=dm.SaveAdmin(admin);
                        status = 1;
                        msg = "修改成功!";
                    }
                }
            }
            jd["status"] = status;
            jd["msg"] = msg;
            context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
            context.Response.Write(JsonMapper.ToJson(jd));
            context.Response.End();
        }
Beispiel #3
0
 public LxyAdmin GetAdmin(int adminID)
 {
     InitCommand();
     LxyAdmin admin = new LxyAdmin();
     cmd.CommandText = "select * from Admin_tb where AdminID = @adminID";
     cmd.Parameters.AddWithValue("@adminID", adminID);
     dr = cmd.ExecuteReader();
     if (dr.Read())
     {
         admin.AdminID = adminID;
         admin.AdminLevel = dr["adminLevel"].ToString();
         admin.AdminAccount = dr["AdminAccount"].ToString(); ;
         admin.AdminPwd = dr["adminPWD"].ToString();
         admin.AdminName = dr["adminName"].ToString();
     }
     return admin;
 }
Beispiel #4
0
 public int SaveAdmin(LxyAdmin admin)
 {
     InitCommand();
     if (admin.AdminID== 0)
     {
         //Insert new user
         cmd.CommandText = "INSERT INTO Admin_tb (AdminName,AdminAccount,AdminPwd,AdminLevel) VALUES (@AdminName,@AdminAccount,@AdminPwd,@AdminLevel)";
         cmd.Parameters.Clear();
         cmd.Parameters.AddWithValue("@AdminName", admin.AdminName);
         cmd.Parameters.AddWithValue("@AdminAccount", admin.AdminAccount);
         cmd.Parameters.AddWithValue("@AdminLevel", admin.AdminLevel);
         cmd.Parameters.AddWithValue("@AdminPwd", admin.AdminPwd);
         cmd.ExecuteNonQuery();
         cmd.CommandText = "SELECT @@Identity ";
         admin.AdminID = (int)cmd.ExecuteScalar();
     }
     else
     {
         cmd = new OleDbCommand();
         cmd.Connection = conn;
         cmd.CommandText = "UPDATE Admin_tb SET  " +
         " AdminName=@AdminName,AdminAccount=@AdminAccount,AdminPwd=@AdminPwd,AdminLevel=@AdminLevel where AdminID =@AdminID";
         cmd.Parameters.Clear();
         cmd.Parameters.AddWithValue("@AdminName", admin.AdminName);
         cmd.Parameters.AddWithValue("@AdminAccount", admin.AdminAccount);
         cmd.Parameters.AddWithValue("@AdminPwd", admin.AdminPwd);
         cmd.Parameters.AddWithValue("@AdminLevel", admin.AdminLevel);
         cmd.Parameters.AddWithValue("@AdminID", admin.AdminID);
         cmd.ExecuteNonQuery();
     }
     conn.Close();
     return admin.AdminID;
 }
Beispiel #5
0
 public LxyAdmin GetAdmin(string adminAccount)
 {
     InitCommand();
     LxyAdmin admin = new LxyAdmin();
     cmd.CommandText = "select * from Admin_tb where AdminAccount = @adminAccount";
     cmd.Parameters.AddWithValue("@AdminName", adminAccount);
     dr = cmd.ExecuteReader();
     if(dr.Read()){
         admin.AdminID = Convert.ToInt32(dr["adminID"]);
         admin.AdminLevel = dr["adminLevel"].ToString();
         admin.AdminAccount = adminAccount;
         admin.AdminPwd = dr["adminPWD"].ToString();
         admin.AdminName = dr["adminName"].ToString();
     }
     return admin;
 }