private void AddOrderButtonClick(object sender, RoutedEventArgs e) { string adressId = AdressIdOrder.Text; bool isAdressValid = adressId.All(Char.IsDigit); if (isAdressValid == true) { var isAdressExist = db.Adresses.Where(a => a.AdressId == int.Parse(adressId)).SingleOrDefault(); if (isAdressExist != null) { Order order = new Order() { AdressId = int.Parse(adressId) }; orderServices.AddData(order); MessageBox.Show("Row was inserted successfully"); RefreshOrderDataGridView(); } else { MessageBox.Show("Adress doesn't exist!"); } } else { MessageBox.Show("Invalid data!"); } }
private void AddAdressButtonClick(object sender, RoutedEventArgs e) { string name = NameAdress.Text; string latitude = LatitudeAdress.Text; string longitude = LongitudeAdress.Text; decimal latitudeDec; decimal longitudeDec; if (decimal.TryParse(latitude, out latitudeDec) && decimal.TryParse(longitude, out longitudeDec)) { Adress adress = new Adress() { Name = name, Latitude = latitudeDec, Longitude = longitudeDec }; adressServices.AddData(adress); MessageBox.Show("Row was inserted successfully"); RefreshAdressDataGridView(); } else { MessageBox.Show("Invalid data!"); } }
private void AddCourierButtonClick(object sender, RoutedEventArgs e) { string firstname = FirstNameCourier.Text; string lastname = LastNameCourier.Text; bool isFirstnameValid = firstname.All(Char.IsLetter); bool isLastnameValid = lastname.All(Char.IsLetter); if (isFirstnameValid == true && isLastnameValid == true) { Courier courier = new Courier() { FirstName = firstname, LastName = lastname, isFree = false }; courierServices.AddData(courier); MessageBox.Show("Row was inserted successfully"); RefreshCourierDataGridView(); } else { MessageBox.Show("Invalid data!"); } }