public bool SaveUpdateCauHoi() { try { #region Update cau hoi cha var cauHoiCha = new EX_CauHoi(); cauHoiCha.NoiDung = txtNoiDungCauHoiCha.Rtf; cauHoiCha.IDChuong = IdDanhMuc; cauHoiCha.IDLoaiCauHoi = IdLoaiCauHoi; cauHoiCha.IsCauHoiCha = true; cauHoiCha.DoKho = IdMucDoNhanThuc; _bus.UpdateCauHoi(IdCauHoiCha ?? 0, cauHoiCha); #endregion #region Update cau hoi foreach (var ch in ListCauHoi) { ch.IDCauHoiCha = IdCauHoiCha; ch.IDLoaiCauHoi = IdLoaiCauHoi; ch.IDChuong = IdDanhMuc; ch.IsKhongDao = ckbKhongDaoCauHoi.Checked; ch.NgaySoan = DateTime.Now; ch.DoKho = IdMucDoNhanThuc; if (ch.Id > 0) { _bus.UpdateCauHoi(ch.Id, ch); } else { _bus.AddNewCauHoi(ch); } // Câu trả lời foreach (var ctl in ch.ListCauTraLoi) { ctl.IDCauHoi = ch.Id; if (ctl.Id == 0) { _bus.AddNewCauTraLoi(ctl); } else { _bus.UpdateCauTraLoi(ctl.Id, ctl); } } } #endregion IsChanged = false; } catch (Exception) { return(false); } return(true); }
public void CauHoiLoad() { ClearAllCauTraLoi(); ClearAllCauTraLoiPhai(); // Neu dang mode cap nhat thi tai noi dung cau hoi len form hien hanh if (Mode == ModeForm.CapNhat) { LoadCauHoiOld(CauHoiCurent); LoadCauTraLoi(CauHoiCurent); } else if (Mode == ModeForm.ThemMoi) { //Add cau tra loi CauHoiCurent = new EX_CauHoi(); IdCauHoiCurent = 1; // Add 4 cau tra loi mac dinh for (int i = 1; i <= 4; i++) { CauHoiCurent.ListCauTraLoi.Add(new EX_CauTraLoi { IdEx = i, IsVeTrai = true }); CauHoiCurent.ListCauTraLoiPhai.Add(new EX_CauTraLoi { IdEx = i, IsVeTrai = false }); ThemCauTraLoiTrai(); ThemCauTraLoiPhai(); } } }
public bool SaveNewCauHoi() { try { var cauHoiCha = new EX_CauHoi(); cauHoiCha.NoiDung = txtNoiDungCauHoiCha.Rtf; cauHoiCha.IDChuong = IdDanhMuc; cauHoiCha.IDLoaiCauHoi = IdLoaiCauHoi; cauHoiCha.DoKho = IdMucDoNhanThuc; cauHoiCha.IsCauHoiCha = true; _bus.AddNewCauHoi(cauHoiCha); foreach (var ch in ListCauHoi) { ch.IDCauHoiCha = cauHoiCha.Id; ch.IDLoaiCauHoi = IdLoaiCauHoi; ch.IDChuong = IdDanhMuc; ch.IsKhongDao = ckbKhongDaoCauHoi.Checked; ch.IsSuDung = true; ch.DoKho = IdMucDoNhanThuc; ch.NgaySoan = DateTime.Now; _bus.AddNewCauHoi(ch); foreach (var ctl in ch.ListCauTraLoi) { ctl.IDCauHoi = ch.Id; _bus.AddNewCauTraLoi(ctl); } } } catch (Exception) { return(false); } return(true); }
private void LoadCauHoiOld() { EX_CauHoi cauHoi = _bus.GetById(CauHoiCurent.Id); //noi dung cau hoi txtNoiDungCauHoiCon.Rtf = cauHoi.NoiDung; //check nếu có dùng câu hỏi cha base.IdCauHoiCha = cauHoi.IDCauHoiCha; // Check đảo/không đảo ckbKhongDaoCauHoi.Checked = cauHoi.IsKhongDao ?? false; //nếu id câu hỏi cha khác null thì hiển thị nội dung câu hỏi cha lên if (base.IdCauHoiCha != null) { EX_CauHoi cauHoiCha = _bus.GetById(base.IdCauHoiCha); if (cauHoiCha != null) { txtNoiDungCauHoiCha.Rtf = cauHoiCha.NoiDung; } } else // Ngược lại nếu không có câu hỏi cha, refresh câu hỏi cha { txtNoiDungCauHoiCha.Clear(); } }
public bool SaveUpdateCauHoi() { try { var ch = new EX_CauHoi(); ch.NoiDung = txtNoiDungCauHoi.Rtf; ch.IDChuong = IdDanhMuc; ch.IDLoaiCauHoi = IdLoaiCauHoi; ch.NgaySoan = DateTime.Now; ch.DoKho = IdMucDoNhanThuc; ch.IsKhongDao = ckbKhongDaoCauHoi.Checked; ch.IsSuDung = true; _business.UpdateCauHoi(IdCauHoiCurent, ch); var cauTraLoi = new EX_CauTraLoi(); cauTraLoi.NoiDung = txtNoiDungCauTraLoi.Rtf; cauTraLoi.IDCauHoi = IdCauHoiCurent; cauTraLoi.IsKhongDao = true; cauTraLoi.NgayTao = DateTime.Now; _business.UpdateCauTraLoi(IdCauTraLoi, cauTraLoi); } catch (Exception) { return(false); } return(true); }
public void CauHoiLoad() { ClearAllCauTraLoi(); ClearAllCauTraLoiPhai(); // Neu dang mode cap nhat thi tai noi dung cau hoi len form hien hanh if (Mode == ModeForm.CapNhat) { LoadCauHoiOld(CauHoiCurent); LoadCauHoiVaCauTraLoi(CauHoiCurent); } else if (Mode == ModeForm.ThemMoi) { CauHoiCurent = new EX_CauHoi(); IdCauHoiCurent = 1; // Add 4 cau hỏi và câu trả lời mặc định for (int i = 1; i <= 4; i++) { var cauHoi = new EX_CauHoi { IDEx = i, NoiDung = "" }; var cauTraLoi = new EX_CauTraLoi { IdEx = i, NoiDung = "" }; cauHoi.ListCauTraLoi.Add(cauTraLoi); CauHoiCurent.ListCauHoi.Add(cauHoi); ThemCauHoiTrai(cauHoi); ThemCauTraLoiPhai(cauTraLoi); } } }
public void CauHoiLoad() { ClearAllCauTraLoi(); // Neu dang mode cap nhat thi tai noi dung cau hoi len form hien hanh if (Mode == ModeForm.CapNhat) { LoadCauHoiOld(CauHoiCurent); LoadCauHoiVaCauTraLoi(CauHoiCurent); } else if (Mode == ModeForm.ThemMoi) { CauHoiCurent = new EX_CauHoi(); // Add 4 cau tra loi mac dinh for (int i = 1; i <= 4; i++) { var cauHoi = new EX_CauHoi { IDEx = i, NoiDung = "" }; var cauTraLoi = new EX_CauTraLoi { IdEx = i, NoiDung = "", IsKhongDao = false, IsDung = true }; cauHoi.ListCauTraLoi.Add(cauTraLoi); CauHoiCurent.ListCauHoi.Add(cauHoi); ThemCauHoiCon(cauHoi); } } }
private void BtnTaoSoCauHoi_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSoCauHoi.Text)) { UICommon.ShowMsgInfoString("Bạn hãy nhập số câu hỏi cần tạo"); return; } if (txtNoiDungCauHoiCha.IsEmpty) { UICommon.ShowMsgInfoString("Bạn hãy nhập nội dung câu hỏi cha"); txtNoiDungCauHoiCha.Focus(); return; } var soCau = Convert.ToInt32(txtSoCauHoi.Text); if (soCau < 1) { UICommon.ShowMsgInfoString("Số câu hỏi cần phải lớn hơn 0"); return; } if (ListCauHoi != null && UICommon.ShowMsgQuestionString("Tạo mới danh sách câu hỏi toàn bộ dữ liệu câu hỏi bạn chưa lưu sẽ bị mất.\nBạn có muốn tiếp tục không?") != DialogResult.Yes) { return; } //Khởi tạo danh sách câu hỏi ListCauHoi = new List <EX_CauHoi>(); var dataCboCauHoi = new List <DM_STT>(); for (int i = 1; i <= soCau; i++) { EX_CauHoi cauHoi = new EX_CauHoi(); cauHoi.IDEx = i; cauHoi.NoiDung = ""; cauHoi.IDChuong = IdDanhMuc; cauHoi.DoKho = IdMucDoNhanThuc; cauHoi.IsSuDung = true; cauHoi.IsKhongDao = ckbKhongDaoCauHoi.Checked; //Khởi tạo cau tra loi => cau hoi tu luan chi mot cau tra loi EX_CauTraLoi cauTraLoi = new EX_CauTraLoi(); cauTraLoi.IdEx = 1; cauTraLoi.IDCauHoi = cauHoi.Id; cauTraLoi.NoiDung = ""; cauHoi.ListCauTraLoi.Add(cauTraLoi); ListCauHoi.Add(cauHoi); dataCboCauHoi.Add(new DM_STT { Id = cauHoi.IDEx, Ten = string.Format("Câu hỏi {0}", i) }); } //Set data cauHoi vào trong cbo SetDataChonCauHoi(dataCboCauHoi); if (dataCboCauHoi.Count > 0) { IdCauHoiCurent = 0; cboChonCauHoi.CategoryID = 1; } SetReadOnlyControl(false); btnTaoCauHoi.Enabled = false; }
private void BtnTaoSoCauHoi_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSoCauHoi.Text)) { UICommon.ShowMsgInfoString("Bạn hãy nhập số câu hỏi cần tạo"); return; } if (txtNoiDungCauHoiCha.IsEmpty) { UICommon.ShowMsgInfoString("Bạn hãy nhập nội dung câu hỏi cha"); txtNoiDungCauHoiCha.Focus(); return; } var soCau = Convert.ToInt32(txtSoCauHoi.Text); if (soCau < 1) { UICommon.ShowMsgInfoString("Số câu hỏi cần phải lớn hơn 0"); return; } //Khởi tạo danh sách câu hỏi ListCauHoi = new List <EX_CauHoi>(); var dataCboCauHoi = new List <DM_STT>(); for (int i = 1; i <= soCau; i++) { EX_CauHoi cauHoi = new EX_CauHoi(); cauHoi.IDEx = i; cauHoi.NoiDung = ""; cauHoi.IDChuong = IdDanhMuc; cauHoi.DoKho = IdMucDoNhanThuc; cauHoi.IsSuDung = true; cauHoi.IsKhongDao = ckbKhongDaoCauHoi.Checked; //Khởi tạo danh sách câu trả lời for (int j = 1; j <= 4; j++) { EX_CauTraLoi cauTraLoi = new EX_CauTraLoi(); cauTraLoi.IdEx = j; cauTraLoi.IDCauHoi = cauHoi.Id; cauTraLoi.NoiDung = ""; cauHoi.ListCauTraLoi.Add(cauTraLoi); } ListCauHoi.Add(cauHoi); dataCboCauHoi.Add(new DM_STT { Id = cauHoi.IDEx, Ten = string.Format("Câu hỏi {0}", i) }); } //Set data cauHoi vào trong cbo SetDataChonCauHoi(dataCboCauHoi); if (dataCboCauHoi.Count > 0) { IdCauHoiCurent = 0; cboChonCauHoi.CategoryID = 1; } SetReadOnlyControl(false); btnTaoCauHoi.Enabled = false; }
private void GridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { _currentCauHoi = gridView1.GetFocusedRow() as EX_CauHoi; if (_currentCauHoi != null) { LoadCauHoi(_currentCauHoi); } }
private void LoadCauHoiOld(EX_CauHoi cauHoi) { //noi dung cau hoi txtCtrlNoiDungCauHoi.Rtf = cauHoi.NoiDung; ckbKhongDaoCauHoi.Checked = cauHoi.IsKhongDao ?? false; txtTieuDeVeTrai.Text = cauHoi.TieuDeVeTrai; txtTieuDeVePhai.Text = cauHoi.TieuDeVePhai; }
public bool SaveCauHoiNew() { try { List <EX_CauTraLoi> lstCauTraLoi = new List <EX_CauTraLoi>(); foreach (var tblPanelDapAn in _lstTablePanelDapAnTrai) { EditorControl txtDapAn = tblPanelDapAn.Controls[_nameTextNoiDungDapAn] as EditorControl; CheckBox chkKhongDao = tblPanelDapAn.Controls[_nameCheckBox] as CheckBox; lstCauTraLoi.Add(new EX_CauTraLoi() { NoiDung = txtDapAn.Rtf, IsDung = false, IsKhongDao = chkKhongDao.Checked, IsVeTrai = true }); } foreach (var tblPanelDapAn in _lstTablePanelDapAnPhai) { EditorControl txtDapAn = tblPanelDapAn.Controls[_nameTextNoiDungDapAn] as EditorControl; CheckBox chkKhongDao = tblPanelDapAn.Controls[_nameCheckBox] as CheckBox; lstCauTraLoi.Add(new EX_CauTraLoi() { NoiDung = txtDapAn.Rtf, IsDung = true, IsKhongDao = chkKhongDao.Checked, IsVeTrai = false }); } #region Kiểm tra trùng câu hỏi #endregion #region Save new câu hỏi EX_CauHoi ch = new EX_CauHoi(); ch.IDChuong = IdDanhMuc; ch.DoKho = IdMucDoNhanThuc; ch.NoiDung = txtCtrlNoiDungCauHoi.Rtf; ch.IsSuDung = true; ch.IsKhongDao = ckbKhongDaoCauHoi.Checked; ch.TieuDeVeTrai = txtTieuDeVeTrai.Text.Trim(); ch.TieuDeVePhai = txtTieuDeVePhai.Text.Trim(); ch.IDLoaiCauHoi = IdLoaiCauHoi; ch.NgaySoan = DateTime.Now; _business.AddNewCauHoi(ch); // Danh sách câu trả lời foreach (var esCauTraLoi in lstCauTraLoi) { esCauTraLoi.IDCauHoi = ch.Id; _business.AddNewCauTraLoi(esCauTraLoi); } #endregion } catch (Exception) { return(false); } return(true); }
private void LoadCauHoiNew(int idCauHoi) { EX_CauHoi cauHoi = new EX_CauHoi(); cauHoi = ListCauHoi.FirstOrDefault(m => m.IDEx == idCauHoi); IdCauHoiCurent = cauHoi.IDEx; txtNoiDungCauHoiCon.Rtf = cauHoi.NoiDung; ckbKhongDaoCauHoi.Checked = cauHoi.IsKhongDao ?? false; LoadCauTraLoiNew(IdCauHoiCurent); }
private void LoadCauTraLoi(EX_CauHoi cauHoi) { // Load danh sách đáp án List <EX_CauTraLoi> listDapAn = cauHoi.ListCauTraLoi; foreach (var dapAn in listDapAn) { ThemCauTraLoi(dapAn); } }
private void LoadCauTraLoi(EX_CauHoi cauHoi) { CauHoiCurent.ListCauTraLoi = CauHoiCurent.ListCauTraLoi.OrderBy(n => n.IndexEx).ToList(); for (int i = 1; i <= CauHoiCurent.ListCauTraLoi.Count; i++) { var ctraLoi = CauHoiCurent.ListCauTraLoi[i - 1]; ctraLoi.IdEx = i; ThemCauTraLoi(ctraLoi); } }
public bool SaveCauHoiNew() { try { List <EX_CauTraLoi> lstCauTraLoi = new List <EX_CauTraLoi>(); foreach (var tblPanelDapAn in _lstTablePanelDapAn) { EditorControl txtDapAn = tblPanelDapAn.Controls[_nameTextNoiDungDapAn] as EditorControl; SimpleButton btnDapAn = tblPanelDapAn.Controls[_nameButtonDapAn] as SimpleButton; CheckBox chkKhongDao = tblPanelDapAn.Controls[_nameCheckBox] as CheckBox; lstCauTraLoi.Add(new EX_CauTraLoi() { NoiDung = txtDapAn.Rtf, IsDung = Convert.ToBoolean(btnDapAn.Tag), IsKhongDao = chkKhongDao.Checked }); } #region Kiểm tra trùng câu hỏi // Kiểm tra trùng đáp án if (lstCauTraLoi.GroupBy(o => o.NoiDung).ToList().Count < _lstTablePanelDapAn.Count && UICommon.ShowMsgQuestionString("Tồn tại đáp án trùng nhau. Bạn có muốn tiếp tục lưu không?") == DialogResult.No) { return(false); } #endregion #region Save new câu hỏi EX_CauHoi ch = new EX_CauHoi(); ch.IDChuong = IdDanhMuc; ch.DoKho = IdMucDoNhanThuc; ch.NoiDung = txtCtrlNoiDungCauHoi.Rtf; ch.IsSuDung = true; ch.IsKhongDao = ckbKhongDaoCauHoi.Checked; ch.IDLoaiCauHoi = (int)LoaiCauHoi.CauHoiDungSai; ch.NgaySoan = DateTime.Now; _business.AddNewCauHoi(ch); // Danh sách câu trả lời foreach (var esCauTraLoi in lstCauTraLoi) { esCauTraLoi.IDCauHoi = ch.Id; _business.AddNewCauTraLoi(esCauTraLoi); } #endregion } catch (Exception) { return(false); } return(true); }
public bool SaveUpdateCauHoi() { try { #region Update cau hoi //cap nhat noi dung cau hoi EX_CauHoi ch = _business.GetById(IdCauHoiCurent); if (ch == null) { return(false); } //get body ch.DoKho = IdMucDoNhanThuc; ch.IDChuong = IdDanhMuc; ch.NoiDung = txtCtrlNoiDungCauHoi.Rtf; ch.IsKhongDao = ckbKhongDaoCauHoi.Checked; ch.IDLoaiCauHoi = IdLoaiCauHoi; //save lai _business.UpdateCauHoi(IdCauHoiCurent, ch); #endregion // Cập nhật câu trả lời foreach (var esCauTraLoi in CauHoiCurent.ListCauTraLoi) { if (esCauTraLoi.Id == 0) { esCauTraLoi.IDCauHoi = CauHoiCurent.Id; _business.AddNewCauTraLoi(esCauTraLoi); } else { _business.UpdateCauTraLoi(esCauTraLoi.Id, esCauTraLoi); } } // Xoa cau tra loi foreach (int IdCauTraLoiBiXoa in ListIdCauHoiBiXoa) { _business.DeleteCauTraLoiById(IdCauTraLoiBiXoa); } IsChanged = false; } catch (Exception) { return(false); } return(true); }
private void LoadNoiDungCauHoiCha(int idCauHoiCha) { //Chuyen id cau hoi va idcau tra li ve dang IDEx từ 1 đến... để xủ lý chung if (base.IdCauHoiCha > 0) { var cauHoiCha = _bus.GetById(base.IdCauHoiCha); if (cauHoiCha != null) { txtNoiDungCauHoiCha.Rtf = cauHoiCha.NoiDung; //Đổ dữ liệu cau hoi để xử lý ListCauHoi = new List <EX_CauHoi>(); ListCauHoi = _bus.Context.EX_CauHoi.Where(mbox => mbox.IDCauHoiCha == cauHoiCha.Id).ToList(); var lstDataCbo = new List <DM_STT>(); int i = 1; foreach (var item in ListCauHoi) { var lstCauTL = _bus.GetCauTraLoi(item.Id); int j = 1; foreach (var ctl in lstCauTL) { ctl.IdEx = j; j++; } item.ListCauTraLoi = lstCauTL; item.IDEx = i; lstDataCbo.Add(new DM_STT { Id = i, Ten = string.Format("Câu hỏi {0}", i) }); i++; } cboChonCauHoi.EditValueChanged -= CboChonCauHoi_EditValueChanged; SetDataChonCauHoi(lstDataCbo); var cauHoiFirst = new EX_CauHoi(); if (IdCauHoiCurent > 0) { cauHoiFirst = ListCauHoi.FirstOrDefault(m => m.Id == IdCauHoiCurent); } else { cauHoiFirst = ListCauHoi.FirstOrDefault(); } CauHoiCurent = cauHoiFirst; IdCauHoiCurent = cauHoiFirst.IDEx; cboChonCauHoi.CategoryID = IdCauHoiCurent; txtSoCauHoi.Text = ListCauHoi.Count.ToString(); txtSoCauHoi.Enabled = false; btnTaoCauHoi.Enabled = false; cboChonCauHoi.EditValueChanged += CboChonCauHoi_EditValueChanged; } } }
private bool CheckAllEditCauHoi(long idCauHoi) { // Kiểm tra câu hỏi EX_CauHoi cauHoi = _business.GetById(idCauHoi); if (cauHoi == null) { UICommon.ShowMsgWarningString("Câu hỏi không tồn tại."); return(false); } return(true); }
private void LoadCauHoiNew(long?idCauHoi) { var cauHoi = ListCauHoi.FirstOrDefault(m => m.IDEx == idCauHoi); if (cauHoi == null) { cauHoi = new EX_CauHoi(); } IdCauHoiCurent = cauHoi.IDEx; txtNoiDungCauHoiCon.Rtf = cauHoi.NoiDung; ckbKhongDaoCauHoi.Checked = cauHoi.IsKhongDao ?? false; LoadCauTraLoiNew(IdCauHoiCurent); }
private void LoadCauHoiVaCauTraLoi() { EX_CauHoi cauHoi = _business.GetById(CauHoiCurent.Id); if (cauHoi != null) { txtNoiDungCauHoiCon.Rtf = cauHoi.NoiDung; ckbKhongDaoCauHoi.Checked = cauHoi.IsKhongDao ?? false; //Load noi dung cau tra loi var cauTraLoi = CauHoiCurent.ListCauTraLoi.FirstOrDefault(); //noi dung cau tra loi txtNoiDungCauTraLoi.Rtf = cauTraLoi.NoiDung; } }
private void LoadCauTraLoi(EX_CauHoi cauHoi) { // Load danh sách đáp án List <EX_CauTraLoi> listDapAnTrai = cauHoi.ListCauTraLoi; List <EX_CauTraLoi> listDapAnPhai = cauHoi.ListCauTraLoiPhai; foreach (var dapAnTrai in listDapAnTrai) { ThemCauTraLoiTrai(dapAnTrai); } foreach (var dapAnPhai in listDapAnPhai) { ThemCauTraLoiPhai(dapAnPhai); } }
private void btnThemCauHoi_Click(object sender, EventArgs e) { var maxIdEx = CauHoiCurent.ListCauHoi.Max(m => m.IDEx); var cauHoi = new EX_CauHoi { IDEx = maxIdEx + 1, NoiDung = "" }; var cauTraLoi = new EX_CauTraLoi { IdEx = maxIdEx + 1, NoiDung = "" }; cauHoi.ListCauTraLoi.Add(cauTraLoi); CauHoiCurent.ListCauHoi.Add(cauHoi); ThemCauHoiTrai(cauHoi); ThemCauTraLoiPhai(cauTraLoi); }
private void LoadCauHoiVaCauTraLoi(EX_CauHoi cauHoiCha) { // Load danh sách đáp án List <EX_CauHoi> lstCauHoi = cauHoiCha.ListCauHoi; foreach (EX_CauHoi cauHoi in lstCauHoi) { // Gắn IdEx = Id để khi có thêm mới thì sẽ ko bị trùng IdEx với những câu hỏi cũ cauHoi.IDEx = (int)cauHoi.Id; var cauTraLoi = cauHoi.ListCauTraLoi.FirstOrDefault(); if (cauTraLoi != null) { cauTraLoi.IdEx = (int)cauHoi.IDEx; } ThemCauHoiCon(cauHoi); } }
private void BtnThem_Click(object sender, EventArgs e) { if (ListCauHoi == null || ListCauHoi.Count == 0) { UICommon.ShowMsgWarningString("Bạn phải tạo câu hỏi trước"); return; } var cauHoi = new EX_CauHoi(); for (int i = 1; i <= 4; i++) { EX_CauTraLoi cauTraLoi = new EX_CauTraLoi(); cauTraLoi.IdEx = i; cauTraLoi.IDCauHoi = cauHoi.Id; cauTraLoi.NoiDung = ""; cauHoi.ListCauTraLoi.Add(cauTraLoi); } var cauHoiLast = ListCauHoi.LastOrDefault(); if (cauHoiLast != null) { cauHoi.IDEx = cauHoiLast.IDEx + 1; cauHoi.NoiDung = ""; cauHoi.IDChuong = IdDanhMuc; cauHoi.DoKho = IdMucDoNhanThuc; cauHoi.IsSuDung = true; cauHoi.IsKhongDao = ckbKhongDaoCauHoi.Checked; ListCauHoi.Add(cauHoi); //Set lai data var lstDataCbo = new List <DM_STT>(); //int i = 1; foreach (var item in ListCauHoi) { lstDataCbo.Add(new DM_STT { Id = item.IDEx, Ten = "Câu hỏi " + item.IDEx }); } txtSoCauHoi.Text = lstDataCbo.Count().ToString(); SetDataChonCauHoi(lstDataCbo); cboChonCauHoi.CategoryID = cauHoi.IDEx; } }
public bool SaveCauHoiNew() { try { #region Kiểm tra trùng câu hỏi // Kiểm tra trùng đáp án if (CauHoiCurent.ListCauTraLoi.GroupBy(o => o.NoiDung).ToList().Count < _lstTablePanelDapAn.Count && UICommon.ShowMsgQuestionString("Tồn tại đáp án trùng nhau. Bạn có muốn tiếp tục lưu không?") == DialogResult.No) { return(false); } #endregion #region Save new câu hỏi EX_CauHoi ch = new EX_CauHoi(); ch.IDChuong = IdDanhMuc; ch.DoKho = IdMucDoNhanThuc; ch.NoiDung = txtCtrlNoiDungCauHoi.Rtf; ch.IsSuDung = true; ch.IsKhongDao = ckbKhongDaoCauHoi.Checked; ch.IDLoaiCauHoi = IdLoaiCauHoi; ch.NgaySoan = DateTime.Now; _business.AddNewCauHoi(ch); // Danh sách câu trả lời foreach (var esCauTraLoi in CauHoiCurent.ListCauTraLoi) { esCauTraLoi.IDCauHoi = ch.Id; _business.AddNewCauTraLoi(esCauTraLoi); } #endregion } catch (Exception) { return(false); } return(true); }
private bool SaveNewCauHoiTemp(long idCauHoiEx) { #region Save new câu hỏi //Cau hoi cha EX_CauHoi cauHoi = ListCauHoi.FirstOrDefault(m => m.IDEx == IdCauHoiCurent); cauHoi.IDChuong = IdDanhMuc; cauHoi.DoKho = IdMucDoNhanThuc; cauHoi.NoiDung = txtNoiDungCauHoiCon.Rtf; cauHoi.IsSuDung = true; cauHoi.IsKhongDao = ckbKhongDaoCauHoi.Checked; cauHoi.NgaySoan = DateTime.Now; var cauTraLoi = cauHoi.ListCauTraLoi.FirstOrDefault(); cauTraLoi.NoiDung = txtNoiDungCauTraLoi.Rtf; #endregion return(true); }
private void btnThemCauHoi_Click(object sender, EventArgs e) { var maxIdEx = CauHoiCurent.ListCauHoi.Max(m => m.IDEx); var cauHoi = new EX_CauHoi { IDEx = maxIdEx + 1, NoiDung = "" }; var cauTraLoi = new EX_CauTraLoi { IdEx = maxIdEx + 1, NoiDung = "", IsKhongDao = false, IsDung = true }; cauHoi.ListCauTraLoi.Add(cauTraLoi); CauHoiCurent.ListCauHoi.Add(cauHoi); ThemCauHoiCon(cauHoi); if (Mode == ModeForm.CapNhat) { IsChanged = true; } }
private void TsbSua_ItemClick(object sender, ItemClickEventArgs e) { _currentCauHoi = gridView1.GetFocusedRow() as EX_CauHoi; if (_currentCauHoi != null) { E000012 frm = new E000012(); if (_currentCauHoi.IsCauHoiCha ?? false) { frm.IsCauHoiCha = true; frm.IdCauHoiCha = _currentCauHoi.Id; frm.Mode = ModeForm.CapNhat; frm.ShowDialog(); } else { frm.IdCauHoi = _currentCauHoi.Id; frm.CurentCauHoi = _currentCauHoi; frm.Mode = ModeForm.CapNhat; frm.ShowDialog(); } } }
private bool CheckAllEditCauHoi(long idCauHoi) { // Kiểm tra câu hỏi EX_CauHoi cauHoi = _business.GetById(idCauHoi); if (cauHoi == null) { UICommon.ShowMsgWarningString("Câu hỏi không tồn tại."); return(false); } // Kiểm tra Đơn vị KT EX_DanhMuc dm = _business.GetDanhMucById(cauHoi.IDChuong); if (dm == null) { UICommon.ShowMsgWarningString("Đơn vị KT không tồn tại."); return(false); } return(true); }