public List <HoKhau_QuanHe> findByMaHK(string id) { try { string sqlString = "select * from HoKhau_QuanHe Where maHK = '" + id + "'"; DataSet ds = db.ExecuteQueryDataSet(sqlString, CommandType.Text); DataTable dt = ds.Tables[0]; List <HoKhau_QuanHe> hoKhau_QuanHes = new List <HoKhau_QuanHe>(); foreach (DataRow dr in dt.Rows) { HoKhau_QuanHe hk = new HoKhau_QuanHe() { maHK = (string)dr.ItemArray[0], maCD = (string)dr.ItemArray[1], idQuanHe = (int)dr.ItemArray[2], QuanHe = ketNoiQuanHe.findById((int)ds.Tables[0].Rows[0].ItemArray[2]) }; hoKhau_QuanHes.Add(hk); } return(hoKhau_QuanHes); } catch (Exception e) { MessageBox.Show("Lỗi findByMaHK HoKhau_QuanHe + " + e.Message); return(null); } }
public bool taoQuanHe(string maHK, string maCD, int idQuanHe) { HoKhau_QuanHe hoKhauQuanHe = new HoKhau_QuanHe(maHK, maCD, idQuanHe); if (hoKhauQuanHeDAO.create(hoKhauQuanHe)) { MessageBox.Show("Tạo quan hệ thành công"); return(true); } return(false); }
public Form10() { InitializeComponent(); dt = new DataTable(); hoKhauQuanHes = new List <HoKhau_QuanHe>(); CongDans = new List <CongDan>(); hoKhauController = new QuanLyHoKhau(); tempHoKhauQuanHe = null; tempCongDan = null; quanHeDAO = new KetNoiQuanHe(); }
public bool create(HoKhau_QuanHe entity) { try { string sqlString = "INSERT INTO HoKhau_QuanHe VALUES ('" + entity.maHK + "','" + entity.maCD + "','" + entity.idQuanHe + "')"; return(db.MyExecuteNonQuery(sqlString, CommandType.Text)); } catch (Exception e) { MessageBox.Show("Lỗi create HoKhau_QuanHe + " + e.Message); return(false); } }
private void simpleButton1_Click(object sender, EventArgs e) { if (r2 == -1) { MessageBox.Show("Chưa chọn thành viên "); return; } if (!chonQuanHe) { MessageBox.Show("Chưa chọn quan hệ với chủ hộ"); return; } tempCongDan = DanhSachThanhVienMoi[r2].CongDan; if (DanhSachThanhVienMoi[r2].idQuanHe != 1) { DanhSachThanhVienMoi.Remove(DanhSachThanhVienMoi[r2]); QuanHe temp = (QuanHe)cmbQuanHe.SelectedItem; tempHoKhauQuanHe = new HoKhau_QuanHe(tempCongDan, temp); foreach (HoKhau_QuanHe qh in DanhSach) { if (qh.QuanHe.id == 1) { flag++; } } if (flag > 0 && tempHoKhauQuanHe.QuanHe.id == 1) { MessageBox.Show("Đã có chủ hộ rồi rồi"); return; } DanhSach.Add(tempHoKhauQuanHe); loadThanhVienMoi(); loadThanhVien(); reset(); } else { MessageBox.Show("Không được chuyển chủ hộ"); tempCongDan = null; r2 = -1; return; } }
public bool edit(HoKhau_QuanHe enitity) { try { string sqlString = " UPDATE HoKhau_QuanHe " + " SET maHk = '" + enitity.maHK + "'" + ",maCD = '" + enitity.maCD + "'" + ",idQuanHe = '" + enitity.idQuanHe + "'" + "WHERE maHK = '" + enitity.maHK + "' AND maCD = '" + enitity.maCD + "'"; return(db.MyExecuteNonQuery(sqlString, CommandType.Text)); } catch (Exception e) { MessageBox.Show("Lỗi edit HoKhau_QuanHe + " + e.Message); return(false); } }
public HoKhau_QuanHe getByAll(string maCD, string maHK) { try { string sqlString = "select * from HoKhau_QuanHe Where maHK = '" + maHK + "' AND maCD = '" + maCD + "'"; DataSet ds = db.ExecuteQueryDataSet(sqlString, CommandType.Text); HoKhau_QuanHe hk = new HoKhau_QuanHe() { maHK = (string)ds.Tables[0].Rows[0].ItemArray[0], maCD = (string)ds.Tables[0].Rows[0].ItemArray[1], idQuanHe = (int)ds.Tables[0].Rows[0].ItemArray[2], QuanHe = ketNoiQuanHe.findById((int)ds.Tables[0].Rows[0].ItemArray[2]) }; return(hk); } catch (Exception e) { MessageBox.Show("Lỗi getByAll HoKhau_QuanHe + " + e.Message); return(null); } }
private void btnXacNhan_Click(object sender, EventArgs e) { int flag = 0; if (tempCongDan != null) { if (!chonQuanHe) { MessageBox.Show("Chưa chọn quan hệ"); return; } QuanHe temp = (QuanHe)cmbQuanHe.SelectedItem; tempHoKhauQuanHe = new HoKhau_QuanHe(tempCongDan, temp); foreach (HoKhau_QuanHe qh in hoKhauQuanHes) { if (qh.CongDan.Equals(tempCongDan)) { MessageBox.Show("Đã thêm người này rồi"); return; } if (qh.QuanHe.id == 1) { flag++; } } if (flag > 0 && tempHoKhauQuanHe.QuanHe.id == 1) { MessageBox.Show("Đã có chủ hộ rồi rồi"); return; } hoKhauQuanHes.Add(tempHoKhauQuanHe); CongDans.Add(tempCongDan); loadThanhVien(); } else { MessageBox.Show("Chưa nhập CMND thành viên"); } reset(); }