Exemple #1
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (DAL.NguoiDung_Model.matkhau.Equals(txtMKCu.Text.Trim()))
     {
         if (txtXacNhan.Text.Trim().Equals(txtMKMoi.Text.Trim()))
         {
             string         TaiKhoan = DAL.NguoiDung_Model.taikhoan;
             string         MatKhau  = txtMKMoi.Text.Trim();
             string         query    = "update NGUOIDUNG set MatKhau = '" + MatKhau + "' where TaiKhoan = '" + TaiKhoan + "'";
             DAL.sqlConnect sqlConn  = new DAL.sqlConnect();
             try
             {
                 sqlConn.openConnection();
                 SqlCommand cmd = new SqlCommand(query, sqlConn.Conn);
                 cmd.ExecuteNonQuery();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             finally
             {
                 DAL.NguoiDung_Model.matkhau = MatKhau;
                 sqlConn.closeConnection();
             }
             MessageBox.Show("Đổi mật khẩu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Close();
         }
         else
         {
             MessageBox.Show("Mật khâu không khớp", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Mật khẩu không chính xác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         txtMKCu.Focus();
     }
 }
Exemple #2
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            string query = "select q.Them, q.Sua, q.Xoa, q.Ad from QUYENHAN q, NGUOIDUNG n where q.ID_QuyenHan = n.ID_QuyenHan and n.TaiKhoan = '" + DAL.NguoiDung_Model.taikhoan + "' and n.MatKhau = '" + DAL.NguoiDung_Model.matkhau + "'";

            DAL.sqlConnect sqlConn = new DAL.sqlConnect();
            sqlConn.openConnection();
            SqlDataReader dr = sqlConn.execCommand(query);

            while (dr.Read())
            {
                if (dr["Ad"].ToString().Equals("True"))
                {
                    mnuHT_QLND.Enabled = true;
                    mnuHT_PQ.Enabled   = true;
                }
                else
                {
                    mnuHT_QLND.Enabled = false;
                    mnuHT_PQ.Enabled   = false;
                }

                if (dr["Them"].ToString().Equals("False") && dr["Sua"].ToString().Equals("False") && dr["Xoa"].ToString().Equals("False"))
                {
                    mnuDM.Enabled = false;
                }
                else
                {
                    mnuDM.Enabled = true;
                }
            }
            //DAL.NguoiDung_Model nd = new DAL.NguoiDung_Model();
            //nd.checkPermission(btnThemKH, btnSuaKH, btnXoaKH);
            //loadLsvKhachHang();
            //pnlThemKH.Visible = false;
            lockControl();
        }