Beispiel #1
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (txtMKCu.Text.Trim().Equals(DAL.NguoiDung_Controller.matkhau))
     {
         if (txtMKMoi.Text.Trim().Equals(txtXacNhan.Text.Trim()))
         {
             string      query = "update NGUOIDUNG set MatKhau = '" + txtMKMoi.Text.Trim() + "' where MaNV = '" + DAL.NguoiDung_Controller.MaNV + "'";
             DAL.Connect conn  = new DAL.Connect();
             conn.openConnection();
             SqlCommand cmd = new SqlCommand(query, conn.Conn);
             cmd.ExecuteNonQuery();
             DAL.NguoiDung_Controller.matkhau = txtMKMoi.Text.Trim();
             this.Close();
         }
         else
         {
             MessageBox.Show("Mật khẩu không khớp", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txtXacNhan.Focus();
         }
     }
     else
     {
         MessageBox.Show("Mật khẩu không chính xác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         txtMKCu.Focus();
     }
 }
Beispiel #2
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            string query = "select Them, Sua, Xoa, CreateLogin from NGUOIDUNG where MaNV = '" + DAL.NguoiDung_Controller.MaNV + "' and MatKhau = '" + DAL.NguoiDung_Controller.matkhau + "'";

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

            while (dr.Read())
            {
                if (dr["CreateLogin"].ToString().Equals("True"))
                {
                    mnuHT_QLND.Enabled = true;
                }
                else
                {
                    mnuHT_QLND.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;
                }
            }
            this.KeyPreview = true;
        }
Beispiel #3
0
        private void showList()
        {
            //combobox.item.add();
            //combobox.selectedindex = 1
            string query = "select * from NGUOIDUNG";

            DAL.Connect conn = new DAL.Connect();
            conn.openConnection();
            SqlDataReader dr = conn.execCommand(query);

            while (dr.Read())
            {
                ListViewItem item = new ListViewItem();
                item.Text = dr["MaNV"].ToString().Trim();
                item.SubItems.Add(dr["MatKhau"].ToString().Trim());
                item.SubItems.Add(dr["Them"].ToString().Trim());
                item.SubItems.Add(dr["Sua"].ToString().Trim());
                item.SubItems.Add(dr["Xoa"].ToString().Trim());
                item.SubItems.Add(dr["CreateLogin"].ToString().Trim());
                lsvNguoiDung.Items.Add(item);
            }
        }