private void NoteForm_FormClosing(object sender, FormClosingEventArgs e) { if (!readyToClose) { DialogResult result = TripperMessageBox.Show("Czy czcesz wyjść bez zapisana zmian?", "Czy napewno?"); if (result != DialogResult.Yes) { e.Cancel = true; return; } } }
private void bAdd_Click(object sender, EventArgs e) { SelectedNote.NoteText = richTextBox.Text; try { Connection.TripperData.SubmitChanges(); readyToClose = true; this.Close(); } catch (Exception exept) { TripperMessageBox.Show(exept.ToString(), "Błąd"); } }
private void checkBox_CheckedChanged(object sender, EventArgs e) { bool currentState = !checkBox.Checked; ToDoCheckBox.IsChecked = checkBox.Checked; try { Connection.TripperData.SubmitChanges(); } catch (Exception exept) { TripperMessageBox.Show(exept.ToString(), "Błąd"); checkBox.Checked = currentState; } }
private void bDelete_Click(object sender, EventArgs e) { DialogResult result = TripperMessageBox.Show("Czy napewno usunąć?", "Czy napewno?"); if (result == DialogResult.Yes) { Connection.TripperData.Notes.DeleteOnSubmit(SelectedNote); try { this.Visible = false; Connection.TripperData.SubmitChanges(); } catch (Exception exept) { TripperMessageBox.Show(exept.ToString(), "Błąd"); } } }
private void bDelete_Click(object sender, EventArgs e) { DialogResult result = TripperMessageBox.Show("Czy chcesz usunąć zakwaterowanie?", "Czy napewno?"); if (result == DialogResult.Yes) { Connection.TripperData.Stayments.DeleteOnSubmit(SelectedStayment); try { this.Visible = false; Connection.TripperData.SubmitChanges(); OnAfterUpdate(EventArgs.Empty); } catch (Exception exept) { TripperMessageBox.Show(exept.ToString(), "Błąd"); } } }
private void bDelete_Click(object sender, EventArgs e) { DialogResult result = TripperMessageBox.Show("Czy chcesz usunąć podróż?", "Czy napewno?"); if (result == DialogResult.Yes) { Connection.TripperData.Trips.DeleteOnSubmit(SelectedTrip); try { this.Visible = false; Connection.TripperData.Transports.DeleteAllOnSubmit(Connection.TripperData.Transports.Where(t => t.Trip == SelectedTrip)); Connection.TripperData.Stayments.DeleteAllOnSubmit(Connection.TripperData.Stayments.Where(t => t.Trip == SelectedTrip)); Connection.TripperData.OtherCosts.DeleteAllOnSubmit(Connection.TripperData.OtherCosts.Where(t => t.Trip == SelectedTrip)); Connection.TripperData.SubmitChanges(); OnAfterUpdate(EventArgs.Empty); } catch (Exception exept) { TripperMessageBox.Show(exept.ToString(), "Błąd"); } } }
private void addNewCity() { var list = cbCity.DataSource as List <Localization>; if (list != null) { bool ifCityExist = list.Any(city => city.City.Equals(cbCity.Text, StringComparison.Ordinal)); if (!ifCityExist && cbCity.Text != string.Empty) { DialogResult result = TripperMessageBox.Show("Podanego miasta nie ma na liście.\nCzy chcesz je dodać?", "Czy chcesz dodać miasto? "); if (result == DialogResult.Yes) { Localization newCity = new Localization(); newCity.Country = cbCountry.SelectedItem as Country; newCity.City = cbCity.Text; Connection.TripperData.Localizations.InsertOnSubmit(newCity); try { Connection.TripperData.SubmitChanges(); cityList = Connection.TripperData.Localizations.Where(city => city.Country.Equals(cbCountry.SelectedItem) && city.Equals(newCity)).ToList(); cbCity.DataSource = cityList; } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { cbCity.Text = string.Empty; cbCity.SendToBack(); } //cbCity_Validating(cbCity, null); cbCity.Close(); } } }