CTI的修改密碼模塊和退出模塊

From1 準備傳值代碼:

Password pa = new Password();

            pa.MdiParent = this;//聲明 PassWord的父窗體是本窗體( Form1)
            pa.NaVa = NaVa;
            pa.PaVa = PaVa;

            pa.Show();


PassWord:

public string NaVa = string.Empty;
        public string PaVa = string.Empty;


點擊修改密碼:

private void button1_Click(object sender, EventArgs e)
        {
            if (this.txt_old.Text==PaVa)
            {
                if (this.txt_new.Text==this.txt_new2.Text)
                {

                    string str = ConfigurationManager.ConnectionStrings["sqlcnn"].ConnectionString;
                    SqlConnection cnn = new SqlConnection(str);
                    SqlCommand cmm = new SqlCommand();
                    cmm.Connection = cnn;
                    cmm.CommandText = "update T_Login set  Password=@password where UserName=@username";
                    cmm.Parameters.AddWithValue("@password", txt_new.Text);
                    cmm.Parameters.AddWithValue("@username", NaVa);
                    cnn.Open();
                    cmm.ExecuteNonQuery();
                    cnn.Close();
                    MessageBox.Show("密碼修改成功!");
                    
                    this.Close();
                }
                else
                {
                    txt_old.Text = "";
                    txt_new.Text = "";
                    txt_new2.Text = "";
                    MessageBox.Show("兩次輸入的密碼不一致,請重新輸入!");
                }
                return;
            }
        
            else
            {
                txt_old.Text = "";
                txt_new.Text = "";
                txt_new2.Text = "";
                MessageBox.Show("你輸入的密碼錯誤,請重新輸入!");

            }

//給子窗體定位,離頂部120px;

 private void Password_Load(object sender, EventArgs e)
        {
            this.Top = 120;
        }
      

//退出。結束整個進程

 Application.Exit();



            



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章