Ejemplo n.º 1
0
        private void btncapnhat_Click(object sender, EventArgs e)
        {
            string mkmoi  = txtmkmoi.Text;
            string mkmoi2 = txtnhaplaimkmoi.Text;
            string mkcu   = txtmkcu.Text;

            if (mkcu == "" || mkmoi == "" || mkmoi2 == "")
            {
                MessageBox.Show("Không được bỏ trống!");
                txtmkcu.Clear();
                txtmkmoi.Clear();
                txtnhaplaimkmoi.Clear();
                txtmkcu.Focus();
            }
            else
            {
                if (txtmkmoi.Text.CompareTo(txtnhaplaimkmoi.Text) == 0)
                {
                    cn.OpenConn();
                    string cm1 = "update CANBO set MATKHAU='" + txtnhaplaimkmoi.Text + "' where MACB='" + txtUser.Text + "' and MATKHAU ='" + txtmkcu.Text + "' ";
                    try
                    {
                        if (cn.executeUpdate(cm1) == true)
                        {
                            MessageBox.Show("Cập nhật mật khẩu thành công");
                            this.Dispose();
                        }
                        else
                        {
                            MessageBox.Show("Mật khẩu củ không trùng khớp!");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("" + ex.ToString());
                    }
                }
                else
                {
                    MessageBox.Show("Mật khẩu mới không trùng khớp!");
                }
            }
        }