Beispiel #1
0
        private void delete_button_Click(object sender, EventArgs e)
        {
            using (CarSalonContext db = new CarSalonContext())
            {
                List <Car> l   = new List <Car>();
                Contract   con = new Contract();
                Car        cc  = new Car();
                cc.update(l);

                foreach (DataGridViewRow drv in AllCarsTable.SelectedRows)
                {
                    int index = drv.Index;
                    int val   = l[index].IdCar;
                    con = db.Contract
                          .Where(j => j.Car == val)
                          .FirstOrDefault();

                    db.Contract.Remove(con);

                    cc = db.Car
                         .Where(j => j.IdCar == val)
                         .FirstOrDefault();

                    db.Car.Remove(cc);
                    db.SaveChanges();
                    cc.update(l);
                    AllCarsTable.DataSource = l;
                    break;
                }
            }
        }
Beispiel #2
0
        private void chdnge_button_Click(object sender, EventArgs e)
        {
            using (CarSalonContext db = new CarSalonContext())
            {
                List <Car> li = new List <Car>();
                Car        ca = new Car();
                ca.update(li);

                int index = AllCarsTable.CurrentCell.RowIndex;

                li[index].Mark = Mark_t.Text;

                List <Car> l = new List <Car>();
                ca.update(l);
                int val = li[index].IdCar;

                ca = db.Car
                     .Where(j => j.IdCar == val)
                     .FirstOrDefault();

                ca.Mark = li[index].Mark;

                db.SaveChanges();
                ca.update(li);
            }
        }
Beispiel #3
0
 public void addCar(string mark_t, DateTime year_t, int mileage_t, int price_t, string size_t, string desc_t)
 {
     using (CarSalonContext db = new CarSalonContext())
     {
         Car car = new Car();
         car.Mark        = mark_t;
         car.IssueYear   = Convert.ToDateTime(year_t);
         car.Mileage     = mileage_t;
         car.Price       = Convert.ToDecimal(price_t);
         car.Size        = size_t;
         car.Description = desc_t;
         db.Car.Add(car);
         db.SaveChanges();
     }
 }
Beispiel #4
0
        public void update(List <CarPersCuntr> li)
        {
            using (CarSalonContext db = new CarSalonContext())
            {
                li.Clear();

                foreach (CarPersCuntr car in db.CarPersCuntr)
                {
                    CarPersCuntr ca = new CarPersCuntr();
                    ca.Name    = car.Name;
                    ca.Price   = car.Price;
                    ca.Lname   = car.Lname;
                    ca.Fname   = car.Fname;
                    ca.Pname   = car.Pname;
                    ca.ConDate = car.ConDate;
                    li.Add(ca);
                }
            }
        }
Beispiel #5
0
        public void update(List <Car> li)
        {
            using (CarSalonContext db = new CarSalonContext())
            {
                li.Clear();

                foreach (Car car in db.Car)
                {
                    Car ca = new Car();
                    ca.IdCar       = car.IdCar;
                    ca.Mark        = car.Mark;
                    ca.IssueYear   = car.IssueYear;
                    ca.Mileage     = car.Mileage;
                    ca.Price       = car.Price;
                    ca.Size        = car.Size;
                    ca.Description = car.Description;
                    li.Add(ca);
                }
            }
        }