using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ResMangSys.DAL.UsersTableAdapters;

namespace ResMangSys
{
    public partial class ChangePassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["id"] == null)
                {
                    Response.Redirect("Login.aspx");
                }
            }
        }
        // 下载于www.51aspx.com
        protected void ChangePasswordPushButton_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                T_UsersTableAdapter adapter = new T_UsersTableAdapter();
                if (Session["pwd"].ToString() == CurrentPassword.Text.Trim())
                {
                    if (adapter.UpdatePwdById(NewPassword.Text.Trim(), Convert.ToInt32(Session["id"])) > 0)
                    {
                        Response.Redirect("ChangePasswordSuccess.aspx");
                    }
                    else
                    {
                        FailureText.Text = "密码修改失败！";
                    }
                }
                else
                {
                    FailureText.Text = "旧密码输入错误！";
                }
            }
        }
    }
}