Пример #1
0
 private void ChangeLocationButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var dialog = new MyDialog();
         if (dialog.ShowDialog() == true)
         {
             var currentSituation = new Situation().Get();
             currentSituation.CurrentLocation = dialog.ResponseText;
             currentSituation.Update();
             boardJobViewSource.Source = GenerateBoardJobs(currentSituation.CurrentLocation);
             var currentBase = AirportDatabaseFile.FindAirportInfo(currentSituation.CurrentLocation);
             CurrentLocationLabel.Content = "You are in: " + currentBase.AirportName + " (" + currentBase.ICAO + ") - " + currentBase.Country;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Пример #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                boardJobViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("boardJobViewSource")));
                // Load data by setting the CollectionViewSource.Source property:
                // boardJobViewSource.Source = [generic data source]

                var currentSituation = new Situation().Get();
                Base currentBase = AirportDatabaseFile.FindAirportInfo(currentSituation.CurrentLocation);

                MoneyLabel.Content = "Your companny cash is: " + currentSituation.CompanyCash.ToString("C", CultureInfo.GetCultureInfo("en-US"));
                CurrentLocationLabel.Content = "You are in: " + currentBase.AirportName + " (" + currentBase.ICAO + ") - " + currentBase.Country;

            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #3
0
        private void RunJoButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var job = (BoardJob)boardJobDataGrid.SelectedItem;

                if (new JobRuning(job).ShowDialog() == true)
                {
                    var currentSituation = new Situation().Get();
                    currentSituation.CurrentLocation = job.Arrival;
                    currentSituation.CompanyCash += job.Profit;
                    currentSituation.Update();
                    boardJobViewSource.Source = GenerateBoardJobs(currentSituation.CurrentLocation);

                    var currentBase = AirportDatabaseFile.FindAirportInfo(currentSituation.CurrentLocation);
                    MoneyLabel.Content = "Your companny cash is: " + currentSituation.CompanyCash.ToString("C", CultureInfo.GetCultureInfo("en-US"));
                    CurrentLocationLabel.Content = "You are in: " + currentBase.AirportName + " (" + currentBase.ICAO + ") - " + currentBase.Country;

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #4
0
 private void ReGenJobsButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var currentSituation = new Situation().Get();
         if (currentSituation == null || string.IsNullOrEmpty(currentSituation.CurrentLocation))
         {
             var dialog = new MyDialog();
             if (dialog.ShowDialog() == true)
             {
                 var newSituation = new Situation() { CurrentLocation = dialog.ResponseText };
                 newSituation.Insert();
                 Base currentBase = AirportDatabaseFile.FindAirportInfo(newSituation.CurrentLocation);
                 CurrentLocationLabel.Content = "You are in: " + currentBase.AirportName + " (" + currentBase.ICAO + ") - " + currentBase.Country;
             }
         }
         else
         {
             boardJobViewSource.Source = GenerateBoardJobs(currentSituation.CurrentLocation);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Пример #5
0
 internal void UpdateSituation(Situation situation)
 {
     try
     {
         using (var conn = new SQLiteConnection(connString))
         {
             conn.Open();
             var cmdSql = new SQLiteCommand("Update Situation SET CurrentLocationICAO = @currentLocationICAO, CompanyCash = @companyCash WHERE id = @id", conn);
             cmdSql.Parameters.AddWithValue("@currentLocationICAO", situation.CurrentLocation);
             cmdSql.Parameters.AddWithValue("@companyCash", situation.CompanyCash);
             cmdSql.Parameters.AddWithValue("@id", situation.Id);
             int result = cmdSql.ExecuteNonQuery();
             conn.Close();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         throw ex;
     }
 }
Пример #6
0
        internal Situation SelectSituation()
        {
            try
            {
                using (var conn = new SQLiteConnection(connString))
                {

                    var cmdSql = new SQLiteCommand("SELECT * FROM [Situation]", conn);
                    conn.Open();
                    var reader = cmdSql.ExecuteReader();

                    var situation = new Situation();
                    while (reader.Read())
                    {
                        situation.Id = Convert.ToInt64(reader["id"].ToString());
                        situation.CurrentLocation = reader["CurrentLocationICAO"].ToString().Trim();
                        situation.CompanyCash = Convert.ToDecimal(reader["CompanyCash"].ToString().Trim());
                        break;
                    }
                    reader.Dispose();
                    conn.Close();
                    return situation;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw ex;
            }
        }
Пример #7
0
        internal void InsertSituation(Situation situation)
        {
            try
            {
                using (var conn = new SQLiteConnection(connString))
                {

                    var cmdSql = new SQLiteCommand("INSERT INTO [Situation] (CurrentLocationICAO, CompanyCash)  VALUES (@currentLocationICAO, @companyCash)", conn);
                    conn.Open();
                    cmdSql.Parameters.AddWithValue("@currentLocationICAO", situation.CurrentLocation);
                    cmdSql.Parameters.AddWithValue("@companyCash", situation.CompanyCash);
                    cmdSql.ExecuteNonQuery();
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw ex;
            }
        }