using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

public partial class personal_updatepwd : PageBase
{
    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["constring"].ConnectionString);



    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {

            string struer = Session["uid"].ToString();

            string strsql = "select loginname from tabP_Personnel where pid = '" + struer + "'";
            string strsql1 = "select pwd from tabP_Personnel where pid = '" + struer + "'";
            SqlCommand com = new SqlCommand(strsql, conn);
            SqlCommand com1 = new SqlCommand(strsql1, conn);
            conn.Open();
            string strname = Convert.ToString(com.ExecuteScalar());
            string strpwd = Convert.ToString(com1.ExecuteScalar());
            Labyhm.Text = strname;
            conn.Close();

        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string struer = Session["uid"].ToString();

        string strsql1 = "select pwd from tabP_Personnel where pid = '" + struer + "'";
        SqlCommand com1 = new SqlCommand(strsql1, conn);

        conn.Open();
        string strpwd = Convert.ToString(com1.ExecuteScalar());
        conn.Close();


        if (Textpwd.Text != strpwd)
        {
            Response.Write("<script>alert('原密码不对！')</script>");
        }
        else
        {
            if (TextBox2.Text != TextBox3.Text)
            {
                Response.Write("<script>alert('两次密码不一致！')</script>");
            }
            else
            {
                string strsql = "update tabP_Personnel set pwd='" + TextBox2.Text + "' where pid = '" + struer + "'";
                SqlCommand com = new SqlCommand(strsql, conn);
                conn.Open();
                com.ExecuteScalar();
                conn.Close();
                Response.Write("<script>alert('修改成功！')</script>");
            }

        }
    }
}
