private void btnLuu_Click(object sender, EventArgs e) { if (dgvDeThi.Rows.Count > 0) { for (int i = 0; i < dgvDeThi.Rows.Count; i++) { _objdethi = new DeThi(_objdethibus.NextID_DeThi(), dgvDeThi.Rows[i].Cells[2].Value.ToString(), _objloaidethibus.GetMa_TheoTen_LoaiDeThi(dgvDeThi.Rows[i].Cells[1].Value.ToString()), dgvDeThi.Rows[i].Cells[3].Value.ToString()); if (_objdethibus.AddDeThi(_objdethi)) { dgvDeThi.Rows.Remove(dgvDeThi.Rows[i]); i--; LoadData(); } else { string a = dgvDeThi.Rows[i].Cells[0].Value.ToString(); MessageBox.Show("Lưu dòng " + a + "thất bại!!!"); } } if (dgvDeThi.Rows.Count == 0) { MessageBox.Show("Lưu thành công!!!"); } } }
public async Task <DeThiAddResponse> Add(DeThi deThi) { try { using (IDbConnection dbConnection = _connection) { string query = @"INSERT INTO [dbo].[DeThi]([MaDe], [IDChuDe]) VALUES ( @MaDe, @IDChuDe)"; DynamicParameters parameters = new DynamicParameters(); parameters.Add("@MaDe", deThi.MaDe, DbType.String); parameters.Add("@IDChuDe", deThi.IDChuDe, DbType.Int16); await dbConnection.ExecuteAsync(query, param : parameters); return(new DeThiAddResponse { Code = 1 }); } } catch (Exception ex) { return(new DeThiAddResponse { Code = 0, Message = ex.Message }); } }
public ActionResult EditActionDT(DeThi hsu) { DeThiDAO dao = new DeThiDAO(); dao.Update(hsu); return(RedirectToAction("Index")); }
public static DeThiDTO FromEntity(DeThi item) { return(new DeThiDTO() { Id = item.Id, TenDeThi = item.TenDeThi, Guid = item.Guid, LinhVucThiId = item.LinhVucThiId, MoTa = item.MoTa, ThoiGianHieuLuc = item.ThoiGianHieuLuc, NgayTao = item.NgayTao, HienThiSoThuTu = item.HienThiSoThuTu, IsActive = item.IsActive, IsShowPublic = item.IsShowPublic, SoCau = item.SoCau, ThoiGianLamBai = item.ThoiGianLamBai, LaVoHanHieuLuc = item.LaVoHanHieuLuc, PhuongThucTao = item.PhuongThucTao, BaoNgayKetQua = item.BaoNgayKetQua, TrangThaiXuatBan = item.TrangThaiXuatBan, MetaTitle = item.MetaTitle, MetaDescription = item.MetaDescription, MetaRobots = item.MetaRobots, MetaUrl = item.MetaUrl, MetaImage = item.MetaImage, ChiTietDeThi = item.ChiTietDeThi?.Select(ChiTietDeThiDTO.FromEntity), BaiThi = item.BaiThi?.Select(BaiThiDTO.FromEntity), HienThiDeThi = item.HienThiDeThi?.Select(HienThiDeThiDTO.FromEntity), NguonDeThi = item.NguonDeThi?.Select(NguonDeThiDTO.FromEntity), CauHinhDoKho = item.CauHinhDoKho?.Select(CauHinhDoKhoDTO.FromEntity), LinhVucThi = item.LinhVucThi != null?LinhVucThiDTO.FromEntity(item.LinhVucThi) : null, }); }
public ActionResult ThemDeThiNgheYesNo(int maNghe) { bool status = false; List <DeThi> dsDeThi = new List <DeThi>(); Task.Run(async() => { dsDeThi = await _deThiAppService.GetListDeThi_ChuDe((int)DSCHUDE.NgheYesNo) as List <DeThi>; }).Wait(); int count = dsDeThi.Count; string maDe = string.Format("Đề {0}", count + 1); DeThi deThi = new DeThi { MaDe = maDe, IDChuDe = (int)DSCHUDE.NgheYesNo }; Task.Run(async() => { status = await _deThiAppService.Add(deThi); }).Wait(); int IdDeThi = 0; Task.Run(async() => { IdDeThi = await _deThiAppService.GetLastId("DeThi"); }).Wait(); // lay ra ds nghe var listNgheYesNo = new List <GetListNghe_CauHoiResponse>(); Task.Run(async() => { listNgheYesNo = await _cauHoiAppService.GetListNghe_CauHoi((int)DSCHUDE.NgheYesNo) as List <GetListNghe_CauHoiResponse>; }).Wait(); var dsCH = listNgheYesNo.Find(x => x.nghe.ID == maNghe).CauHois; foreach (var item in dsCH) { Task.Run(async() => { await _deThiAppService.UpdateCauHoi_DeThi(item.ID, IdDeThi); }).Wait(); } return(RedirectToAction("Nghe")); }
private void simpleButton1_Click(object sender, EventArgs e) { if (txtTieuDe.Text.Trim() != "" && txtThoiGian.Text.Trim() != "" && !txtTong.Text.Equals("0")) { try { int thoiGian = int.Parse(txtThoiGian.Text); DeThi dt = new DeThi(); dt.Tieu_De = txtTieuDe.Text; dt.Ma_Chu_De = int.Parse(cbChude.EditValue.ToString()); dt.SL_De = D; dt.SL_TrungBinh = TB; dt.SL_Kho = K; dt.Thoi_Gian_Lam_Bai = thoiGian; dt.Nguoi_Tao = userName; dt.Ngay_Tao = DateTime.Now; dt.Trang_Thai = checkBox1.Checked; cls.addDethi(dt); gridDeThi.DataSource = null; gridDeThi.DataSource = cls.listDeThi(); MessageBox.Show("Tạo đề thi thành công!"); } catch (Exception) { MessageBox.Show("Không thể thực hiện.Có lỗi xảy ra vui lòng kiểm tra lại."); } } else { MessageBox.Show("Không được để trống các trường!"); } }
public bool EditDeThi(DeThi dethi) { try { if (conn.State != ConnectionState.Open) { conn.Open(); } SqlCommand cmd = new SqlCommand("DeThi_Edit", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MaDeThi", SqlDbType.VarChar).Value = dethi._madethi; cmd.Parameters.Add("@TenDeThi", SqlDbType.NVarChar).Value = dethi._tendethi; cmd.Parameters.Add("@MaLoaiDeThi", SqlDbType.VarChar).Value = dethi._maloaidethi; cmd.Parameters.Add("@NgayLap", SqlDbType.SmallDateTime).Value = dethi._ngaylap; cmd.ExecuteNonQuery(); conn.Close(); return(true); } catch { conn.Close(); return(false); } }
public async Task <DeThi> UpdateDethi(DeThi deThi) { _context.DeThiContext.Update(deThi); await _context.SaveChangesAsync(); return(deThi); }
private void btnSua_Click(object sender, EventArgs e) { if (dgvDSDeThi.RowCount > 0) { if (dgvDSDeThi.SelectedRows.Count > 0) { if (cbbLoaiDeThi.SelectedIndex == -1 || txtTenDeThi.Text == "" || dtNgayLap.Text == "") { MessageBox.Show("Bạn chưa nhập đầy đủ thông tin!!!"); return; } _objdethi = new DeThi(dgvDSDeThi.CurrentRow.Cells[0].Value.ToString(), txtTenDeThi.Text, dgvDSDeThi.CurrentRow.Cells[2].Value.ToString(), dtNgayLap.Text); if (_objdethibus.EditDeThi(_objdethi)) { MessageBox.Show("Sửa thành công!!!"); LoadData(); resetbox(); } } else { MessageBox.Show("Bạn chưa chọn dòng cần sửa!!!"); return; } } else { MessageBox.Show("Không có dữ liệu để sửa!!!"); } }
public DeThi getATest(int Thang, int Nam, string idHoaDon) { DeThi objDeThi = new DeThi(); objDeThi = db.DeThis.Where(p => p.InUsed == true && p.CreatedDate.Value.Month == Thang && p.CreatedDate.Value.Year == Nam && p.ID == idHoaDon).FirstOrDefault(); return(objDeThi); }
public ActionResult AddQuestionAuto(AddQuestionAuto_Model model) { DeThi deThi = deThiRepository.GetById((int)Session["DeThiID"]); var listCauDe = cauHoiRepository.GetRandomCauHoiByDoKho(1, (int)deThi.MonHocID, model.SoCauDe); foreach (var item in listCauDe) { //o day nhung cau hoi nao trung se khong duoc add nen khong can phai loc cau hoi da co trong de thi deThi.CauHois.Add(item); } var listCauTrungBinh = cauHoiRepository.GetRandomCauHoiByDoKho(2, (int)deThi.MonHocID, model.SoCauDe); foreach (var item in listCauTrungBinh) { //o day nhung cau hoi nao trung se khong duoc add nen khong can phai loc cau hoi da co trong de thi deThi.CauHois.Add(item); } var listCauKho = cauHoiRepository.GetRandomCauHoiByDoKho(3, (int)deThi.MonHocID, model.SoCauDe); foreach (var item in listCauKho) { //o day nhung cau hoi nao trung se khong duoc add nen khong can phai loc cau hoi da co trong de thi deThi.CauHois.Add(item); } var listCauRatKho = cauHoiRepository.GetRandomCauHoiByDoKho(4, (int)deThi.MonHocID, model.SoCauDe); foreach (var item in listCauRatKho) { //o day nhung cau hoi nao trung se khong duoc add nen khong can phai loc cau hoi da co trong de thi deThi.CauHois.Add(item); } deThiRepository.Update(deThi); return(RedirectToAction("Details", "DeThiManagement", new { id = (int)Session["DeThiID"] })); }
// GET: Admin/DeThiManagement/Delete/5 public ActionResult Delete(int id) { DeThi deThi = deThiRepository.GetById(id); deThiRepository.Delete(deThi); return(RedirectToAction("Index")); }
public ActionResult Create(DeThi collection) { try { // TODO: Add insert logic here if (ModelState.IsValid) { //collection.NgayTao = DateTime.Now; DeThiDAO tan = new DeThiDAO(); int id = tan.Insert(collection); if (id > 0) { return(RedirectToAction("Index", "DeThi")); } else { ModelState.AddModelError("", "Thêm thất bại"); } } return(RedirectToAction("Index")); } catch { return(View()); } }
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 ActionResult Edit(int id) { DeThiDAO dao = new DeThiDAO(); DeThi model = dao.FindDeThiById(id); SetViewBagDD(); return(View(model)); }
public async Task <DeThi> CreateDeThi(DeThi deThi) { await _context.DeThiContext.AddAsync(deThi); await _context.SaveChangesAsync(); return(deThi); }
public async Task DeleteDeThi(DeThi deThi) { _context.ChiTietDeThiContext.RemoveRange(deThi.DsCauHoi); await _context.SaveChangesAsync(); _context.DeThiContext.Remove(deThi); await _context.SaveChangesAsync(); }
// GET: Admin/DeThiManagement/Edit/5 public ActionResult Edit(int id) { DeThi deThi = deThiRepository.GetById(id); ViewBag.GiaoVienID = new SelectList(db.GiaoViens, "GiaoVienID", "TenGV", deThi.GiaoVienID); ViewBag.MonHocID = new SelectList(db.MonHocs, "MonHocID", "TenMH", deThi.MonHocID); return(View(deThi)); }
// GET: Admin/DeThiManagement/Details/5 public ActionResult Details(int id) { DeThi deThi = deThiRepository.GetById(id); ViewBag.CauHois = cauHoiRepository.GetCauHoiByMaDe(id); Session["DeThiID"] = id; return(View(deThi)); }
public async Task <bool> Add(DeThi deThi) { DeThiAddRequest deThiAddRequest = new DeThiAddRequest { deThi = deThi }; return(await _deThiService.Add(deThiAddRequest)); }
//Remove question from de thi public ActionResult RemoveQuestion(int id) { CauHoi cauHoi = cauHoiRepository.GetById(id); DeThi deThi = deThiRepository.GetById((int)Session["DeThiID"]); deThi.CauHois.Remove(cauHoi); deThiRepository.Update(deThi); return(RedirectToAction("Details", new { id = (int)Session["DeThiID"] })); }
// GET: Admin/DeThiManagement/Edit/5 public ActionResult Edit(int id) { DeThi deThi = deThiRepository.GetById(id); //time return from database {06/01/2017 8:32:00 AM} ViewBag.GiaoVienID = new SelectList(giaoVienRepository.GetAll(), "GiaoVienID", "TenGV", deThi.GiaoVienID); ViewBag.MonHocID = new SelectList(monHocRepository.GetAll(), "MonHocID", "TenMH", deThi.MonHocID); return(View(deThi)); }
private void DeThi_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { try { id = int.Parse(DeThi.GetFocusedRowCellValue("id").ToString()); cbChude.EditValue = DeThi.GetFocusedRowCellValue("Ma_Chu_De").ToString(); txtTieuDe.Text = DeThi.GetFocusedRowCellValue("Tieu_De").ToString(); txtNoiDung.Text = DeThi.GetFocusedRowCellValue("Noi_Dung").ToString(); txtA.Text = DeThi.GetFocusedRowCellValue("Dap_An_A").ToString(); txtB.Text = DeThi.GetFocusedRowCellValue("Dap_An_B").ToString(); txtC.Text = DeThi.GetFocusedRowCellValue("Dap_An_C").ToString(); txtD.Text = DeThi.GetFocusedRowCellValue("Dap_An_D").ToString(); char tl = char.Parse(DeThi.GetFocusedRowCellValue("Dap_An_Dung").ToString()); if (tl == 'A') { rA.Checked = true; } else { if (tl == 'B') { rB.Checked = true; } else { if (tl == 'C') { rC.Checked = true; } else { rD.Checked = true; } } } char cd = char.Parse(DeThi.GetFocusedRowCellValue("Cap_Do").ToString()); if (cd == 'D') { cbCapDo.SelectedItem = "Dễ"; } else { if (cd == 'T') { cbCapDo.SelectedItem = "Trung bình"; } else { cbCapDo.SelectedItem = "Khó"; } } } catch (Exception) { } }
void LayDuLieu() { var lv = (ListView)form.Controls["lvDethi"]; dethiid = int.Parse(lv.SelectedItems[0].SubItems[0].Text); using (var qltn = Utils.QLTN.getInstance()) { dethi = qltn.DeThis.Where(i => i.id == dethiid).First(); } }
//Add question to de thi public ActionResult AddQuestion(int id) { //TempData.Keep("DeThiID"); CauHoi cauHoi = cauHoiRepository.GetById(id); DeThi deThi = deThiRepository.GetById((int)Session["DeThiID"]); cauHoi.DeThis.Add(deThi); cauHoiRepository.Update(cauHoi); return(RedirectToAction("AddQuestionManually", new { id = (int)Session["DeThiID"] })); }
bool KiemTraDeThi(DeThi dt, QLTNDataContext qltn) { var hstg = qltn.HocSinhThamGias.Where(i => i.dethiid == dt.id && i.thoigianlambai != null).ToList(); var hslb = qltn.HocSinhLamBais.Where(i => i.dethiid == dt.id).ToList(); if (hstg.Count > 0 || hslb.Count > 0) { return(false); } return(true); }
public ActionResult Edit([Bind(Include = "DeThiID,MonHocID,TenDeThi,ThoiGianLamBai,ThoiGianBatDauLamBai,LoaiDe,GiaoVienID")] DeThi deThi) { if (ModelState.IsValid) { db.Entry(deThi).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.GiaoVienID = new SelectList(db.GiaoViens, "GiaoVienID", "TenGV", deThi.GiaoVienID); ViewBag.MonHocID = new SelectList(db.MonHocs, "MonHocID", "TenMH", deThi.MonHocID); return(View(deThi)); }
public ActionResult Create(DeThi deThi) { if (ModelState.IsValid) { deThiRepository.Add(deThi); return(RedirectToAction("Index")); } //ViewBag.GiaoVienID = new SelectList(db.GiaoViens, "GiaoVienID", "TenGV", deThi.GiaoVienID); //ViewBag.MonHocID = new SelectList(db.MonHocs, "MonHocID", "TenMH", deThi.MonHocID); return(View()); }
public JsonResult Delete(DeThi dethi) { using (ELearningDB db = new ELearningDB()) { DeThi dt = db.DeThis.Find(dethi.MaDeThi); if (dt == null) { return(Json(new { success = false })); } db.DeThis.Remove(dt); db.SaveChanges(); return(Json(new { success = true })); } }
public int Update(DeThi hsu) { DeThi hs = tn.DeThis.Find(hsu.MaDe); if (hs != null) { hs.MoTa = hsu.MoTa; hs.TrangThai = true; hs.ThoiGian = hsu.ThoiGian; hs.SoCauHoi = hsu.SoCauHoi; tn.SaveChanges(); } return(hs.MaDe); }