private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbSoSoHoKhau.Text) || cbbChuHo.SelectedValue == null || shkDTO.NhanKhau.Count == 0 ||
                string.IsNullOrEmpty(tbDiaChi.Text) || string.IsNullOrEmpty(tbSoDangKy.Text))
            {
                MessageBox.Show(this, "Vui lòng điền đầy đủ thông tin!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(shkDTO.SoSoHoKhau))
            {
                shkDTO = new SoHoKhauDTO(tbSoSoHoKhau.Text, cbbChuHo.SelectedValue.ToString(), tbDiaChi.Text, dtpNgayCap.Value, tbSoDangKy.Text, shkDTO.NhanKhau);
                shk.Add(shkDTO);
                foreach (NhanKhauThuongTruDTO item in shkDTO.NhanKhau)
                {
                    item.SoSoHoKhau = shkDTO.SoSoHoKhau;
                    nktt.Update(item);
                }
                //nktt.DoiChuHo(shkDTO.NhanKhau, cbbChuHo.SelectedValue.ToString());
                MessageBox.Show(this, "Tạo sổ hộ khẩu thành công!", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                shkDTO = new SoHoKhauDTO(tbSoSoHoKhau.Text, cbbChuHo.SelectedValue.ToString(), tbDiaChi.Text, dtpNgayCap.Value, tbSoDangKy.Text, shkDTO.NhanKhau);

                shk.Update(shkDTO);
                foreach (NhanKhauThuongTruDTO item in shkDTO.NhanKhau)
                {
                    item.SoSoHoKhau = shkDTO.SoSoHoKhau;
                    nktt.Update(item);
                }
                //nktt.DoiChuHo(shkDTO.NhanKhau, cbbChuHo.SelectedValue.ToString());
                MessageBox.Show(this, "Cập nhật sổ hộ khẩu thành công!", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            btnXoa.Enabled = true;
        }
Esempio n. 2
0
 public void ThemSoHoKhau(SoHoKhauDTO SoHoKhau)
 {
     Assert.AreEqual(true, SoHoKhau_BUS.Add(SoHoKhau));
 }