예제 #1
0
        public static AirCompany RestoreDates(AirCompany company)
        {
            //JsonSerializer serializer = new JsonSerializer();
            //using (StreamReader In = new StreamReader(Constants.path))
            //using(JsonReader jsr = new JsonTextReader(In))
            StreamReader In;

            try
            {
                In = new StreamReader(Constants.path);
                for (string s = In.ReadLine(); s != null; s = In.ReadLine())
                {
                    flight f = JsonConvert.DeserializeObject <flight>(s);
                    if (f.typeOfPlane.Equals(Constants.typeOfPlaneIsCargo))
                    {
                        company.AddCargoFlight(Convert.ToInt32(f.flightNumber), Convert.ToDouble(f.curbWeight) - Constants.emptyWeightOfCargoPlane, f.names);
                    }
                    if (f.typeOfPlane.Equals(Constants.typeOfPlaneIsPassenger))
                    {
                        company.AddPassengerFlight(Convert.ToInt32(f.flightNumber), (int)((Convert.ToDouble(f.curbWeight) - Constants.emptyWeightOfPassengerPlane) / Constants.averagePassengerWeight), f.names);
                    }
                }
                In.Close();
            }
            catch
            {
                return(company);
            }
            return(company);
        }
예제 #2
0
        private void Bt_add_Click(object sender, RoutedEventArgs e)
        {
            WindowAdd wndAdd = new WindowAdd(company);

            wndAdd.ShowDialog();
            company = wndAdd.GetCompany();
            ShowTable();
        }
예제 #3
0
 public MainWindow()
 {
     InitializeComponent();
     company = new AirCompany();
     GetDates();
     ShowTable();
     Closing += Window_Closed;
 }
예제 #4
0
 public WindowAdd(AirCompany company)
 {
     InitializeComponent();
     Bt_next.IsEnabled   = false;
     Txt_type.Visibility = Visibility.Visible;
     TypeList.Visibility = Visibility.Visible;
     this.company        = company;
 }
예제 #5
0
        private void Bt_Clear_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult res = MessageBox.Show(Constants.msgClearingList, Constants.headerClearingList, MessageBoxButton.YesNo);

            if (res == MessageBoxResult.No)
            {
                return;
            }
            company = new AirCompany();
            ShowTable();
            AirCompany.WriteFile(company);
        }
예제 #6
0
        public static void WriteFile(AirCompany company)
        {
            StreamWriter Out;

            try
            {
                Out = new StreamWriter(Constants.path);
                Out.Write("");
                for (int i = 0; i < company.GetCountOfFlights(); i++)
                {
                    flight f = company.GetFlight(i);
                    Out.WriteLine(JsonConvert.SerializeObject(f));
                }
                Out.Close();
            }
            catch
            {
                return;
            }
        }
예제 #7
0
 private void Window_Closed(object sender, EventArgs e)
 {
     AirCompany.WriteFile(company);
 }
예제 #8
0
 private void GetDates()
 {
     company = AirCompany.RestoreDates(company);
 }