コード例 #1
0
        public void LoadData()
        {
            if (ds != null)
            {
                ds.Clear();
                dscv.Clear();
            }
            dscv = chucVuBLL.getListChucVu();
            tbChucVu.DataSource    = dscv.Tables[0];
            tbChucVu.DisplayMember = "tenChucVu";
            tbChucVu.ValueMember   = "chucVuID";

            ds = nguoiDungBLL.ListUser();
            datagridNguyenLieu.DataSource = ds.Tables[0];

            // binding
            txtTaiKhoan.Enabled = false;
            XoaText();

            txtTaiKhoan.DataBindings.Clear();
            txtHoTen.DataBindings.Clear();
            txtDanToc.DataBindings.Clear();
            txtDienThoai.DataBindings.Clear();
            txtNoiO.DataBindings.Clear();
            tbChucVu.DataBindings.Clear();
            tbGioiTinh.DataBindings.Clear();
            dtpNgaySinh.DataBindings.Clear();
            dtpNgayVaoLam.DataBindings.Clear();
            txtPassword.DataBindings.Clear();
            nudLuongGio.DataBindings.Clear();

            txtTaiKhoan.DataBindings.Add("Text", ds.Tables[0], "taiKhoan");
            txtHoTen.DataBindings.Add("Text", ds.Tables[0], "hoTen");
            txtDanToc.DataBindings.Add("Text", ds.Tables[0], "danToc");
            txtDienThoai.DataBindings.Add("Text", ds.Tables[0], "dienThoai");
            txtNoiO.DataBindings.Add("Text", ds.Tables[0], "noiO");

            tbChucVu.DataBindings.Add("SelectedValue", ds.Tables[0], "chucVuID");
            tbGioiTinh.DataBindings.Add("Text", ds.Tables[0], "gioiTinh");
            dtpNgaySinh.DataBindings.Add("Text", ds.Tables[0], "ngaySinh");
            dtpNgayVaoLam.DataBindings.Add("Text", ds.Tables[0], "ngayBatDau");
            txtPassword.DataBindings.Add("Text", ds.Tables[0], "matKhau");
            nudLuongGio.DataBindings.Add("Text", ds.Tables[0], "luongGioHT");
        }