DanhSachMonThi DsMonThi() { DanhSachMonThi Dsmt = new DanhSachMonThi(new List <MonThi>()); foreach (DataGridViewRow r in grwDanhSach.Rows) { if (Convert.ToString(r.Cells[3].Value) != "") { MonThi mt = new MonThi(Convert.ToString(r.Cells[1].Value)); foreach (DataGridViewRow r2 in grwDanhSach.Rows) { if (r2.Index != r.Index) { string bac1 = Convert.ToString(r.Cells[3].Value); string bac2 = Convert.ToString(r2.Cells[3].Value); bool thimay1 = Convert.ToBoolean(((DataGridViewCheckBoxCell)r.Cells[4]).Value); bool thimay2 = Convert.ToBoolean(((DataGridViewCheckBoxCell)r2.Cells[4]).Value); string phong1 = Convert.ToString(((DataGridViewComboBoxCell)r.Cells[11]).Value); string phong2 = Convert.ToString(((DataGridViewComboBoxCell)r2.Cells[11]).Value); if (bac2 != "") { if (bac1 == bac2 || (thimay1 && thimay2 && Phong.TrungPhong(phong1, phong2))) { mt.ThemMonCungNhom(Convert.ToString(r2.Cells[1].Value)); } } } } Dsmt.ds.Add(mt); } } return(Dsmt); }
private void Server_Load(object sender, EventArgs e) { GetActiveIP(); string sqlserver = @"server=.; database=Students; integrated security = true;"; SqlConnection connection = new SqlConnection(sqlserver); SqlDataReader read; SqlCommand cmd = connection.CreateCommand(); connection.Open(); cmd.CommandText = "Select * from MonThi "; read = cmd.ExecuteReader(); while (read.Read()) { monThi = new MonThi() ; monThi.ID = read.GetValue(0).ToString(); monThi.Name = read.GetValue(1).ToString(); listMonThi.Add(monThi); } cmd.Dispose(); read.Close(); connection.Close(); foreach (MonThi mon in listMonThi) { cbbMonThi.Items.Add(mon.Name); } cbbMonThi.Text = cbbMonThi.Items[1].ToString(); }
DanhSachMonThi DsMonThi() { DanhSachMonThi Dsmt = new DanhSachMonThi(new List <MonThi>()); foreach (DataGridViewRow r in grwDanhSach.Rows) { if (Convert.ToString(r.Cells["NHÓM"].Value) != "") { MonThi mt = new MonThi(Convert.ToString(r.Cells["MÃ HP"].Value)); string phong1 = Convert.ToString(((DataGridViewTextBoxCell)r.Cells["PHÒNG"]).Value); string nhom1 = Convert.ToString(r.Cells["NHÓM"].Value); if (phong1 != "") { mt.MonThucHanh = true; } foreach (DataGridViewRow r2 in grwDanhSach.Rows) { if (r2.Index != r.Index) { string nhom2 = Convert.ToString(r2.Cells["NHÓM"].Value); string phong2 = Convert.ToString(((DataGridViewTextBoxCell)r2.Cells["PHÒNG"]).Value); if (DuLieu.KiemTraTrung(nhom1, nhom2) || DuLieu.KiemTraTrung(phong1, phong2)) { mt.ThemMonCungNhom(Convert.ToString(r2.Cells[1].Value)); } } } Dsmt.ds.Add(mt); } } return(Dsmt); }
public void Post([FromBody] Object _MonThi) { MonThi MonThi = (MonThi)Serializer.Deserialize <MonThi>(_MonThi.ToString()); MonThi.MonThiId = Guid.NewGuid(); db.MonThi.Add(MonThi); db.SaveChanges(); }
public void DeleteMonThi(int?monthiId) { try { MonThi monthi = _context.MonThis.Find(monthiId); if (monthi != null) { _context.MonThis.Remove(monthi); } _context.SaveChanges(); } catch (Exception) { throw; } }
public long?UpdateMonThi(MonThi monthi) { try { long?result = -1; if (monthi != null) { //monthi.CreateDate = DateTime.Now; _context.Entry(monthi).State = EntityState.Modified; _context.SaveChanges(); result = monthi.ID; } return(result); } catch (Exception) { throw; } }
public long?AddMonThi(MonThi monthi) { try { long?result = -1; if (monthi != null) { monthi.Status = true; //usermaster.CreateDate = DateTime.Now; _context.MonThis.Add(monthi); _context.SaveChanges(); result = monthi.ID; } return(result); } catch (Exception) { throw; } }
public ActionResult Edit(int id, MonThi collection) { try { // TODO: Add update logic here if (ModelState.IsValid) { var res = mt.Update(collection); if (res) { return(RedirectToAction("Index", "MonThi")); } else { ModelState.AddModelError("", "Sửa thất bại"); } } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(MonThi collection) { try { // TODO: Add insert logic here if (ModelState.IsValid) { int id = mt.Insert(collection); if (id > 0) { return(RedirectToAction("Index", "MonThi")); } else { ModelState.AddModelError("", "Thêm thất bại"); } } return(RedirectToAction("Index")); } catch { return(View()); } }