private void SubmitChanges()
        {
            if (saveChanges())
            {
                DialogResult result;
                if (Mode == CreatorMode.AddNew)
                {
                    result = TripperMessageBox.Show("Dodać nowy koszt?", "");
                }
                else
                {
                    result = TripperMessageBox.Show("Zapiszać zmiany?", "");
                }

                if (result == DialogResult.Yes)
                {
                    try
                    {
                        Connection.TripperData.SubmitChanges();
                        Status = CreatorStatus.Confirmed;
                        OnAfterAdd(EventArgs.Empty);
                        OnAfterUpdate(EventArgs.Empty);
                    }
                    catch (Exception exept)
                    {
                        TripperMessageBox.Show(exept.ToString(), "Błąd");
                    }

                    if (Mode == BusinessLogic.CreatorMode.AddNew)
                    {
                        this.Close();
                    }
                }
            }
        }
Beispiel #2
0
        public void confirmChanges(string newAddMessage, string editMessage = "Zapisać zmiany?", bool closeAfterAdd = true)
        {
            DialogResult result;

            if (Mode == CreatorMode.AddNew)
            {
                result = TripperMessageBox.Show(newAddMessage, "");
            }
            else
            {
                result = TripperMessageBox.Show(editMessage, "");
            }

            if (result == DialogResult.Yes)
            {
                try
                {
                    Connection.TripperData.SubmitChanges();
                    Status = CreatorStatus.Confirmed;
                    OnAfterUpdate(EventArgs.Empty);
                }
                catch (Exception exept)
                {
                    TripperMessageBox.Show(exept.ToString(), "Błąd");
                }

                if (Mode == BusinessLogic.CreatorMode.AddNew && closeAfterAdd)
                {
                    this.Close();
                }
            }
        }
 private void AddNewTripForm_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;
         }
     }
 }
Beispiel #4
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (!readyToClose)
     {
         DialogResult result = TripperMessageBox.Show("Czy czcesz zamknąć program?", "Czy napewno?");
         if (result != DialogResult.Yes)
         {
             e.Cancel = true;
             return;
         }
     }
 }
Beispiel #5
0
        public override bool CanBeClosed()
        {
            base.CanBeClosed();

            if (Mode == BusinessLogic.CreatorMode.AddNew && Status == CreatorStatus.Edit)
            {
                DialogResult result = TripperMessageBox.Show("Czy czcesz wyjść bez zapisana zmian?", "Czy napewno?");
                if (result != DialogResult.Yes)
                {
                    return(false);
                }
            }
            return(true);
        }
        private void bAdd_Click(object sender, EventArgs e)
        {
            if (tTitle.CheckValidation())
            {
                if (Mode == CreatorMode.AddNew)
                {
                    Trip newTrip = new Trip();
                    newTrip.Name       = tTitle.Text;
                    newTrip.ImageIndex = SelectedAvatar;
                    newTrip.TravelerID = SelectedTraveler.TravelerID;
                    Connection.TripperData.Trips.InsertOnSubmit(newTrip);
                    CurrentSelected.Trip = newTrip;
                    try
                    {
                        this.Hide();
                        Connection.TripperData.SubmitChanges();
                        readyToClose = true;
                        OnAfterAdd(EventArgs.Empty);
                        this.Close();
                    }
                    catch (Exception exept)
                    {
                        TripperMessageBox.Show(exept.ToString(), "Błąd");
                    }
                }
                else
                {
                    SelectedTrip.Name       = tTitle.Text;
                    SelectedTrip.ImageIndex = SelectedAvatar;

                    try
                    {
                        Connection.TripperData.SubmitChanges();
                        readyToClose = true;
                        this.Close();
                    }
                    catch (Exception exept)
                    {
                        TripperMessageBox.Show(exept.ToString(), "Błąd");
                    }
                }
            }
        }