Ejemplo n.º 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult dialog = new DialogResult();

            dialog = MessageBox.Show("Silmek istiyor musunuz?", "Silme Onayı", MessageBoxButtons.YesNo);
            if (dialog == DialogResult.Yes)
            {
                using (CarParkDbContext db = new CarParkDbContext())
                {
                    int id = int.Parse(dataGridCustomerList.CurrentRow.Cells[0].Value.ToString());

                    var customer = db.Customers
                                   .Include(x => x.CarParkingSpaces)
                                   .FirstOrDefault(x => x.Id == id);

                    if (customer != null)
                    {
                        customer.Deleted = true;
                        customer.CarParkingSpaces.Status = false;

                        db.SaveChanges();
                        MessageBox.Show("Kayıt silindi", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Clean();
                        GridFill();
                    }
                    else
                    {
                        MessageBox.Show("Müşteri bulunamadı", "Hata!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void GridFill()
 {
     using (CarParkDbContext db = new CarParkDbContext())
     {
         dataGridCustomerList.DataSource = db.Customers
                                           .Include(x => x.Brand)
                                           .Include(x => x.Serie)
                                           .Include(x => x.CarParkingSpaces)
                                           .Where(x => !x.Deleted)
                                           .Select(x => new
         {
             x.Id,
             x.NameSurname,
             x.Plaque,
             SerieName     = x.Serie.SerieName,
             BrandName     = x.Brand.BrandName,
             ParkingSpaces = x.CarParkingSpaces.ParkingSpaces,
             x.Color,
             x.Comment,
             x.EntryDate,
             x.Telephone,
             x.Year
         }).ToList();
     }
 }
        private static void SetDbContext()
        {
            var options = new DbContextOptionsBuilder <CarParkDbContext>()
                          .UseInMemoryDatabase("CarParkDb")
                          .Options;

            _carParkDbContext = new CarParkDbContext(options);
        }
Ejemplo n.º 4
0
 private void txtSearch_TextChanged(object sender, EventArgs e)
 {
     using (CarParkDbContext db = new CarParkDbContext())
     {
         if (!string.IsNullOrEmpty(txtSearch.Text))
         {
             dataGridCustomerList.DataSource = db.Customers.Where(x => x.Plaque.Contains(txtSearch.Text)).ToList();
         }
         else
         {
             GridFill();
         }
     }
 }
Ejemplo n.º 5
0
 public CarParkingSpaceService(CarParkDbContext context)
 {
     this.context = context;
 }
Ejemplo n.º 6
0
 public SerieService(CarParkDbContext context)
 {
     this.context = context;
 }
Ejemplo n.º 7
0
 public BrandService(CarParkDbContext context)
 {
     this.context = context;
 }
Ejemplo n.º 8
0
 public CustomerService(CarParkDbContext context)
 {
     this.context = context;
 }
Ejemplo n.º 9
0
 public UserController(IOptions <SettingsModel> app, CarParkDbContext context)
 {
     appSettings         = app;
     _context            = context;
     _applicationservice = applicationservice;
 }
Ejemplo n.º 10
0
 public UserService(CarParkDbContext context)
 {
     this.context = context;
 }
Ejemplo n.º 11
0
 public TariffService(CarParkDbContext context)
 {
     this.context = context;
 }