Beispiel #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (IsValid())
            {
                rentACarEntities.Cars.Add(new Car()
                {
                    Description        = txtDescription.Text,
                    ChasisNumber       = txtChasisNumber.Text,
                    EngineNumber       = txtEngineNumber.Text,
                    LicensePlateNumber = txtLicensePlateNumber.Text,
                    CarTypeId          = (int)cbCarType.SelectedValue,
                    MakeId             = (int)cbMake.SelectedValue,
                    ModelId            = (int)cbModel.SelectedValue,
                    FuelTypeId         = (int)cbFuelType.SelectedValue,
                    Status             = true,
                    CarStatu           = rentACarEntities.CarStatus.Where(cs => cs.Description == "Disponible").FirstOrDefault(),
                    Created            = DateTime.Now
                });

                rentACarEntities.SaveChanges();

                MessageBox.Show("El vehículo fue agreagdo correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                frmCars frmCars = new frmCars();
                frmCars.Show();
                Close();
            }
        }
Beispiel #2
0
        private void vehículosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmCars frmCars = new frmCars();

            frmCars.Show();
            Hide();
        }
Beispiel #3
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (IsValid())
     {
         Car car = rentACarEntities.Cars.Where(c => c.Id == Car.Id).FirstOrDefault();
         //car.CarType = null;
         //car.FuelType = null;
         //car.Model = null;
         //car.Make = null;
         car.Description                   = txtDescription.Text;
         car.ChasisNumber                  = txtChasisNumber.Text;
         car.EngineNumber                  = txtEngineNumber.Text;
         car.LicensePlateNumber            = txtLicensePlateNumber.Text;
         car.CarTypeId                     = (int)cbCarType.SelectedValue;
         car.MakeId                        = (int)cbMake.SelectedValue;
         car.ModelId                       = (int)cbModel.SelectedValue;
         car.FuelTypeId                    = (int)cbFuelType.SelectedValue;
         rentACarEntities.Entry(car).State = System.Data.Entity.EntityState.Modified;
         rentACarEntities.SaveChanges();
         MessageBox.Show("El vehículo fue editado correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
         frmCars frmCars = new frmCars();
         frmCars.Show();
         Hide();
     }
 }