Esempio n. 1
0
 private void LoadData()
 {
     using (var db = new AutoContext())
     {
         db.Orders.Load();
         dgwOrders.DataSource = db.Orders.Local.ToBindingList();
     }
 }
Esempio n. 2
0
 private void edCost_ValueChanged(object sender, EventArgs e)
 {
     using (var db = new AutoContext())
     {
         _parking.Cost = edCost.Value;
         db.Parkings.Attach(_parking);
         db.Entry(_parking).State = EntityState.Modified;
         DbHelper.Save(db);
     }
 }
Esempio n. 3
0
 private void DrawParking(Graphics g, Size size)
 {
     using (var db = new AutoContext())
     {
         var parking = db.Parkings.FirstOrDefault(p => p.Id == 1);
         var placeWidth = 60;
         var placeHeight = 90;
         foreach (var p in db.ParkingPlaces.Where(p => p.ParkingId == parking.Id))
         {
             const int offset = 3;
             Rectangle rectangle = GetRectangle(p, placeHeight, placeWidth);
             g.DrawRectangle(GetPen(p, offset * 2), rectangle);
             g.FillRectangle(GetBrush(p),
                 new Rectangle(new Point(rectangle.X + offset, rectangle.Y + offset),
                     new Size(rectangle.Width - offset * 2, rectangle.Height - offset * 2)));
             p.ParkingPlaceStatus = ParkingPlaceStatus.Reservated;
             if (p.ParkingPlaceStatus != ParkingPlaceStatus.Free)
             {
                 g.DrawImage(GetImage(p),
                     new Point(rectangle.Left + offset*2, rectangle.Top + offset*2));
             }
         }
     }
 }
Esempio n. 4
0
 private void LoadParkingInfo()
 {
     using (var db = new AutoContext())
     {
         _parking = db.Parkings.FirstOrDefault(p => p.Id == 1);
         edCost.Value = _parking.Cost;
         edInflation.Value = db.Inflations.FirstOrDefault(p => p.Year == DateTime.Now.Year).Value;
     }
 }