private void RemoveRecordDB() { using (PlannerContext db = new PlannerContext()) { db.DiaryDB.Remove(db.DiaryDB.Find(SelectedRecord.Id)); db.SaveChanges(); } }
/// <summary> /// Сохранение нового плана в бд /// </summary> /// <param name="newPlan"></param> private void SaveAddPlan(Plan newPlan) { using (PlannerContext db = new PlannerContext()) { db.PlanDB.Add(newPlan); db.SaveChanges(); } }
private void SaveAddRecord(Diary newPlan) { using (PlannerContext db = new PlannerContext()) { db.DiaryDB.Add(newPlan); db.SaveChanges(); } }
/// <summary> /// Удаление плана включая все его дочерние элементы /// </summary> /// <param name="children"></param> private void RemovePlanDB() { using (PlannerContext db = new PlannerContext()) { List <Guid> IdList = PlannerSorting.ReturnIdChildrenPlans(SelectedPlanner); foreach (Guid Id in IdList) { db.PlanDB.Remove(db.PlanDB.Find(Id)); } db.PlanDB.Remove(db.PlanDB.Find(SelectedPlanner.Id)); db.SaveChanges(); } }
/// <summary> /// Сохранение изменений в конечном сроке плана в бд /// </summary> /// <param name="sender"></param> private void SaveDeadlines(object sender) { DatePicker obj = sender as DatePicker; using (PlannerContext db = new PlannerContext()) { if (obj == Deadlines_DP) { db.PlanDB.Find(SelectedPlanner.Id).EndDate = SelectedPlanner.EndDate; } db.SaveChanges(); } }
private void DiarySaveTitleDB() { if (DiaryEdit) { using (PlannerContext db = new PlannerContext()) { db.DiaryDB.Find(SelectedRecord.Id).Title = SelectedRecord.Title; db.SaveChanges(); } DiaryEdit = false; } }
/// <summary> /// Сохранение заголовка в бд /// </summary> private void SaveTitleDB() { using (PlannerContext db = new PlannerContext()) { db.PlanDB.Find(SelectedPlanner.Id).Title = SelectedPlanner.Title; db.SaveChanges(); } if (SelectedPlanner.Children.Count == 0) { var task = to_do_list.SearchTask(SelectedPlanner.Id); if (task != null) { task.Title = SelectedPlanner.Title; } } }
/// <summary> /// Сохранение изменений данных в плане и в бд /// </summary> /// <param name="sender"></param> private void SaveData(object sender) { TextBox obj = sender as TextBox; using (PlannerContext db = new PlannerContext()) { //Plan plan = db.PlanDB.Find(SelectedPlanner.Id); if (obj == TargetTB) { //plan.Target = TargetTB.Text; db.PlanDB.Find(SelectedPlanner.Id ).Target = TargetTB.Text; } else if (obj == DescriptionTB) { //plan.Description = DescriptionTB.Text; db.PlanDB.Find(SelectedPlanner.Id ).Description = DescriptionTB .Text; //Перезапись описания в списке задач var task = to_do_list.SearchTask(SelectedPlanner.Id); if (task != null) { task.Children[0].Title = DescriptionTB.Text; } } else if (obj == MethodsTB) { //plan.Methods = MethodsTB.Text; db.PlanDB.Find(SelectedPlanner.Id).Methods = MethodsTB.Text; } else if (obj == FacilitiesTB) { //plan.Facilities = FacilitiesTB.Text; db.PlanDB.Find(SelectedPlanner.Id).Facilities = FacilitiesTB.Text; } db.SaveChanges(); } }