Ejemplo n.º 1
0
 /// <summary>
 /// The method of adding  info about Client and Car to Parking
 /// </summary>
 private void AddToBalanceParking()
 {
     using (ParkingContext db = new ParkingContext())
     {
         var            tempCar    = db.Cars.Where(c => c.NumberCar == txbInfoNumber.Text).FirstOrDefault();
         int            tempNum    = Int32.Parse(txbInfoPhone.Text);
         var            tempClient = db.Clients.Where(c => c.Phone == tempNum).FirstOrDefault();
         BalanceParking temPlace   = new BalanceParking {
             ClientId = tempClient.Id, CarId = tempCar.Id, DataAdded = DateTime.Parse(txbInfoDate.Text), Place = (int)SenderPlace
         };
         var isExistPlace = db.BalanceParking.Where(pl => pl.CarId == temPlace.CarId).FirstOrDefault();
         if (isExistPlace == null)
         {
             db.BalanceParking.Add(temPlace);
             db.HistoryAddedCars.Add(new HistoryAddedCars {
                 ClientId = tempClient.Id, CarId = tempCar.Id, DataAdded = DateTime.Parse(txbInfoDate.Text), Place = (int)SenderPlace
             });
             db.SaveChanges();
             StatisticsOfPlaces.UpdateStatisticsPlaces(temPlace.Place, '+');
             StatisticsOfPlaces.ShowStatisticsInMainWind();
             SetColor.SetColorForPlaces((List <Button>)(this.Owner as MainWindow).ListButtons);
             this.Close();
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Set for any sectors color scheme
 /// </summary>
 /// <param name="obj"></param>
 private void SetColorSchemeSectors(dynamic obj)
 {
     ClickOnPlace.DefaultSettingsForButtons(this);
     if ((obj).Visibility == Visibility.Hidden)
     {
         // установка цветовой схемы для мест на стоянки
         SetColor.SetColorForPlaces(ListButtons);
         obj.Visibility = Visibility.Visible;
     }
     else
     {
         SetColor.SetColorForPlaces(ListButtons);
         obj.Show();
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Show place in sector with border
 /// </summary>
 /// <param name="result"></param>
 private void ShowSector(BalanceParking result)
 {
     if (Int32.Parse(result.Place.ToString()) > 0 & Int32.Parse(result.Place.ToString()) < 22)
     {
         SetColor.SetColorForPlaces(ListButtons);
         sector1.Show();
     }
     if (Int32.Parse(result.Place.ToString()) > 21 & Int32.Parse(result.Place.ToString()) < 46)
     {
         SetColor.SetColorForPlaces(ListButtons);
         sector2.Show();
     }
     if (Int32.Parse(result.Place.ToString()) > 45 & Int32.Parse(result.Place.ToString()) < 67)
     {
         sector3.Show();
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Take the car out off the parking place
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnMoveFromPlace_Click(object sender, RoutedEventArgs e)
 {
     if (CheckAllFieldsClickPlace())
     {
         using (ParkingContext db = new ParkingContext())
         {
             using (var tran = db.Database.BeginTransaction())
             {
                 try
                 {
                     BalanceParking bal = db.BalanceParking.Where(b => b.Place == SenderPlace).FirstOrDefault();
                     //BalanceParking bal = new BalanceParking { Place = (int)SenderPlace };
                     //db.BalanceParking.Attach(bal);
                     if (bal != null)
                     {
                         db.BalanceParking.Remove(bal);
                         db.HistoryDeletedCars.Add(new HistoryDeletedCars {
                             ClientId = bal.ClientId, CarId = bal.CarId, DataAdded = bal.DataAdded, Place = (int)SenderPlace
                         });
                         db.SaveChanges();
                         tran.Commit();
                         btnMoveFromPlace.IsEnabled = false;
                         btnSaveToPlace.IsEnabled   = false;
                         StatisticsOfPlaces.UpdateStatisticsPlaces(bal.Place, '-');
                         StatisticsOfPlaces.ShowStatisticsInMainWind();
                         SetColor.SetColorForPlaces((List <Button>)(this.Owner as MainWindow).ListButtons);
                         this.Close();
                     }
                 }
                 catch (Exception)
                 {
                     tran.Rollback();
                 }
             }
         }
     }
 }