private void btnSua_Click(object sender, EventArgs e) { if (dgvDSKyThi.RowCount > 0) { if (cbbLoaiKyThi.SelectedIndex == -1 || txtTenKyThi.Text == "" || cbbDeThi.SelectedIndex == -1 || cbbLoaiDeThi.SelectedIndex == -1 || cbbLop.SelectedIndex == -1 || dtGioThi.Text == "" || dtNgayThi.Text == "") { MessageBox.Show("Bạn chưa nhập đủ thông tin!!!"); return; } _objkythi = new KyThi(dgvDSKyThi.CurrentRow.Cells[0].Value.ToString(), txtTenKyThi.Text, _objloaidethibus.GetMa_TheoTen_LoaiDeThi(cbbLoaiDeThi.Text), _objdethibus.GetMa_TheoTen_DeThi(cbbDeThi.Text), _objlopbus.GetMa_TheoTen_LopHoc(cbbLop.Text), dtNgayThi.Text, dtGioThi.Text, _objphonghocbus.GetMa_TheoTen_PhongHoc(cbbPhongThi.Text), _objloaikythibus.GetMa_TheoTen_LoaiKyThi(cbbLoaiKyThi.Text)); if (_objkythibus.EditKyThi(_objkythi)) { MessageBox.Show("Sửa Thành Công!!! ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadData(); resetbox(); } else { MessageBox.Show("Sửa Thất Bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Không có dữ liệu để sửa!!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnLuu_Click(object sender, EventArgs e) { if (dgvKyThi.Rows.Count > 0) { for (int i = 0; i < dgvKyThi.Rows.Count; i++) { _objkythi = new KyThi(_objkythibus.KyThi_NextID(), dgvKyThi.Rows[i].Cells[1].Value.ToString(), _objloaidethibus.GetMa_TheoTen_LoaiDeThi(dgvKyThi.Rows[i].Cells[2].Value.ToString()), _objdethibus.GetMa_TheoTen_DeThi(dgvKyThi.Rows[i].Cells[3].Value.ToString()), _objlopbus.GetMa_TheoTen_LopHoc(dgvKyThi.Rows[i].Cells[4].Value.ToString()), dgvKyThi.Rows[i].Cells[5].Value.ToString(), dgvKyThi.Rows[i].Cells[6].Value.ToString(), _objphonghocbus.GetMa_TheoTen_PhongHoc(dgvKyThi.Rows[i].Cells[7].Value.ToString()), _objloaikythibus.GetMa_TheoTen_LoaiKyThi(cbbLoaiKyThi.Text)); if (_objkythibus.AddKyThi(_objkythi)) { dgvKyThi.Rows.Remove(dgvKyThi.Rows[i]); i--; LoadData(); resetbox(); } else { string a = dgvKyThi.Rows[i].Cells[0].Value.ToString(); MessageBox.Show("Lưu dòng " + a + "thất bại!!!"); } if (dgvKyThi.Rows.Count == 0) { MessageBox.Show("Lưu thành công!!!"); } } } else { MessageBox.Show("Không có dữ liệu để lưu!!!"); } }