public void Insert(DAL.TracNghiem tracNghiem) { if (tracNghiem != null) { dataContext.TracNghiems.InsertOnSubmit(tracNghiem); Save(); } }
public void Delete(int id) { DAL.TracNghiem temp = dataContext.TracNghiems.SingleOrDefault(t => t.ID == id); if (temp != null) { dataContext.TracNghiems.DeleteOnSubmit(temp); Save(); } }
public void Update(DAL.TracNghiem tracNghiem) { DAL.TracNghiem temp = dataContext.TracNghiems.SingleOrDefault(t => t.ID == tracNghiem.ID); if (temp != null) { temp.CriterionID = tracNghiem.CriterionID; temp.ExplainName = tracNghiem.ExplainName; temp.MaxPoint = tracNghiem.MaxPoint; temp.MinPoint = tracNghiem.MinPoint; temp.Order = tracNghiem.Order; Save(); } }
protected void HandleChanges(object sender, BeforeStoreChangedEventArgs e) { try { TracNghiemController tracNghiemController = new TracNghiemController(); ChangeRecords <TracNghiemInfo> tracNghiems = e.DataHandler.ObjectData <TracNghiemInfo>(); // insert foreach (TracNghiemInfo created in tracNghiems.Created) { try { DAL.TracNghiem info = new DAL.TracNghiem(); info.CriterionID = hdfInsertedID.Text; info.ExplainName = created.ExplainName; info.MaxPoint = created.MaxPoint; info.MinPoint = created.MinPoint; info.Order = created.Order; tracNghiemController.Insert(info); } catch (Exception ex) { } } // update foreach (TracNghiemInfo updated in tracNghiems.Updated) { try { DAL.TracNghiem info = new DAL.TracNghiem(); info.CriterionID = hdfInsertedID.Text; info.ExplainName = updated.ExplainName; info.MaxPoint = updated.MaxPoint; info.MinPoint = updated.MinPoint; info.Order = updated.Order; tracNghiemController.Update(info); } catch (Exception ex) { } } // delete foreach (TracNghiemInfo deleted in tracNghiems.Deleted) { try { tracNghiemController.Delete(deleted.ID); } catch (Exception ex) { } } if (hdfTypeCommand.Text == "Insert") { Dialog.ShowNotification("Thêm mới thành công tiêu chí đánh giá"); if (hdfClose.Text == "True") { wdAddNewEstimateCriterion.Hide(); } else { RM.RegisterClientScriptBlock("rsform", "ResetCriterionWindow();"); } } else if (hdfTypeCommand.Text == "Edit") { Dialog.ShowNotification("Cập nhật thông tin tiêu chí đánh giá thành công"); wdAddNewEstimateCriterion.Hide(); } GridPanel1.Reload(); } catch (Exception ex) { Dialog.ShowError("Có lỗi xảy ra: " + ex.Message); } }