private void ChonHoKhauEvent(HoKhau hoKhau) { phieuChuyenKhau = chuyenKhauBUS.ChuyenKhau(congDan, hkMoi: hoKhau); hoKhau.Update(congDan); setData(congDan); }
private PhieuChuyenKhau GetFromReader(SqlDataReader reader) { PhieuChuyenKhau phieu = new PhieuChuyenKhau(); phieu.Ma = int.Parse(reader["Ma"].ToString()); phieu.MaCongDan = int.Parse(reader["MaCongDan"].ToString()); phieu.MaHoKhauChuyenDen = int.Parse(reader["MaHoKhauChuyenDen"].ToString()); phieu.MaHoKhauChuyenTu = int.Parse(reader["MaHoKhauChuyenTu"].ToString()); string NgayChuyenKhau; NgayChuyenKhau = reader["NgayChuyenKhau"].ToString(); if (!string.IsNullOrEmpty(NgayChuyenKhau.Trim())) { phieu.NgayChuyenKhau = DateTime.Parse(NgayChuyenKhau); } phieu.CongDanChuyenKhau = CongDanDAL.GetInstance().Read(phieu.MaCongDan); phieu.HoKhauChuyenTu = HoKhauDAL.GetInstance().Read(phieu.MaHoKhauChuyenTu); phieu.HoKhauChuyenDen = HoKhauDAL.GetInstance().Read(phieu.MaHoKhauChuyenDen); phieu.SelfUpdate(); return(phieu); }
public FrmChiTietChuyenKhau(PhieuChuyenKhau phieu) { InitializeComponent(); if (phieu != null) { SetCongDanWidgets(phieu.CongDanChuyenKhau); SetHoKhauChuyenTuWidgets(phieu.HoKhauChuyenTu); SetHoKhauChuyenDenWidgets(phieu.HoKhauChuyenDen); dtpNgayChuyenKhau.Value = phieu.NgayChuyenKhau; } }
private void DgvPhieuChuyenKhau_CellClick(object sender, DataGridViewCellEventArgs e) { int numrow; numrow = e.RowIndex; if (numrow == -1) { disableSelect(); } else { enableSelect(); chuyenKhauSelect = listPhieuChuyenKhau[numrow]; } }
public bool Add(PhieuChuyenKhau phieu) { string query = string.Empty; query += @" INSERT INTO [PHIEU_CHUYEN_KHAU] ( [MaCongDan], [MaHoKhauChuyenTu], [MaHoKhauChuyenDen], [NgayChuyenKhau] )"; query += @"VALUES ( @MaCongDan, @MaHoKhauChuyenTu, @MaHoKhauChuyenDen, @NgayChuyenKhau )"; using (SqlConnection _cnn = new SqlConnection(ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = _cnn; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = query; cmd.Parameters.AddWithValue("@MaCongDan", phieu.MaCongDan); cmd.Parameters.AddWithValue("@MaHoKhauChuyenTu", phieu.MaHoKhauChuyenTu); cmd.Parameters.AddWithValue("@MaHoKhauChuyenDen", phieu.MaHoKhauChuyenDen); cmd.Parameters.AddWithValue("@NgayChuyenKhau", phieu.NgayChuyenKhau); try { _cnn.Open(); cmd.ExecuteNonQuery(); _cnn.Close(); _cnn.Dispose(); } catch (Exception ex) { _cnn.Close(); return(false); } } } return(true); }
public List <PhieuChuyenKhau> ReadAll() { string query = string.Empty; query += "SELECT * "; query += "FROM [PHIEU_CHUYEN_KHAU]"; List <PhieuChuyenKhau> phieus = new List <PhieuChuyenKhau>(); using (SqlConnection con = new SqlConnection(ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = query; try { con.Open(); SqlDataReader reader = null; reader = cmd.ExecuteReader(); if (reader.HasRows == true) { while (reader.Read()) { PhieuChuyenKhau phieu = GetFromReader(reader); phieus.Add(phieu); } } con.Close(); con.Dispose(); } catch (Exception ex) { con.Close(); return(null); } } } return(phieus); }
public PhieuChuyenKhau ChuyenKhau(CongDan cd, HoKhau hkMoi) { HoKhau hkCu = HoKhauDAL.GetInstance().ReadBySoHoKhau(cd.MaHoKhau); if (hkCu == null) { return(null); } if (hkCu.Ma == hkMoi.Ma) { return(null); } PhieuChuyenKhau phieu = new PhieuChuyenKhau(); phieu.NgayChuyenKhau = Init.DATE; phieu.MaCongDan = cd.Ma; phieu.MaHoKhauChuyenTu = hkCu.Ma; phieu.MaHoKhauChuyenDen = hkMoi.Ma; return(phieu); }
public bool Add(PhieuChuyenKhau phieu) { return(PhieuChuyenKhauDAL.GetInstance().Add(phieu)); }