Beispiel #1
0
        private void btnThemMoi_Click(object sender, EventArgs e)
        {
            KhachThue khach = new KhachThue();

            if (txtCMND.Text.ToString() == "" || txtMaKhach.Text.ToString() == "" || txtNgheNghiep.Text.ToString() == null || txtQueQuan.Text.ToString() == null || txtTenKhach.Text.ToString() == null || cbGioiTinh.Text.ToString() == null)
            {
                MessageBox.Show("Hãy điền đầy đủ thông tin");
            }

            else
            {
                khach.setMaKhach(txtMaKhach.Text.ToString());
                khach.setCmnd(txtCMND.Text.ToString());
                khach.setNghenghiep(txtNgheNghiep.Text.ToString());
                khach.setQuequan(txtQueQuan.Text.ToString());
                khach.setTenKhach(txtTenKhach.Text.ToString());
                khach.setPhai(cbGioiTinh.Text.ToString());

                khachThueBLL.ThemKhachThueVaoPhongMoi(khach);
                dgvDSKhachThue.DataSource = khachThueBLL.LoadKhachThue();

                MessageBox.Show("Thêm khách thành công.");
            }
            txtCMND.Enabled       = false;
            txtMaKhach.Enabled    = false;
            txtNgheNghiep.Enabled = false;
            txtQueQuan.Enabled    = false;
            txtTenKhach.Enabled   = false;
            cbGioiTinh.Enabled    = false;
        }
Beispiel #2
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            DataGridViewRow updaterow = dgvDSKhachThue.Rows[indexRowKhach];

            if (updaterow.Cells[0].Value == null || updaterow.Cells[1].Value == null || updaterow.Cells[2].Value == null || updaterow.Cells[3].Value == null || updaterow.Cells[4].Value == null || updaterow.Cells[5].Value == null)
            {
                MessageBox.Show("Hãy chọn khách hàng cần cập nhật");
            }
            else
            {
                KhachThue khach = new KhachThue();
                khach.setMaKhach(txtMaKhach.Text.ToString());
                khach.setCmnd(txtCMND.Text.ToString());
                khach.setNghenghiep(txtNgheNghiep.Text.ToString());
                khach.setQuequan(txtQueQuan.Text.ToString());
                khach.setTenKhach(txtTenKhach.Text.ToString());
                khach.setPhai(cbGioiTinh.Text.ToString());

                khachThueBLL.SuaKhachThue(khach);
                dgvDSKhachThue.DataSource = khachThueBLL.LoadKhachThue();
            }
            txtCMND.Enabled       = false;
            txtMaKhach.Enabled    = false;
            txtNgheNghiep.Enabled = false;
            txtQueQuan.Enabled    = false;
            txtTenKhach.Enabled   = false;
            cbGioiTinh.Enabled    = false;
        }
Beispiel #3
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     try
     {
         int selectedIndex = dgvDSKhachThue.CurrentCell.RowIndex;
         if (selectedIndex > -1)
         {
             KhachThue khach = new KhachThue();
             khach.setMaKhach(txtMaKhach.Text.ToString());
             khachThueBLL.XoaKhachThue(khach);
             dgvDSKhachThue.DataSource = khachThueBLL.LoadKhachThue();
         }
     }
     catch (InvalidOperationException ex)
     {
         throw ex;
     }
 }