Ejemplo n.º 1
0
        // chưa có xác trùng khóa

        public void LoadData()
        {
            loaiNVBindingSource.DataSource = LoaiNvBUS.GetLNV();
            txtMa.ResetText();
            txtTenLoai.ResetText();
            // Không cho thao tác trên các nút Lưu / Hủy
            btnLuu.Enabled = false;
            btnHuy.Enabled = false;
            panel.Enabled  = false;
            // Cho thao tác trên các nút Thêm / Sửa / Xóa / Thoát
            btnThem.Enabled = true;
            btnSua.Enabled  = true;
            btnXoa.Enabled  = true;
        }
Ejemplo n.º 2
0
        private void dgvNhanVien_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            cboCH.DataSource        = CuaHangBUS.GetAllCuaHang();
            cboCH.DisplayMember     = "TenCuaHang";
            cboCH.ValueMember       = "MaCuaHang";
            cboLoaiNV.DataSource    = LoaiNvBUS.GetLNV();
            cboLoaiNV.DisplayMember = "TenLoaiNV";
            cboLoaiNV.ValueMember   = "MaLoaiNV";

            // Lấy thứ tự record hiện hành
            int r = dgvNhanVien.CurrentCell.RowIndex;

            txtMaNV.Text            = dgvNhanVien.Rows[r].Cells[0].Value.ToString();
            cboCH.SelectedValue     = dgvNhanVien.Rows[r].Cells[1].Value.ToString();
            cboLoaiNV.SelectedValue = dgvNhanVien.Rows[r].Cells[2].Value.ToString();
            txtTenNV.Text           = dgvNhanVien.Rows[r].Cells[3].Value.ToString();
            cboSex.Text             = dgvNhanVien.Rows[r].Cells[4].Value.ToString();
            try
            {
                txtDiaChi.Text = dgvNhanVien.Rows[r].Cells[5].Value.ToString();
            }
            catch { txtDiaChi.Text = " "; }

            try
            {
                txtSDT.Text = dgvNhanVien.Rows[r].Cells[6].Value.ToString();
            }
            catch
            {
                txtSDT.Text = " ";
            }
            try
            {
                txtLuong.Text = dgvNhanVien.Rows[r].Cells[7].Value.ToString();
            }
            catch
            {
                txtLuong.Text = " ";
            }
        }