private void Init() { txtMaPhieu.Text = PhieuTiepNhanBLL.GenMaPhieu().ToString(); txtMaHocSinh.Text = TreBLL.GenMaTre().ToString(); txtNgayTiepNhan.Text = DateTime.Now.ToShortDateString(); txtNguoiTiepNhan.Text = TaiKhoanBLL.GetTenNguoiDung(username); }
public static void ThemTreVaoDBTuExcel(DataTable data, string ngayTiepNhan, string nguoiTiepNhan) { if (data == null || data.Rows.Count == 0) { MessageBox.Show("Không có dữ liệu để import"); return; } try { for (int i = 0; i < data.Rows.Count; i++) { string maTre = TreBLL.GenMaTre(); Tre tre = new Tre(maTre, data.Rows[i][0].ToString().Trim(), // Họ tên Convert.ToInt32(data.Rows[i][1].ToString()), // Giới tính, DateTime.Parse(data.Rows[i][2].ToString().Trim()), // Ngày sinh data.Rows[i][3].ToString().Trim(), // Họ tên cha data.Rows[i][4].ToString().Trim(), // Họ tên mẹ data.Rows[i][5].ToString().Trim(), // Địa chỉ data.Rows[i][6].ToString().Trim()); // SĐT PhieuTiepNhanTre phieumoi = new PhieuTiepNhanTre(maTre, PhieuTiepNhanBLL.GenMaPhieu(), ngayTiepNhan, nguoiTiepNhan); try { TreBLL.ThemTre(tre); PhieuTiepNhanBLL.ThemPhieu(phieumoi); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } MessageBox.Show("Import hoàn tất", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("File nhập vào không đúng định dạng!\nVui lòng xem HDSD để chuẩn bị file có định dạng đúng", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }