public async Task <IActionResult> PutKythi(Kythi kythi) { //if (id != kythi.Makythi) //{ // return BadRequest(); //} _context.Entry(kythi).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { //if (!KythiExists(id)) //{ // return NotFound(); //} //else //{ // throw; //} } return(NoContent()); }
/// <summary> /// Sửa thông tin 1 kỳ thi /// </summary> /// <returns>true</returns> public static void UpdateTrangThaiKt(Kythi item) { try { Conn.ExcuteQuerySql("update KYTHI set TrangThai = '" + item.TrangThai + "' WHERE ID = " + item.ID + ""); } catch (Exception ex) { Log2File.LogExceptionToFile(ex); } }
/// <summary> /// Sửa thông tin 1 kỳ thi /// </summary> /// <returns>true</returns> private static void UpdateKyThi(Kythi item) { try { Conn.ExcuteQuerySql("update KYTHI set TenKT = N'" + item.TenKT + "',NgayThi = '" + item.NgayThi + "',TGLamBai = N'" + item.TGLamBai + "',TGBatDau = N'" + item.TGBatDau + "' ,TGKetThuc = N'" + item.TGKetThuc + "', GhiChu = N'" + item.GhiChu + "' WHERE ID = " + item.ID + ""); } catch (Exception ex) { Log2File.LogExceptionToFile(ex); } }
/// <summary> /// Thêm 1 kỳ thi /// </summary> /// <returns></returns> public static bool ThemKyThi(Kythi item) { try { Conn.ExcuteQuerySql("insert into KYTHI(MaKT,TenKT,NgayThi,TGLamBai,TGBatDau,TGKetThuc,GhiChu,TrangThai) values(N'" + item.MaKT + "',N'" + item.TenKT + "','" + item.NgayThi + "',N'" + item.TGLamBai + "',N'" + item.TGBatDau + "',N'" + item.TGKetThuc + "',N'" + item.GhiChu + "',1)"); return(true); } catch (Exception ex) { Log2File.LogExceptionToFile(ex); return(false); } }
protected override void SaveDetail() { try { if (ValidateData()) { MessageBox.Show(@"Vui lòng nhập đầy đủ thông tin", @"Lỗi"); } else { foreach (var row in uG_DanhSach.Rows.Where(row => string.IsNullOrEmpty(row.Cells["ID"].Text))) { var hs = new Kythi { MaKT = row.Cells["MaKT"].Text, TenKT = row.Cells["TenKT"].Text, NgayThi = row.Cells["NgayThi"].Text, TGLamBai = row.Cells["TGLamBai"].Text, TGBatDau = row.Cells["TGBatDau"].Text, TGKetThuc = row.Cells["TGKetThuc"].Text, GhiChu = row.Cells["GhiChu"].Text, }; _listAdd.Add(hs); } if (_listUpdate.Count <= 0 && _listAdd.Count <= 0) { return; } if (_listUpdate.Count > 0) { UpdateData.UpdateKyThi(_listUpdate); } if (_listAdd.Count > 0) { InsertData.ThemKythi(_listAdd); } Updatekythi(null); MessageBox.Show(FormResource.MsgThongbaothanhcong, FormResource.MsgCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); LoadFormDetail(); } } catch (Exception ex) { Log2File.LogExceptionToFile(ex); } }
private void uG_DanhSach_ClickCell(object sender, ClickCellEventArgs e) { try { if (e.Cell.Column.Key != "TT") { return; } if (string.IsNullOrEmpty(e.Cell.Row.Cells["ID"].Text)) { return; } if (bool.Parse(e.Cell.Row.Cells["TrangThai"].Text)) { e.Cell.Value = "Ẩn"; e.Cell.Row.Cells["TrangThai"].Value = false; var hs = new Kythi { ID = int.Parse(e.Cell.Row.Cells["ID"].Text), TrangThai = false }; UpdateData.UpdateTrangThaiKt(hs); } else { e.Cell.Value = "Hiển thị"; e.Cell.Row.Cells["TrangThai"].Value = true; var hs = new Kythi { ID = int.Parse(e.Cell.Row.Cells["ID"].Text), TrangThai = true }; UpdateData.UpdateTrangThaiKt(hs); } Updatekythi(sender); } catch (Exception ex) { Log2File.LogExceptionToFile(ex); } }
public async Task <ActionResult <Kythi> > PostKythi([FromBody] Kythi kythi) { _context.Kythi.Add(kythi); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (KythiExists(kythi.Makythi)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetKythi", new { id = kythi.Makythi }, kythi)); }
private void uG_DanhSach_AfterExitEditMode(object sender, EventArgs e) { try { if (DeleteAndUpdate) { DeleteAndUpdate = false; return; } var id = uG_DanhSach.ActiveRow.Cells["ID"].Text; if (!string.IsNullOrEmpty(id)) { foreach (var item in _listUpdate.Where(item => item.ID == int.Parse(id))) { item.TenKT = uG_DanhSach.ActiveRow.Cells["TenKT"].Text; item.NgayThi = uG_DanhSach.ActiveRow.Cells["NgayThi"].Text; item.TGLamBai = uG_DanhSach.ActiveRow.Cells["TGLamBai"].Text; item.TGBatDau = uG_DanhSach.ActiveRow.Cells["TGBatDau"].Text; item.TGKetThuc = uG_DanhSach.ActiveRow.Cells["TGKetThuc"].Text; item.GhiChu = uG_DanhSach.ActiveRow.Cells["GhiChu"].Text; return; } var hs = new Kythi { ID = int.Parse(id), TenKT = uG_DanhSach.ActiveRow.Cells["TenKT"].Text, NgayThi = uG_DanhSach.ActiveRow.Cells["NgayThi"].Text, TGLamBai = uG_DanhSach.ActiveRow.Cells["TGLamBai"].Text, TGBatDau = uG_DanhSach.ActiveRow.Cells["TGBatDau"].Text, TGKetThuc = uG_DanhSach.ActiveRow.Cells["TGKetThuc"].Text, GhiChu = uG_DanhSach.ActiveRow.Cells["GhiChu"].Text, }; _listUpdate.Add(hs); } } catch (Exception ex) { Log2File.LogExceptionToFile(ex); } }