private void btnXoa_Click(object sender, EventArgs e) { string TenDangNhap; string MatKhau; int row = this.listView1.SelectedItems[0].Index; TenDangNhap = this.listView1.Items[row].SubItems[0].Text; MatKhau = this.listView1.Items[row].SubItems[1].Text; SqlConnection con = new SqlConnection(); con.ConnectionString = KetNoi.str; con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "DELETE FROM QuanLyNguoiDung WHERE TenDangNhap='" + TenDangNhap + "' and MatKhau='" + MatKhau + "'"; DialogResult result; result = MessageBox.Show("Bạn Muốn Xoá Dữ Liệu Người Dùng Không?", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Xoá Dữ Liệu Thành Công"); this.Close(); frmDanhSachNguoiDung frm = new frmDanhSachNguoiDung(); frm.Show(); } }
private void btnThoat_Click(object sender, EventArgs e) { this.Close(); frmDanhSachNguoiDung frm = new frmDanhSachNguoiDung(); frm.Show(); }
private void btnDangNhap_Click(object sender, EventArgs e) { DangNhapNguoiDung login = new DangNhapNguoiDung(); if (login.DangNhap(txtTenDangNhap.Text, txtMatKhau.Text, txtQuyenHan.Text) == true) { MessageBox.Show("Xin Chào Admin", "Đăng Nhập Thành Công", MessageBoxButtons.OK, MessageBoxIcon.Warning); frmDanhSachNguoiDung frm = new frmDanhSachNguoiDung(); this.Close(); frm.Show(); } else { MessageBox.Show("Thông Tin Không Đúng.Xin vui Lòng Kiểm Tra Lại", "Lỗi Đăng Nhập", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnThem_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(); con.ConnectionString = KetNoi.str; con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; string QuyenHan; QuyenHan = this.cboQuyenHan.SelectedItem.ToString(); cmd.CommandText = "INSERT INTO QuanLyNguoiDung VALUES('" + txtTenDangNhap.Text + "','" + txtMatKhau.Text + "','" + QuyenHan + "')"; cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Thêm Dữ Liệu Thành Công"); this.Close(); frmDanhSachNguoiDung frm = new frmDanhSachNguoiDung(); frm.Show(); }
private void btnSua_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(); con.ConnectionString = KetNoi.str; con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "UPDATE QuanLyNguoiDung SET QuyenHan='" + txtQuyenHan.Text + "' WHERE TenDangNhap='" + txtTenDangNhap.Text + "' AND MatKhau='" + txtMatKhau.Text + "'"; DialogResult result; result = MessageBox.Show("Bạn Có Muốn Thay Đổi Thông Tin Không?", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Sửa Thông Tin Thành Công"); this.Close(); frmDanhSachNguoiDung frm = new frmDanhSachNguoiDung(); frm.Show(); } }