Example #1
0
        private void miDelete_Click(object sender, RoutedEventArgs e)
        {
            Flightt f = (Flightt)lbFlights.SelectedItem;

            if (f == null)
            {
                return;
            }
            Global.ctx.Flights.Remove(f);
            Global.ctx.SaveChanges();
            refreshFlight();
        }
Example #2
0
        private void miUpdate_Click(object sender, RoutedEventArgs e)
        {
            Flightt f = (Flightt)lbFlights.SelectedItem;

            if (f == null)
            {
                return;
            }
            DlgAddEdit dlg = new DlgAddEdit(f);

            if (dlg.ShowDialog() == true)
            {
                refreshFlight();
            }
        }
Example #3
0
        private void miSave_Click(object sender, RoutedEventArgs e)
        {
            Flightt f = (Flightt)lbFlights.SelectedItem;

            if (f == null)
            {
                return;
            }
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            string         content        = string.Format("{0}", f);

            if (saveFileDialog.ShowDialog() == true)
            {
                File.WriteAllText(saveFileDialog.FileName, content);
            }
        }
Example #4
0
 public DlgAddEdit(Flightt f)
 {
     currentFlight = f;
     InitializeComponent();
     if (currentFlight == null)
     {
         btnSave.Content = "Add new";
     }
     else
     {
         lblId.Content          = f.Id;
         dtpkOnDay.SelectedDate = f.OnDay;
         tbFromCode.Text        = f.FromCode;
         tbToCode.Text          = f.ToCode;
         cbbxType.SelectedItem  = f.Type;
         slPassengers.Value     = f.Passengers;
     }
 }
Example #5
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (tbFromCode.Text.Equals("") && tbToCode.Equals("") && dtpkOnDay.SelectedDate.Equals(""))
            {
                MessageBox.Show("Please enter infomation to add");
                return;
            }
            else
            {
                Flightt  f        = currentFlight == null ? new Flightt() : currentFlight;
                DateTime onDay    = (DateTime)dtpkOnDay.SelectedDate;
                string   fromCode = tbFromCode.Text;
                string   toCode   = tbToCode.Text;
                //FlyingType type = (FlyingType) cbbxType.SelectedItem;
                string type       = cbbxType.Text;
                int    passengers = (int)slPassengers.Value;
                try
                {
                    f.OnDay      = onDay;
                    f.FromCode   = fromCode;
                    f.ToCode     = toCode;
                    f.Type       = type;
                    f.Passengers = passengers;
                    if (btnSave.Content.Equals("Add new"))
                    {
                        Global.ctx.Flights.Add(f);
                    }

                    Global.ctx.SaveChanges();
                }
                catch (System.IO.InvalidDataException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                DialogResult = true;
            }
        }