public void CreateApplication() { if (IsValidation()) { var application = new Model.Aplication() { Name = Name, Adress = Adress, Surname = Surname, MiddleName = MiddleName, Problem = Problem, Status = true }; using (DbTest db = new DbTest()) { db.Aplication.Add(application); db.SaveChanges(); MessageDb = "Сохранили В БД"; UpdateModel(); } } else { MessageBox.Show(@"Не введены данные"); } }
private void AddApplicationWin() { ApplicationWin.Clear(); using (DbTest db = new DbTest()) { var app = db.Aplication.Where(appl => appl.Status == false); foreach (Aplication aplication in app) { ApplicationWin.Add(aplication); } } }
public void DeleteApplication() { if (SelectAplication == null) { MessageBox.Show(@"Ошибка не выбран объект"); } else { using (DbTest db = new DbTest()) { db.Entry(SelectAplication).State = EntityState.Deleted; db.SaveChanges(); } UpdateModel(); } }
public void StatusWin() { if (SelectAplication == null) { MessageBox.Show(@"Ошибка не выбран объект"); } else { SelectAplication.Status = false; using (DbTest db = new DbTest()) { db.Entry(SelectAplication).State = EntityState.Modified; db.SaveChanges(); } UpdateModel(); } }
/// <summary> /// Сбор статистики /// </summary> public void SeathStatistics() { if (!IsValidationDateStatistics()) { MessageBox.Show("Ошибки в дате диопазона!!!"); } else { IQueryable <Aplication>[] iqveryarray = new IQueryable <Aplication> [3]; using (DbTest db = new DbTest()) { var allapp = db.Aplication.Where(appl => appl.DateCreate >= StartDateTime || appl.DateCreate <= FinishDateTime); var trueapp = db.Aplication.Where(appl => appl.Status == true); var falseapp = db.Aplication.Where(appl => appl.Status == false); iqveryarray[0] = allapp; iqveryarray[1] = trueapp; iqveryarray[2] = falseapp; MainWindow(iqveryarray); Statistic = $@"Количество заявок в диопазоне c {StartDateTime} по {FinishDateTime}"; } } }