public void Load_Du_Lieu_Len_Gridview() { //Load dữ liệu lên Datagridview ThuVienKetNoi ketnoi = new ThuVienKetNoi(); dtgridview_phong.DataSource = ketnoi.GetTable("SELECT * FROM PHONG"); }
//Hàm kiểm tra người dùng có phải là admin hay không public bool is_admin(string user) { string str = "select * from NGUOIDUNG where TENDANGNHAP = N'" + user + "'"; ThuVienKetNoi ketnoi = new ThuVienKetNoi(); DataTable loainguoidung = ketnoi.GetTable(str); string lnd = loainguoidung.Rows[0][2].ToString(); if (lnd == "ADMIN") { return(true); } return(false); }
private void dtgridview_phong_SelectionChanged(object sender, EventArgs e) { txt_maphong.Text = dtgridview_phong.CurrentRow.Cells[0].Value.ToString(); txt_tenphong.Text = dtgridview_phong.CurrentRow.Cells[1].Value.ToString(); txt_giaphong.Text = dtgridview_phong.CurrentRow.Cells[2].Value.ToString(); txt_tinhtrang.Text = dtgridview_phong.CurrentRow.Cells[3].Value.ToString(); ThuVienKetNoi ketnoi = new ThuVienKetNoi(); cbo_maloaiphong.DataSource = ketnoi.GetTable("select MALOAIP from LOAIPHONG"); cbo_maloaiphong.DisplayMember = "MALOAIP"; cbo_maloaiphong.ValueMember = "MALOAIP"; cbo_maloaiphong.SelectedValue = dtgridview_phong.CurrentRow.Cells[4].Value.ToString(); txt_ghichu.Text = dtgridview_phong.CurrentRow.Cells[5].Value.ToString(); }
//Kiểm tra đăng nhập: 0 - Không tồn tại; 1 - Mật khẩu sai; 2 - Đăng nhập thành công, phân quyền public int KiemTraDangNhap(string tendangnhap, string matkhau) { string str = "select * from NGUOIDUNG where TENDANGNHAP = N'" + tendangnhap + "'"; ThuVienKetNoi ketnoi = new ThuVienKetNoi(); DataTable user = ketnoi.GetTable(str); if (user.Rows.Count == 0) { return(0); } string mk = user.Rows[0][1].ToString().Trim(); if (mk != matkhau) { return(1); } return(2); }
public void Load_Du_Lieu() { ThuVienKetNoi ketnoi = new ThuVienKetNoi(); dtgridview_nhanvien.DataSource = ketnoi.GetTable("SELECT * FROM NHANVIEN"); }