private void ButtonAddEdit_Click(object sender, RoutedEventArgs e) { if (this.add_edit == true) { if (date.Text != string.Empty && employee.Text != string.Empty && customer.Text != string.Empty) { WpfApplicationEntity.API.Order objectOrder = new WpfApplicationEntity.API.Order(); objectOrder.date = date.Text; objectOrder.status = status.IsEnabled; try { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { objectMyDBContext.Orders.Add(objectOrder); objectMyDBContext.SaveChanges(); } MessageBox.Show("Заказ добавлен"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } }
private void ButtonAddEdit_Click(object sender, RoutedEventArgs e) { if (this.add_edit == true) { if (date.Text != string.Empty && shop.Text != string.Empty) { WpfApplicationEntity.API.Production_plan objectPlan = new WpfApplicationEntity.API.Production_plan(); objectPlan.date = date.Text; //objectPlan.shop = shop.Text; try { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { objectMyDBContext.Production_plans.Add(objectPlan); objectMyDBContext.SaveChanges(); } MessageBox.Show("План добавлен"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { WpfApplicationEntity.API.Action naz = new WpfApplicationEntity.API.Action(); List <string> list = new List <string>(); var actions = objectMyDBContext.Action_for_the_needys.ToList(); foreach (var item in actions) { list.Add(item.Name); } comboBlockAddEditActionForTheNeedy.ItemsSource = list; List <string> list1 = new List <string>(); var actions1 = objectMyDBContext.Type_Actions.ToList(); foreach (var item in actions1) { list1.Add(item.Name); } comboBlockAddEditTypeAction.ItemsSource = list1; if (add_edit == false) { ButtonAddEditGroup.Content = "Сохранить"; naz = objectMyDBContext.Actions.Find(EditID); Starttime.Text = naz.StarTime; Endtime.Text = naz.EndTime; Dateofthe.Text = naz.TheDateOfThe; Numberofvolunteer.Text = naz.NumberOfVolonteers.ToString(); Numberofneedy.Text = naz.NumberOfNeeds.ToString(); comboBlockAddEditActionForTheNeedy.Text = naz.Action_for_the_needy.Name; comboBlockAddEditTypeAction.Text = naz.Type_Action.Name; } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { WpfApplicationEntity.API.Needy naz = new WpfApplicationEntity.API.Needy(); List <string> list = new List <string>(); var actions = objectMyDBContext.Registration_for_a_needss.ToList(); foreach (var item in actions) { list.Add(item.ApplicationDate); } comboBlockAddEditRegistrationForANeeds.ItemsSource = list; List <string> list1 = new List <string>(); var actions1 = objectMyDBContext.Action_for_the_needys.ToList(); foreach (var item in actions1) { list1.Add(item.Name); } comboBlockAddEditActionForTheNeedy.ItemsSource = list1; if (add_edit == false) { ButtonAddEditNeedy.Content = "Сохранить"; naz = objectMyDBContext.Needys.Find(EditID); Addres.Text = naz.Addres; MiddleName.Text = naz.MiddleName; Surname.Text = naz.SurName; LastName.Text = naz.LastName; Disability.Text = naz.Disability; PhoneNumber.Text = naz.PhoneNumber; Genum.Text = naz.Genus; comboBlockAddEditRegistrationForANeeds.Text = naz.Registration_for_a_needs.ApplicationDate; comboBlockAddEditActionForTheNeedy.Text = naz.Action_for_the_needy.Name; } } }
private void ButtonAddEdit_Click(object sender, RoutedEventArgs e) { if (this.add_edit == true) { if (name.Text != string.Empty && shop.Text != string.Empty) { WpfApplicationEntity.API.Product_Type objectProduct_type = new WpfApplicationEntity.API.Product_Type(); objectProduct_type.name = name.Text; try { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { objectMyDBContext.Product_types.Add(objectProduct_type); objectMyDBContext.SaveChanges(); } MessageBox.Show("Вид продукции добавлен"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } }
private void ButtonAddEditShop_Click(object sender, RoutedEventArgs e) { if (this.add_edit == true) { if (textBlockAddEditShop.Text != string.Empty) { WpfApplicationEntity.API.Shop objectShop = new WpfApplicationEntity.API.Shop(); objectShop.number = Convert.ToInt32(textBlockAddEditShop.Text); try { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { objectMyDBContext.Shops.Add(objectShop); objectMyDBContext.SaveChanges(); } MessageBox.Show("Цех добавлен"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } }
private void ButtonAddEditAction_Click(object sender, RoutedEventArgs e) { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { if (this.add_edit == true) { if (Starttime.Text != string.Empty && Endtime.Text != string.Empty && Dateofthe.Text != string.Empty && Numberofvolunteer.Text != string.Empty && Numberofneedy.Text != string.Empty && comboBlockAddEditActionForTheNeedy.SelectedIndex != -1 && comboBlockAddEditTypeAction.SelectedIndex != -1) { WpfApplicationEntity.API.Action objectAction = new WpfApplicationEntity.API.Action(); objectAction.StarTime = Starttime.Text; objectAction.EndTime = Endtime.Text; objectAction.TheDateOfThe = Dateofthe.Text; objectAction.NumberOfVolonteers = Convert.ToInt32(Numberofvolunteer.Text); objectAction.NumberOfNeeds = Convert.ToInt32(Numberofneedy.Text); objectAction.Action_for_the_needy = GetActionForTheNeedy(objectMyDBContext.Action_for_the_needys.ToList()); objectAction.Type_Action = GetTypeAction(objectMyDBContext.Type_Actions.ToList()); try { objectMyDBContext.Actions.Add(objectAction); objectMyDBContext.SaveChanges(); MessageBox.Show("Акция добавлена"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } else { var result = objectMyDBContext.Actions.Find(EditID); result.StarTime = Starttime.Text; result.EndTime = Endtime.Text; result.TheDateOfThe = Dateofthe.Text; result.NumberOfVolonteers = Convert.ToInt32(Numberofvolunteer.Text); result.NumberOfNeeds = Convert.ToInt32(Numberofneedy.Text); result.Action_for_the_needy = GetActionForTheNeedy(objectMyDBContext.Action_for_the_needys.ToList()); result.Type_Action = GetTypeAction(objectMyDBContext.Type_Actions.ToList()); } objectMyDBContext.SaveChanges(); } this.Close(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { WpfApplicationEntity.API.Action_for_the_needy naz = new WpfApplicationEntity.API.Action_for_the_needy(); if (add_edit == false) { ButtonAddEditGroup.Content = "Сохранить"; naz = objectMyDBContext.Action_for_the_needys.Find(EditID); Name.Text = naz.Name; } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { WpfApplicationEntity.API.Registration_for_a_volunteer naz = new WpfApplicationEntity.API.Registration_for_a_volunteer(); if (add_edit == false) { ButtonAddEditGroup.Content = "Сохранить"; naz = objectMyDBContext.Registration_for_a_volunteers.Find(EditID); date.Text = naz.Date; } } }
private void ButtonAddEditEmployee_Click(object sender, RoutedEventArgs e) { if (this.add_edit == true) { if (textBlockAddEditaddress.Text != string.Empty && textBlockAddEditbirth_date.Text != string.Empty && textBlockAddEditfname.Text != string.Empty && textBlockAddEditlName.Text != string.Empty && textBlockAddEditlogin.Text != string.Empty && textBlockAddEditname.Text != string.Empty && textBlockAddEditpassword.Text != string.Empty && textBlockAddEditphone.Text != string.Empty && textBlockAddEditposition.Text != string.Empty && textBlockAddEditposition_set_date.Text != string.Empty && textBlockAddEditshop.Text != string.Empty) { WpfApplicationEntity.API.Employee objectEmployee = new WpfApplicationEntity.API.Employee(); objectEmployee.address = textBlockAddEditaddress.Text; objectEmployee.birth_date = textBlockAddEditbirth_date.Text; objectEmployee.fName = textBlockAddEditfname.Text; objectEmployee.lName = textBlockAddEditlName.Text; objectEmployee.login = textBlockAddEditlogin.Text; objectEmployee.name = textBlockAddEditname.Text; objectEmployee.password = textBlockAddEditpassword.Text; objectEmployee.phone = textBlockAddEditphone.Text; objectEmployee.position = textBlockAddEditposition.Text; objectEmployee.position_set_date = textBlockAddEditposition_set_date.Text; // objectEmployee.shop = (ICollection<API.Shop>)textBlockAddEditshop.Text; try { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { objectMyDBContext.Employees.Add(objectEmployee); objectMyDBContext.SaveChanges(); } MessageBox.Show("Сотрудник добавлен"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } }
private void ButtonAddEditService_Click(object sender, RoutedEventArgs e) { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { if (this.add_edit == true) { if (name.Text != string.Empty && spendingTime.Text != string.Empty && comboBlockAddEditRegistrationForAVolunteer.SelectedIndex != -1 && comboBlockAddEditRegistrationForANeeds.SelectedIndex != -1 && comboBlockAddEditTypeService.SelectedIndex != -1) { WpfApplicationEntity.API.Service objectService = new WpfApplicationEntity.API.Service(); objectService.Name = name.Text; objectService.SpendingTime = spendingTime.Text; objectService.Registration_for_a_volunteer = GetRegistrationForAVolunteer(objectMyDBContext.Registration_for_a_volunteers.ToList()); objectService.Registration_for_a_needs = GetRegistrationForANeeds(objectMyDBContext.Registration_for_a_needss.ToList()); objectService.Type_Service = GetTypeService(objectMyDBContext.Type_Services.ToList()); try { objectMyDBContext.Services.Add(objectService); objectMyDBContext.SaveChanges(); MessageBox.Show("Услуга добавлена"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } else { var result = objectMyDBContext.Services.Find(EditID); result.Name = name.Text; result.SpendingTime = spendingTime.Text; result.Registration_for_a_volunteer = GetRegistrationForAVolunteer(objectMyDBContext.Registration_for_a_volunteers.ToList()); result.Registration_for_a_needs = GetRegistrationForANeeds(objectMyDBContext.Registration_for_a_needss.ToList()); result.Type_Service = GetTypeService(objectMyDBContext.Type_Services.ToList()); } objectMyDBContext.SaveChanges(); } this.Close(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { WpfApplicationEntity.API.Type_Service naz = new WpfApplicationEntity.API.Type_Service(); if (add_edit == false) { ButtonAddEditGroup.Content = "Сохранить"; naz = objectMyDBContext.Type_Services.Find(EditID); name.Text = naz.Name; discripsion.Text = naz.Discripsion; } } }
private void ShowAll() { try { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { shopGrid.ItemsSource = WpfApplicationEntity.API.DatabaseRequest.GetShops(objectMyDBContext); } } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void ButtonAddEditRegistrationForANeeds_Click(object sender, RoutedEventArgs e) { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { if (this.add_edit == true) { if (plannedDate.Text != string.Empty && applicationDate.Text != string.Empty && actualDate.Text != string.Empty && registrationDate.SelectedIndex != -1) { WpfApplicationEntity.API.Registration_for_a_needs objectRegistrationForANeeds = new WpfApplicationEntity.API.Registration_for_a_needs(); objectRegistrationForANeeds.PlannedDate = plannedDate.Text; objectRegistrationForANeeds.ApplicationDate = applicationDate.Text; objectRegistrationForANeeds.ActualDate = actualDate.Text; objectRegistrationForANeeds.Registration_for_a_volunteer = GetRegistrationForAVolunteer(objectMyDBContext.Registration_for_a_volunteers.ToList()); try { objectMyDBContext.Registration_for_a_needss.Add(objectRegistrationForANeeds); objectMyDBContext.SaveChanges(); MessageBox.Show("Регистрация нуждающегося добавлена"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } else { var result = objectMyDBContext.Registration_for_a_needss.Find(EditID); result.PlannedDate = plannedDate.Text; result.ApplicationDate = applicationDate.Text; result.ActualDate = actualDate.Text; result.Registration_for_a_volunteer = GetRegistrationForAVolunteer(objectMyDBContext.Registration_for_a_volunteers.ToList()); } objectMyDBContext.SaveChanges(); } this.Close(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { if (objectMyDBContext.Database.Exists() == false) { objectMyDBContext.Database.Create(); WpfApplicationEntity.API.Employee objectEmployee = new WpfApplicationEntity.API.Employee(); objectEmployee.fName = "user fname"; objectEmployee.name = "user"; objectEmployee.lName = "user"; objectEmployee.position = "admin"; objectEmployee.login = "******"; objectEmployee.password = "******"; objectEmployee.birth_date = "555555"; objectEmployee.address = "home"; objectEmployee.phone = "543543"; objectEmployee.position_set_date = "234556"; objectMyDBContext.Employees.Add(objectEmployee); objectMyDBContext.SaveChanges(); } //WpfApplicationEntity.API.Employee objectEmployee1 = new WpfApplicationEntity.API.Employee(); //objectEmployee1.fName = "user fname"; //objectEmployee1.name = "user"; //objectEmployee1.lName = "user"; //objectEmployee1.position = "admin"; //objectEmployee1.login = "******"; //objectEmployee1.password = "******"; //objectEmployee1.birth_date = "555555"; //objectEmployee1.address = "home"; //objectEmployee1.phone = "543543"; //objectEmployee1.position_set_date = "234556"; //objectMyDBContext.Employees.Add(objectEmployee1); //objectMyDBContext.SaveChanges(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } this.ShowAll(); }
private void ButtonAddEditTypeAction_Click(object sender, RoutedEventArgs e) { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { if (this.add_edit == true) { if (name.Text != string.Empty && discription.Text != string.Empty && duration.Text != string.Empty) { WpfApplicationEntity.API.Type_Action objectTypeAction = new WpfApplicationEntity.API.Type_Action(); objectTypeAction.Name = name.Text; objectTypeAction.Discription = discription.Text; objectTypeAction.Duration = duration.Text; try { objectMyDBContext.Type_Actions.Add(objectTypeAction); objectMyDBContext.SaveChanges(); MessageBox.Show("Тип акции добавлен"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } else { var result = objectMyDBContext.Type_Actions.Find(EditID); result.Name = name.Text; result.Discription = discription.Text; result.Duration = duration.Text; } objectMyDBContext.SaveChanges(); } this.Close(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { WpfApplicationEntity.API.Volunteer naz = new WpfApplicationEntity.API.Volunteer(); List <string> list = new List <string>(); var actions = objectMyDBContext.Action_for_the_needys.ToList(); foreach (var item in actions) { list.Add(item.Name); } comboBlockAddEditActionForTheNeedy.ItemsSource = list; List <string> list1 = new List <string>(); var actions1 = objectMyDBContext.Registration_for_a_volunteers.ToList(); foreach (var item in actions1) { list1.Add(item.Date); } comboBlockAddEditRegistrationForAVolunteer.ItemsSource = list1; if (add_edit == false) { ButtonAddEditGroup.Content = "Сохранить"; naz = objectMyDBContext.Volunteers.Find(EditID); textBlockAddEditAddres.Text = naz.Addres; textBlockAddEditBirthday.Text = naz.DateOfBirth; textBlockAddEditMiddleName.Text = naz.MiddleName; textBlockAddEditSurname.Text = naz.SurName; textBlockAddEditLastName.Text = naz.LastName; textBlockAddEditLogin.Text = naz.Login; textBlockAddEditPassword.Text = naz.Password; textBlockAddEditNumberPhone.Text = naz.PhoneNumber; textBlockAddEditGenus.Text = naz.Genus; comboBlockAddEditActionForTheNeedy.Text = naz.Action_for_the_needy.Name; comboBlockAddEditRegistrationForAVolunteer.Text = naz.Registration_for_a_volunteer.Date; } } } catch { } }
private void Window_Loaded(object sender, RoutedEventArgs e) { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { WpfApplicationEntity.API.Service naz = new WpfApplicationEntity.API.Service(); List <string> list = new List <string>(); var actions = objectMyDBContext.Registration_for_a_volunteers.ToList(); foreach (var item in actions) { list.Add(item.Date); } comboBlockAddEditRegistrationForAVolunteer.ItemsSource = list; List <string> list1 = new List <string>(); var actions1 = objectMyDBContext.Registration_for_a_needss.ToList(); foreach (var item in actions1) { list1.Add(item.ApplicationDate); } comboBlockAddEditRegistrationForANeeds.ItemsSource = list1; List <string> list2 = new List <string>(); var actions2 = objectMyDBContext.Type_Services.ToList(); foreach (var item in actions2) { list2.Add(item.Name); } comboBlockAddEditTypeService.ItemsSource = list2; if (add_edit == false) { ButtonAddEditGroup.Content = "Сохранить"; naz = objectMyDBContext.Services.Find(EditID); name.Text = naz.Name; spendingTime.Text = naz.SpendingTime; comboBlockAddEditRegistrationForAVolunteer.Text = naz.Registration_for_a_volunteer.Date; comboBlockAddEditRegistrationForANeeds.Text = naz.Registration_for_a_needs.ApplicationDate; comboBlockAddEditTypeService.Text = naz.Type_Service.Name; } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { WpfApplicationEntity.API.Registration_for_a_needs naz = new WpfApplicationEntity.API.Registration_for_a_needs(); List <string> list = new List <string>(); var actions = objectMyDBContext.Registration_for_a_volunteers.ToList(); foreach (var item in actions) { list.Add(item.Date); } registrationDate.ItemsSource = list; if (add_edit == false) { ButtonAddEditGroup.Content = "Сохранить"; naz = objectMyDBContext.Registration_for_a_needss.Find(EditID); plannedDate.Text = naz.PlannedDate; applicationDate.Text = naz.ApplicationDate; actualDate.Text = naz.ActualDate; registrationDate.Text = naz.Registration_for_a_volunteer.Date; } } }
private void ButtonAddEditRegistrationForAVolunteer_Click(object sender, RoutedEventArgs e) { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { if (this.add_edit == true) { if (date.Text != string.Empty) { WpfApplicationEntity.API.Registration_for_a_volunteer objectRegistrationForAVolunteer = new WpfApplicationEntity.API.Registration_for_a_volunteer(); objectRegistrationForAVolunteer.Date = date.Text; try { objectMyDBContext.Registration_for_a_volunteers.Add(objectRegistrationForAVolunteer); objectMyDBContext.SaveChanges(); MessageBox.Show("Регистрация волонтёра добавлена"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } else { var result = objectMyDBContext.Registration_for_a_volunteers.Find(EditID); result.Date = date.Text; } objectMyDBContext.SaveChanges(); } this.Close(); }
private void ButtonAddEditAction_Click(object sender, RoutedEventArgs e) { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { if (this.add_edit == true) { if (Name.Text != string.Empty) { WpfApplicationEntity.API.Action_for_the_needy objectAction = new WpfApplicationEntity.API.Action_for_the_needy(); objectAction.Name = Name.Text; try { objectMyDBContext.Action_for_the_needys.Add(objectAction); objectMyDBContext.SaveChanges(); MessageBox.Show("Акция для нуждающегося добавлена"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } else { var result = objectMyDBContext.Action_for_the_needys.Find(EditID); result.Name = Name.Text; } objectMyDBContext.SaveChanges(); } this.Close(); }
private void ButtonAddEdit_Click(object sender, RoutedEventArgs e) { if (this.add_edit == true) { if (textBlockAddEditname.Text != string.Empty && textBlockAddEditprice.Text != string.Empty && textBlockAddEditlshelf_life.Text != string.Empty && textBlockAddEditltype.Text != string.Empty) { WpfApplicationEntity.API.Product objectProduct = new WpfApplicationEntity.API.Product(); objectProduct.name = textBlockAddEditname.Text; objectProduct.price = Convert.ToDouble(textBlockAddEditprice.Text); objectProduct.shelf_life = textBlockAddEditlshelf_life.Text; //objectProduct.type = textBlockAddEditlphone.Text; try { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { objectMyDBContext.Products.Add(objectProduct); objectMyDBContext.SaveChanges(); } MessageBox.Show("Продукт добавлен"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } }
private void ButtonAddEdit_Click(object sender, RoutedEventArgs e) { if (this.add_edit == true) { if (textBlockAddEditaddress.Text != string.Empty && textBlockAddEditaddress.Text != string.Empty && textBlockAddEditlphone.Text != string.Empty && textBlockAddEditname.Text != string.Empty) { WpfApplicationEntity.API.Customer objectCustomer = new WpfApplicationEntity.API.Customer(); objectCustomer.address = textBlockAddEditaddress.Text; objectCustomer.Name = textBlockAddEditname.Text; objectCustomer.phone = textBlockAddEditlphone.Text; try { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { objectMyDBContext.Customers.Add(objectCustomer); objectMyDBContext.SaveChanges(); } MessageBox.Show("Заказчик добавлен"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } }
private void ButtonAddEdit_Click(object sender, RoutedEventArgs e) { if (this.add_edit == true) { if (count.Text != string.Empty && manufacturing_date.Text != string.Empty && shop.Text != string.Empty && product.Text != string.Empty && employee.Text != string.Empty) { WpfApplicationEntity.API.Product_in_stock objectProduct_in_stock = new WpfApplicationEntity.API.Product_in_stock(); objectProduct_in_stock.count = Convert.ToInt32(count.Text); objectProduct_in_stock.manufacture_date = manufacturing_date.Text; try { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { objectMyDBContext.Product_in_stocks.Add(objectProduct_in_stock); objectMyDBContext.SaveChanges(); } MessageBox.Show("Прадукция на складе добавлена"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } }
private void ButtonAddEdit_Click(object sender, RoutedEventArgs e) { if (this.add_edit == true) { if (receiving_date.Text != string.Empty && departuring_date.Text != string.Empty && count.Text != string.Empty && order.Text != string.Empty) { WpfApplicationEntity.API.Shipment objectShipment = new WpfApplicationEntity.API.Shipment(); objectShipment.departure_date = departuring_date.Text; objectShipment.receiving_date = receiving_date.Text; objectShipment.count = Convert.ToInt32(count.Text); try { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { objectMyDBContext.Shipments.Add(objectShipment); objectMyDBContext.SaveChanges(); } MessageBox.Show("Запись отгрузки добавлена"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } }
private void ButtonAddEditNeedy_Click(object sender, RoutedEventArgs e) { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { if (this.add_edit == true) { if (Addres.Text != string.Empty && MiddleName.Text != string.Empty && Surname.Text != string.Empty && LastName.Text != string.Empty && Disability.Text != string.Empty && PhoneNumber.Text != string.Empty && Genum.Text != string.Empty && comboBlockAddEditRegistrationForANeeds.SelectedIndex != -1 && comboBlockAddEditActionForTheNeedy.SelectedIndex != -1) { WpfApplicationEntity.API.Needy objectNeedy = new WpfApplicationEntity.API.Needy(); objectNeedy.Addres = Addres.Text; objectNeedy.MiddleName = MiddleName.Text; objectNeedy.SurName = Surname.Text; objectNeedy.LastName = LastName.Text; objectNeedy.Disability = Disability.Text; objectNeedy.PhoneNumber = PhoneNumber.Text; objectNeedy.Genus = Genum.Text; objectNeedy.Registration_for_a_needs = GetRegistrationForANeeds(objectMyDBContext.Registration_for_a_needss.ToList()); objectNeedy.Action_for_the_needy = GetActionForTheNeedy(objectMyDBContext.Action_for_the_needys.ToList()); try { objectMyDBContext.Needys.Add(objectNeedy); objectMyDBContext.SaveChanges(); MessageBox.Show("Нуждающийся добавлен"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } else { var result = objectMyDBContext.Needys.Find(EditID); result.Addres = Addres.Text; result.MiddleName = MiddleName.Text; result.SurName = Surname.Text; result.LastName = LastName.Text; result.Disability = Disability.Text; result.PhoneNumber = PhoneNumber.Text; result.Genus = Genum.Text; result.Registration_for_a_needs = GetRegistrationForANeeds(objectMyDBContext.Registration_for_a_needss.ToList()); result.Action_for_the_needy = GetActionForTheNeedy(objectMyDBContext.Action_for_the_needys.ToList()); } objectMyDBContext.SaveChanges(); } this.Close(); }
private void ButtonAddEditVolunteer_Click(object sender, RoutedEventArgs e) { using (WpfApplicationEntity.API.MyDBContext objectMyDBContext = new WpfApplicationEntity.API.MyDBContext()) { if (this.add_edit == true) { if (textBlockAddEditAddres.Text != string.Empty && textBlockAddEditBirthday.Text != string.Empty && textBlockAddEditMiddleName.Text != string.Empty && textBlockAddEditSurname.Text != string.Empty && textBlockAddEditLastName.Text != string.Empty && textBlockAddEditLogin.Text != string.Empty && textBlockAddEditPassword.Text != string.Empty && textBlockAddEditNumberPhone.Text != string.Empty && textBlockAddEditGenus.Text != string.Empty && comboBlockAddEditActionForTheNeedy.SelectedIndex != -1 && comboBlockAddEditRegistrationForAVolunteer.SelectedIndex != -1) { WpfApplicationEntity.API.Volunteer objectVolunteer = new WpfApplicationEntity.API.Volunteer(); objectVolunteer.Addres = textBlockAddEditAddres.Text; objectVolunteer.DateOfBirth = textBlockAddEditBirthday.Text; objectVolunteer.MiddleName = textBlockAddEditMiddleName.Text; objectVolunteer.SurName = textBlockAddEditSurname.Text; objectVolunteer.LastName = textBlockAddEditLastName.Text; objectVolunteer.Login = textBlockAddEditLogin.Text; objectVolunteer.Password = textBlockAddEditPassword.Text; objectVolunteer.PhoneNumber = textBlockAddEditNumberPhone.Text; objectVolunteer.Genus = textBlockAddEditGenus.Text; objectVolunteer.Action_for_the_needy = GetActionForTheNeedy(objectMyDBContext.Action_for_the_needys.ToList()); objectVolunteer.Registration_for_a_volunteer = GetRegistrationForAVolunteer(objectMyDBContext.Registration_for_a_volunteers.ToList()); try { objectMyDBContext.Volunteers.Add(objectVolunteer); objectMyDBContext.SaveChanges(); MessageBox.Show("Волонтёр добавлен"); this.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ОШИБКА", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Заполните все поля!", "Ошибка!"); this.DialogResult = false; } } else { var result = objectMyDBContext.Volunteers.Find(EditID); result.Addres = textBlockAddEditAddres.Text; result.DateOfBirth = textBlockAddEditBirthday.Text; result.MiddleName = textBlockAddEditMiddleName.Text; result.SurName = textBlockAddEditSurname.Text; result.LastName = textBlockAddEditLastName.Text; result.Login = textBlockAddEditLogin.Text; result.Password = textBlockAddEditPassword.Text; result.PhoneNumber = textBlockAddEditNumberPhone.Text; result.Genus = textBlockAddEditGenus.Text; result.Action_for_the_needy = GetActionForTheNeedy(objectMyDBContext.Action_for_the_needys.ToList()); result.Registration_for_a_volunteer = GetRegistrationForAVolunteer(objectMyDBContext.Registration_for_a_volunteers.ToList()); } objectMyDBContext.SaveChanges(); } this.Close(); }