private void SuaKyThiForm_Load(object sender, EventArgs e) { qltn = Utils.QLTN.getInstance(); kythi = qltn.KyThis.Where(i => i.id == kythiid).First(); kythicustom = new KyThiCusTom(kythi); kythicustom.PropertyChanged += Kythicustom_PropertyChanged; var TenkythiBinding = new Binding("Text", kythicustom, "Tenkythi", true); var NgaybatdauBinding = new Binding("Value", kythicustom, "Ngaybatdau", true); var SongayBinding = new Binding("Value", kythicustom, "Songay", true); txtTen.DataBindings.Add(TenkythiBinding); dtNgayBD.DataBindings.Add(NgaybatdauBinding); numericSoNgay.DataBindings.Add(SongayBinding); getData(); loadLoaiKyThi(); cb.SelectedIndex = kythi.loaikythi == true ? 0 : 1; loadDeThi(); checkLVDeThi = true; checkLVHocSinh = true; if (cb.SelectedIndex == 0) { checkbox.Checked = true; checkbox.Enabled = false; } }
public bool AddKyThi(KyThi kt) { try { if (conn.State != ConnectionState.Open) { conn.Open(); } SqlCommand cmd = new SqlCommand("KyThi_Insert", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MaKyThi", SqlDbType.VarChar).Value = kt._makythi; cmd.Parameters.Add("@TenKyThi", SqlDbType.NVarChar).Value = kt._tenkythi; cmd.Parameters.Add("@NgayThi", SqlDbType.SmallDateTime).Value = kt._ngaythi; cmd.Parameters.Add("@GioThi", SqlDbType.Time).Value = kt._giothi; cmd.Parameters.Add("@MaPhongThi", SqlDbType.VarChar).Value = kt._maphongthi; cmd.Parameters.Add("@MaDeThi", SqlDbType.VarChar).Value = kt._madethi; cmd.Parameters.Add("@MaLoaiKyThi", SqlDbType.VarChar).Value = kt._maloaikythi; cmd.Parameters.Add("@MaLoaiDeThi", SqlDbType.VarChar).Value = kt._maloaidethi; cmd.Parameters.Add("@MaLop", SqlDbType.VarChar).Value = kt._malop; cmd.ExecuteNonQuery(); conn.Close(); return(true); } catch (Exception e) { conn.Close(); Console.WriteLine(e); return(false); } }
private void btn_TaoKyThi_Click(object sender, EventArgs e) { LTUDQL1DataContext themkt = new LTUDQL1DataContext(); KyThi kt = new KyThi(); kt.MaKT = txtmakt.Text; kt.Ngay = txtmant.Text; kt.MaDT = txtmadt.Text; kt.ThoiGian = txttg.Text; kt.MaHV = txtmahv.Text; if (kt.MaKT == "" && kt.MaHV == "") { MessageBox.Show("Không được bỏ trống Mã Kỳ Thi và Mã Học Viên!!!"); return; } else { themkt.KyThis.InsertOnSubmit(kt); themkt.SubmitChanges(); MessageBox.Show("Tạo thành công kỳ thi thử!!!"); LoadData(); } CleanTextBox(); }
private void button1_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Bạn có muốn thêm kì thi", "Thông tin", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.Cancel) { return; } int temp = kiThiBUS.InsertKiThi(comboBoxThemKiThiKT.SelectedValue.ToString(), comboBoxThemKiThiKT.Text, dateTimeThi.Value.Date); if (temp == 1) { MessageBox.Show("Lỗi , mã kiểm tra phải là GK hoặc CK", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (temp == 2) { MessageBox.Show("Lỗi , đã tồn tại Mã Kì Thi", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } MessageBox.Show("Thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); KyThi kiThi = kiThiBUS.GetOneKiThiCuoiCung(comboBoxThemKiThiKT.SelectedValue.ToString()); DanhSachDeTrongKiThi danhSachDeTrongKiThi = new DanhSachDeTrongKiThi(kiThi); danhSachDeTrongKiThi.ShowDialog(); this.Hide(); this.Close(); }
private void LoadKyThi() { List <string> kqThi = new List <string>(); kqThi = (from k in db.KetQuaThis select k.KyThi).ToList(); foreach (string idKQ in kqThi) { KyThi kt = (from k in db.KyThis where k.ID == idKQ select k).SingleOrDefault(); try { if (kt.SuDung == false) { kt.SuDung = true; db.SubmitChanges(); } } catch { } } dgvKyThi.DataSource = (from kt in db.KyThis select new { kt.ID, kt.NgayThi, kt.MaDe, kt.SuDung }); }
public bool EditKyThi(KyThi kt) { try { if (conn.State != ConnectionState.Open) { conn.Open(); } SqlCommand cmd = new SqlCommand("EditKyThi", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MaKyThi", SqlDbType.NVarChar).Value = kt._makythi; cmd.Parameters.Add("@NgayThi", SqlDbType.DateTime).Value = kt._ngaythi; cmd.Parameters.Add("@GioThi", SqlDbType.Float).Value = kt._giothi; cmd.Parameters.Add("@MaPhongThi", SqlDbType.NVarChar).Value = kt._maphongthi; cmd.Parameters.Add("@MaDeThi", SqlDbType.NVarChar).Value = kt._madethi; cmd.ExecuteNonQuery(); conn.Close(); return(true); } catch { conn.Close(); return(false); } }
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 BtnSua_Click(object sender, EventArgs e) { if (lvKyThi.SelectedItems.Count == 0) { MessageBox.Show("Hãy chọn kỳ thi muốn sửa"); return; } using (var qltn = Utils.QLTN.getInstance()) { var kythi = qltn.KyThis.Where(i => i.id == int.Parse(lvKyThi.SelectedItems[0].SubItems[0].Text)).First(); KyThi kt = qltn.KyThis.Where(i => i.id == kythi.id).First(); var dsDeThi = qltn.DeThis.Where(i => i.kythiid == kt.id).ToList(); foreach (DeThi dt in dsDeThi) { var Hstg = qltn.HocSinhThamGias.Where(i => i.dethiid == dt.id && i.thoigianlambai.Length > 0); if (Hstg.ToList().Count > 0) { MessageBox.Show("Kỳ thi này đã có thí sinh làm bài"); return; } } } SuaKyThiForm f = new SuaKyThiForm(this, kythiid); f.ShowDialog(); }
private void frmMain_Load(object sender, EventArgs e) { //tabThi.Dispose(); lblNgayThi.Text = DateTime.Now.ToShortDateString(); loadCboDotThi(); loadCboLTK(); loadDSDT(); loadDSKT(); enableControls(); loadKT_MangayThi(); btnNopBai.Visible = false; lblTitleDiem.Visible = false; lblDiem.Visible = false; loadCH(); loadcontrol(false); KyThi kt = cauHoiBLL_DAL.getThoiGianLamBai(maKyThi); if (maLoaiTaiKhoan.Equals("TS")) { lblThoiGianConLai.Text = kt.ThoiGianLamBai.ToString() + ":00"; } if (isNhanVien) { loadThongTinCaNhan("TS"); } else { loadThongTinCaNhan(); } }
private void btnCreate_Click(object sender, EventArgs e) { string id = txtID.Text; var check = (from kt in db.KyThis where kt.ID == id select kt).SingleOrDefault(); if (check == null) { KyThi kt = new KyThi(); kt.ID = id; kt.NgayThi = dtpDate.Text.ToString(); kt.MaDe = int.Parse(cbMaDe.SelectedValue.ToString()); kt.SuDung = false; db.KyThis.InsertOnSubmit(kt); try { db.SubmitChanges(); ShowInsertStudent(); MessageBox.Show("Thêm kỳ thi thành công"); DisableInfo(); } catch { MessageBox.Show("Lỗi thêm kỳ thi vào database"); } } else { MessageBox.Show("Đã tồn tại id kỳ thi trong database"); } }
private void BtnXoa_Click(object sender, EventArgs e) { if (lvKyThi.SelectedItems.Count == 0) { MessageBox.Show("Hãy chọn kỳ thi muốn xóa"); return; } if (lvKyThi.SelectedItems[0].BackColor == Color.Red) { MessageBox.Show("Không thể xóa kỳ thi này"); return; } using (var qltn = Utils.QLTN.getInstance()) { var kythi = qltn.KyThis.Where(i => i.id == int.Parse(lvKyThi.SelectedItems[0].SubItems[0].Text)).First(); KyThi kt = qltn.KyThis.Where(i => i.id == kythi.id).First(); var dsDeThi = qltn.DeThis.Where(i => i.kythiid == kt.id).ToList(); foreach (DeThi dt in dsDeThi) { var Hstg = qltn.HocSinhThamGias.Where(i => i.dethiid == dt.id); qltn.HocSinhThamGias.DeleteAllOnSubmit(Hstg); } foreach (DeThi dt in dsDeThi) { dt.ngaythi = null; dt.kythiid = null; } qltn.KyThis.DeleteOnSubmit(kythi); qltn.SubmitChanges(); } loadLVKyThi(); }
public KyThi GetOneKyThiONMaKhiThi(string MaKyThi) { /* * Tìm kì thi thông qua mã kì thi * Nếu không tìm thấy -> trả về null * Nếu tìm thấy -> trả về kì thi */ using (DataContextDataContext DB = new DataContextDataContext()) { KyThi getOneKyThi = new KyThi(); var KyThi = from KH in DB.KyThis where KH.MaKyThi == MaKyThi select KH; if (KyThi.Count() == 0) { return(null); } foreach (var kh in KyThi) { getOneKyThi.MaKyThi = kh.MaKyThi; getOneKyThi.TenKyThi = kh.TenKyThi; getOneKyThi.NgayThi = kh.NgayThi; } return(getOneKyThi); } }
private void btnXacNhan_Click(object sender, System.EventArgs e) { KyThi kyThi = _kyThiRepos.FindByCondition(p => p.MaKT.Equals(cbKyThi.SelectedValue.ToString())).Single(); DeThi deThi = _deThiRepos.FindByCondition(p => p.MaDeThi.Equals(cbDeThi.SelectedValue.ToString())).Single(); LamTracNgiemHS lamTracNgiemHS = new LamTracNgiemHS(kyThi, deThi, hocsinh); lamTracNgiemHS.ShowDialog(); }
public IActionResult Post(KyThi kythi) { if (HttpContext.Session.GetString("role") == "admin") { return(View()); } return(Redirect("/")); }
public int InsertKyThi(string MaKT, string TenKyThi, DateTime ThoiGianThi) { /* * Mã kì thi = KyThi+Nam+(01,02) 01 -> học kì 1 , 02 -> học kì 2 VD:KyThi201901 * Tên Kì Thi * Thời gian thi * Nếu Mã KT không phải 15 hoặc 1T hoặc không phải CK thì -> trả về 1 * Nếu MaKyThi đẫ tồn tại thì thì trả về 2 * * */ using (DataContextDataContext DB = new DataContextDataContext()) { string MaKyThi = "0"; if (MaKT != "GK" && MaKT != "CK") { return(1); } //KT2019KT01 KyThi KyThi1 = GetOneKyThiCuoiCung(MaKT); if (KyThi1 != null) { int SoCuoiCungTemp = Int32.Parse(KyThi1.MaKyThi.Substring(8, 2)); SoCuoiCungTemp++; if (SoCuoiCungTemp.ToString().Length == 1) { MaKyThi = "KT" + DateTime.Now.Year.ToString() + MaKT + "0" + SoCuoiCungTemp.ToString(); } if (SoCuoiCungTemp.ToString().Length == 2) { MaKyThi = "KT" + DateTime.Now.Year.ToString() + MaKT + SoCuoiCungTemp.ToString(); } } else { MaKyThi = "KT" + DateTime.Now.Year.ToString() + MaKT + "00"; } var findOneKyThi = from KT in DB.KyThis where KT.MaKyThi == MaKyThi select KT; if (findOneKyThi.Count() != 0) { return(2); } KyThi KyThi = new KyThi(); KyThi.MaKyThi = MaKyThi; KyThi.TenKyThi = TenKyThi; KyThi.NgayThi = ThoiGianThi; DB.KyThis.InsertOnSubmit(KyThi); DB.SubmitChanges(); return(0); } }
private void btnThemKT_Click(object sender, EventArgs e) { string maKT = maKTTextBox.Text; maKTTextBox.Undo(); if (_kyThiRepository.FindByCondition(p => p.MaKT.Equals(maKT)).Count() > 0) { MessageBox.Show("Mã kì thi đã tồn tại", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);; return; } _kyThiRepository = new KyThiRepository(); KyThi kt = new KyThi(); kt.MaKT = maKT; kt.TenKT = tenKTTextBox.Text; kt.NgayBD = ngayBDDateTimePicker.Value; kt.NgayKT = ngayKTDateTimePicker.Value; kt.MaCapHoc = int.Parse(maCapHocKTCombobox.SelectedValue.ToString()); kt.LoaiKT = int.Parse(loaiKTComboBox.SelectedValue.ToString()); _kyThiRepository.Create(kt); _kyThiRepository.Update(); foreach (DataGridViewRow item in dgvKTDT.Rows) { var cell = item.Cells["Chon"] as DataGridViewCheckBoxCell; if (cell.Value == cell.TrueValue) { string madethi = item.Cells["MaDeThi"].Value.ToString(); _KT_DT_RePository.Create(new KT_DT { MaDT = madethi, MaKT = maKT }); } } _KT_DT_RePository.Update(); foreach (DataGridViewRow item in dgvKTHS.Rows) { var cell = item.Cells["Chon"] as DataGridViewCheckBoxCell; if (cell.Value == cell.TrueValue) { string mahs = item.Cells["MaHS"].Value.ToString(); _KT_HS_Repository.Create(new KT_H { MaHS = mahs, MaKT = maKT }); } } _KT_HS_Repository.Update(); ReLoad(); }
public ActionResult Edit([Bind(Include = "IdKyThi,MaKyThi,TenKyThi,NgayTao,NguoiTao,ChuThich,isDelete,Status")] KyThi kyThi) { if (ModelState.IsValid) { db.Entry(kyThi).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(kyThi)); }
private void BtnTao_Click(object sender, EventArgs e) { if (txtTen.Text.Length == 0) { MessageBox.Show("Tên kỳ thi không được để trống"); return; } if (numericSoNgay.Value < 0) { MessageBox.Show("Số ngày không được nhỏ hơn 0"); return; } //them du lieu using (var qltn = Utils.QLTN.getInstance()) { var kythi = new KyThi() { tenkythi = txtTen.Text, loaikythi = (cb.SelectedIndex == 0 ? true : false), ngaybatdau = dtNgayBD.Value, songay = Decimal.ToInt32(numericSoNgay.Value) }; qltn.KyThis.InsertOnSubmit(kythi); qltn.SubmitChanges(); kythi = qltn.KyThis.ToList().Last(); foreach (DeThiCusTom dt in dsDeThiCustom) { if (dt.loaidethi != (cb.SelectedIndex == 0 ? true : false)) { continue; } if (dt.DuocCheck) { var dethidcchon = qltn.DeThis.Where(i => i.id == dt.deThiid).First(); dethidcchon.kythiid = kythi.id; if (dt.CoNgayThi) { dethidcchon.ngaythi = dt.NgayThi.Date; } //them hocsinh thamgia foreach (int i in dt.hocsinhid) { var hstg = new HocSinhThamGia(); hstg.dethiid = dethidcchon.id; hstg.hocsinhid = i; qltn.HocSinhThamGias.InsertOnSubmit(hstg); } } } qltn.SubmitChanges(); form.loadLVKyThi(); Close(); } }
// GET: Admins/KyThi_Ad/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } KyThi kyThi = db.KyThis.Find(id); if (kyThi == null) { return(View("~/Views/Shared/404Notfound.cshtml")); } return(View(kyThi)); }
public ActionResult Create([Bind(Include = "IdKyThi,MaKyThi,TenKyThi,NgayTao,NguoiTao,ChuThich,isDelete,Status")] KyThi kyThi) { kyThi.NgayTao = DateTime.Now; kyThi.isDelete = false; kyThi.Status = true; kyThi.NguoiTao = Session["idUser"].ToString(); if (ModelState.IsValid) { db.KyThis.Add(kyThi); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(kyThi)); }
private void btnThiThu_Click(object sender, EventArgs e) { if (dgvTTKyThiThu.SelectedRows.Count > 0) { int madt = int.Parse(dgvTTKyThiThu.SelectedRows[0].Cells["maDT"].Value.ToString()); int makt = int.Parse(dgvTTKyThiThu.SelectedRows[0].Cells["maKT"].Value.ToString()); btGanNhat = qlttn.BuoiThis.Where(bt => bt.maKT == makt && bt.maDT == madt).FirstOrDefault(); btGanNhat.NgayGioThi = DateTime.Now; ktGanNhat = btGanNhat.KyThi; tabControl1.SelectedIndex = 0; SetUpThi(); } else { MessageBox.Show("Hãy chọn một đề thi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public ActionResult DeleteConfirmed(int id) { var check = db.DanhSachThis.Where(m => m.IdKyThi == id).Count(); KyThi kyThi = db.KyThis.Find(id); if (check > 0) { kyThi.isDelete = true; db.SaveChanges(); } else { db.KyThis.Remove(kyThi); db.SaveChanges(); } return(RedirectToAction("Index")); }
private void btn_sua_Click(object sender, EventArgs e) { LTUDQL1DataContext suakt = new LTUDQL1DataContext(); KyThi kt = new KyThi(); kt = suakt.KyThis.Where(u => u.MaKT == txtmakt.Text).Where(u => u.MaHV == txtmahv.Text).Single(); kt.MaKT = txtmakt.Text; kt.Ngay = txtmant.Text; kt.MaDT = txtmadt.Text; kt.ThoiGian = txttg.Text; kt.MaHV = txtmahv.Text; suakt.SubmitChanges(); LoadData(); MessageBox.Show("UpDate thành công!!!"); CleanTextBox(); }
private void Kythicustom_PropertyChanged(object sender, PropertyChangedEventArgs e) { kythi = qltn.KyThis.Where(i => i.id == kythiid).First(); switch (e.PropertyName) { case "Tenkythi": kythi.tenkythi = kythicustom.Tenkythi; break; case "Songay": kythi.songay = kythicustom.Songay; break; case "Ngaybatdau": kythi.ngaybatdau = kythicustom.Ngaybatdau.Date; break; } }
public LamTracNgiemHS(KyThi kyThi, DeThi deThi, QuanLyThiTracNghiem.Data.HocSinh hs) { InitializeComponent(); this._kythi = kyThi; this.deThi = deThi; this.hocsinh = hs; time = int.Parse(deThi.ThoiGian.ToString()) * 60; LoadThongTin(); LoadCheckList(); checklist.SelectedIndexChanged += Checklist_SelectedIndexChanged; checkBox1.CheckedChanged += CheckBox1_CheckedChanged; checkBox2.CheckedChanged += CheckBox1_CheckedChanged; checkBox3.CheckedChanged += CheckBox1_CheckedChanged; checkBox4.CheckedChanged += CheckBox1_CheckedChanged; checkBox5.CheckedChanged += CheckBox1_CheckedChanged; checkBox6.CheckedChanged += CheckBox1_CheckedChanged; Runtimecount(); }
private void btnSave_Click(object sender, EventArgs e) { KyThi kt = (from k in db.KyThis where k.ID == txtID.Text select k).SingleOrDefault(); kt.MaDe = int.Parse(cbMaDe.SelectedValue.ToString()); kt.NgayThi = dtpDate.Text; try { db.SubmitChanges(); this.Close(); MessageBox.Show("Lưu thành công"); } catch { MessageBox.Show("Lưu thất bại"); } }
private void btnDelete_Click(object sender, EventArgs e) { string id = dgvKyThi.CurrentRow.Cells["ID"].Value.ToString(); KyThi kt = (from k in db.KyThis where k.ID == id select k).SingleOrDefault(); db.KyThis.DeleteOnSubmit(kt); try { db.SubmitChanges(); MessageBox.Show("Xóa kỳ thi thành công"); LoadKyThi(); dgvThiSinh.Rows.Clear(); } catch { MessageBox.Show("Lỗi xóa kỳ thi "); } }
public ActionResult ThongKePhach(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } KyThi kyThi = db.KyThis.Find(id); if (kyThi == null || kyThi.isDelete == true) { return(View("~/Views/Shared/404Notfound.cshtml")); } var model = (from tkp in db.ThongKePhachs join kt in db.KyThis on tkp.IdKyThi equals kt.IdKyThi where tkp.IdKyThi == id orderby tkp.PhachBatDau descending select new { tenKyThi = kt.TenKyThi, tenMonThi = tkp.TenMonThi, phachBD = tkp.PhachBatDau, phachKT = tkp.PhachKetThuc }).Distinct().ToList(); rptThongKePhach rpt = new rptThongKePhach(); DataTable dt = new DataTable(); dt.Columns.Add("TenKyThi", typeof(String)); dt.Columns.Add("TenMonThi", typeof(String)); dt.Columns.Add("PhachBatDau", typeof(String)); dt.Columns.Add("PhachKetThuc", typeof(String)); for (int i = 0; i < model.Count; i++) { dt.Rows.Add(model[i].tenKyThi, model[i].tenMonThi, model[i].phachBD, model[i].phachKT); } rpt.Load(); rpt.SetDataSource(dt); Stream s = rpt.ExportToStream(ExportFormatType.WordForWindows); return(File(s, "application/docx", "ThongKePhach.doc")); }
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!!!"); } }
private void btnLamBaiThi_Click(object sender, EventArgs e) { int stt; lstCH = cauHoiBLL_DAL.getCauHoi(); dsch = randomCauHoi(lstCH, soLuongCauHoi); listUserControl = new List <usrctrCauHoi>(); listDapAnDung = new List <DapAn>(); for (int i = 0; i < soLuongCauHoi; i++) { stt = dsch[i]; List <DapAn> lstDA = cauHoiBLL_DAL.getDapan(lstCH[stt].MaCH); DapAn dadung = cauHoiBLL_DAL.getDapAnDung(lstCH[stt].MaCH); listDapAnDung.Add(dadung); ch = new usrctrCauHoi(lstCH[stt].NoiDungCH, i + 1, lstDA[0].NoiDungDA, lstDA[1].NoiDungDA, lstDA[2].NoiDungDA, lstDA[3].NoiDungDA); ch.setTagDapAn(lstDA[0].DungSai.ToString(), lstDA[1].DungSai.ToString(), lstDA[2].DungSai.ToString(), lstDA[3].DungSai.ToString()); // Đáp án đúng Tag = True - Đáp án sai Tag = False; flowLayoutPanel1.Controls.Add(ch); flowLayoutPanel1.SetFlowBreak(ch, true); listUserControl.Add(ch); // kiểm soát 20 câu hỏi và đáp án } timer1.Enabled = true; KyThi kt = cauHoiBLL_DAL.getThoiGianLamBai(maKyThi); setThoiGianDemNguoc(int.Parse(kt.ThoiGianLamBai.ToString()), 0); btnLamBaiThi.Visible = false; btnNopBai.Visible = true; }
private static void KhoiTaoTableKyThi() { tblKyThi = new Dictionary<int, KyThi>(); KyThi kt = new KyThi(0, "Kỳ thi 0"); kt.DanhSachBai.Add(tblBai[0]); kt.DanhSachBai.Add(tblBai[1]); kt.DanhSachBai.Add(tblBai[2]); tblKyThi.Add(kt.ID, kt); kt = new KyThi(1, "Kỳ thi 1"); kt.DanhSachBai.Add(tblBai[2]); kt.DanhSachBai.Add(tblBai[4]); kt.DanhSachBai.Add(tblBai[6]); tblKyThi.Add(kt.ID, kt); kt = new KyThi(2, "Kỳ thi 2"); kt.DanhSachBai.Add(tblBai[3]); kt.DanhSachBai.Add(tblBai[5]); kt.DanhSachBai.Add(tblBai[7]); kt.DanhSachBai.Add(tblBai[9]); tblKyThi.Add(kt.ID, kt); kt = new KyThi(3, "Kỳ thi 3"); kt.DanhSachBai.Add(tblBai[2]); kt.DanhSachBai.Add(tblBai[7]); tblKyThi.Add(kt.ID, kt); DataBase.Add("KyThi", tblKyThi); }