void LoadData() { try { dgvLogin.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgvLogin.AllowUserToAddRows = false; dgvLogin.ReadOnly = true; dgvLogin.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dgvLogin.DataSource = dbLogin.LayLogin(); groupBox1.Enabled = false; // Không cho thao tác trên các nút Lưu / Hủy this.btnSave.Enabled = false; this.btnCancel.Enabled = false; this.groupBox1.Enabled = false; this.txtTaikhoan.Enabled = false; // Cho thao tác trên các nút Thêm / Sửa / Xóa /Thoát this.btnAdd.Enabled = true; this.btnEdit.Enabled = true; this.btnDel.Enabled = true; } catch { MessageBox.Show("Không lấy được nội dung trong table . Lỗi rồi!!!"); } }
public void LoadData() { /*try * {*/ dtLogin = new DataTable(); dtLogin.Clear(); DataSet ds = dbLogin.LayLogin(); dtLogin = ds.Tables[0]; dgvLogin.DataSource = dtLogin; dgvLogin.AutoResizeColumns(); this.mskPhone.ResetText(); this.txtEmail.ResetText(); this.txtTaiKhoan.ResetText(); this.txtMatKhau.ResetText(); this.cboQuyen.ResetText(); this.btnLuu.Enabled = false; this.btnHuyBo.Enabled = false; this.grbTTCT.Enabled = false; this.btnThem.Enabled = true; this.btnSua.Enabled = true; this.btnXoa.Enabled = true; this.btnLuu.BackgroundImage = image_save_off; this.btnHuyBo.BackgroundImage = image_cancel_off; this.btnThem.BackgroundImage = image_add; this.btnSua.BackgroundImage = image_update; this.btnXoa.BackgroundImage = image_delete; this.lblLuu.ForeColor = Color.Gray; this.lblHuyBo.ForeColor = Color.Gray; this.lblThem.ForeColor = Color.SteelBlue; this.lblSua.ForeColor = Color.SteelBlue; this.lblXoa.ForeColor = Color.SteelBlue; dgvLogin_CellClick(null, null); /*} * catch * { * MessageBox.Show("Không lấy được nội dung trong table LOGIN. Lỗi rồi!!!" + err); * }*/ }