Example #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (IsValid())
     {
         Inspection inspection = rentACarEntities.Inspections.Where(i => i.Id == Inspection.Id).FirstOrDefault();
         inspection.CarId          = (int)cbCar.SelectedValue;
         inspection.Cat            = cbCat.Checked;
         inspection.CustomerId     = (int)cbCustomer.SelectedValue;
         inspection.EmployeeId     = (int)cbEmployee.SelectedValue;
         inspection.FuelQuantityId = (int)cbFuelQuantity.SelectedValue;
         inspection.GlassBreak     = cbGlassBreak.Checked;
         inspection.ResponseRubber = cbResponseRubber.Checked;
         inspection.RubberStatus1  = (int)cbRubberStatus1.SelectedValue;
         inspection.RubberStatus2  = (int)cbRubberStatus2.SelectedValue;
         inspection.RubberStatus3  = (int)cbRubberStatus3.SelectedValue;
         inspection.RubberStatus4  = (int)cbRubberStatus4.SelectedValue;
         inspection.Scratches      = cbScratches.Checked;
         rentACarEntities.Entry(inspection).State = System.Data.Entity.EntityState.Modified;
         rentACarEntities.SaveChanges();
         MessageBox.Show("La inspección fue editada correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
         frmInspection frmInspection = new frmInspection();
         frmInspection.Show();
         Hide();
     }
 }
Example #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (IsValid())
            {
                rentACarEntities.Rents.Add(new Rent()
                {
                    AmountPerDay = txtAmountPerDay.Value,
                    CarId        = (int)cbCar.SelectedValue,
                    Comments     = txtComments.Text,
                    CustomerId   = (int)cbCustomer.SelectedValue,
                    EmployeeId   = (int)cbEmployee.SelectedValue,
                    Days         = (int)txtDays.Value,
                    RentalDate   = DateTime.Now,
                    RentStatusId = rentACarEntities.RentStatus.Where(rs => rs.Description == "Rentado").FirstOrDefault().Id,
                    ReturnDate   = dtpReturnDate.Value,
                    Status       = true
                });

                Car car = rentACarEntities.Cars.Where(m => m.Id == (int)cbCar.SelectedValue).FirstOrDefault();
                rentACarEntities.Entry(car).State = EntityState.Modified;
                car.Status = false;

                rentACarEntities.SaveChanges();

                MessageBox.Show("La renta fue creada correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                frmRents frm = new frmRents();
                frm.Show();
                Close();
            }
        }
Example #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();
     }
 }
Example #4
0
        private void bnDelete_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("¿Seguro de eliminar esta renta?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Yes)
            {
                int currentRow = dgvRents.SelectedRows[0].Index;
                int id         = (int)dgvRents.Rows[currentRow].Cells[0].Value;

                Rent rent = rentACarEntities.Rents.Where(r => r.Id == id).FirstOrDefault();
                rentACarEntities.Entry(rent).State = EntityState.Modified;
                rent.Status = false;
                rentACarEntities.SaveChanges();
                MessageBox.Show("La renta fue eliminada correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                BindGridView();
            }
        }
Example #5
0
 private void btnSave_Click(object sender, System.EventArgs e)
 {
     if (IsValid())
     {
         Make make = rentACarEntities.Makes.Where(m => m.Id == Make.Id).FirstOrDefault();
         make.Description = txtDescription.Text;
         rentACarEntities.Entry(make).State = System.Data.Entity.EntityState.Modified;
         rentACarEntities.SaveChanges();
         MessageBox.Show("La marca fue editada correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
         frmMakes frmMakes = new frmMakes();
         frmMakes.Show();
         Hide();
     }
 }
Example #6
0
 private void btnSave_Click(object sender, System.EventArgs e)
 {
     if (IsValid())
     {
         CarType carType = rentACarEntities.CarTypes.Where(ct => ct.Id == CarType.Id).FirstOrDefault();
         carType.Description = txtDescription.Text;
         rentACarEntities.Entry(carType).State = System.Data.Entity.EntityState.Modified;
         rentACarEntities.SaveChanges();
         MessageBox.Show("El tipo de vehiculo fue editado correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
         frmCarTypes frmCarTypes = new frmCarTypes();
         frmCarTypes.Show();
         Hide();
     }
 }
Example #7
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (IsValid())
     {
         FuelType fuelType = rentACarEntities.FuelTypes.Where(ft => ft.Id == FuelType.Id).FirstOrDefault();
         fuelType.Description = txtDescription.Text;
         rentACarEntities.Entry(fuelType).State = System.Data.Entity.EntityState.Modified;
         rentACarEntities.SaveChanges();
         MessageBox.Show("El tipo de combustible fue editado correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
         frmFuelTypes frmFuelTypes = new frmFuelTypes();
         frmFuelTypes.Show();
         Hide();
     }
 }
Example #8
0
 private void btnSave_Click(object sender, System.EventArgs e)
 {
     if (IsValid())
     {
         Model             = rentACarEntities.Models.Where(m => m.Id == Model.Id).FirstOrDefault();
         Model.Description = txtDescription.Text;
         Model.MakeId      = (int)cbMake.SelectedValue;
         rentACarEntities.Entry(Model).State = EntityState.Modified;
         rentACarEntities.SaveChanges();
         MessageBox.Show("El modelo fue editado correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
         frmModels frmModels = new frmModels();
         frmModels.Show();
         Hide();
     }
 }
Example #9
0
        private void bnDelete_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("¿Seguro de eliminar este tipo de combustible?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Yes)
            {
                int currentRow = dgvFuelTypes.SelectedRows[0].Index;
                int id         = (int)dgvFuelTypes.Rows[currentRow].Cells[0].Value;

                FuelType fuelType = rentACarEntities.FuelTypes.Where(ct => ct.Id == id).FirstOrDefault();
                rentACarEntities.Entry(fuelType).State = System.Data.Entity.EntityState.Modified;
                fuelType.Status = false;
                rentACarEntities.SaveChanges();
                MessageBox.Show("El tipo de combustible fue eliminado correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                BindGridView();
            }
        }
Example #10
0
 private void btnSave_Click(object sender, System.EventArgs e)
 {
     if (IsValid())
     {
         Customer customer = rentACarEntities.Customers.Where(c => c.Id == Customer.Id).FirstOrDefault();
         customer.Name            = txtName.Text;
         customer.DocumentNumber  = txtDocumentNumber.Text;
         customer.CreditCarNumber = txtCreditCarNumber.Text;
         customer.CreditLimit     = txtCreditLimit.Value;
         customer.PersonTypeId    = (int)cbPersonType.SelectedValue;
         rentACarEntities.Entry(customer).State = System.Data.Entity.EntityState.Modified;
         rentACarEntities.SaveChanges();
         MessageBox.Show("El cliente fue editado correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
         frmCustomers frmCustomers = new frmCustomers();
         frmCustomers.Show();
         Hide();
     }
 }
Example #11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (IsValid())
            {
                Employee employee = rentACarEntities.Employees.Where(em => em.Id == Employee.Id).FirstOrDefault();
                employee.Name            = txtName.Text;
                employee.DocumentNumber  = txtDocumentNumber.Text;
                employee.BatchId         = (int)cbBatch.SelectedValue;
                employee.Comission       = txtComision.Value;
                employee.DateOfAdmission = dtpDateOfAdmission.Value;

                rentACarEntities.Entry(employee).State = System.Data.Entity.EntityState.Modified;
                rentACarEntities.SaveChanges();
                MessageBox.Show("El empleado fue editado correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                frmEmployees frmEmployees = new frmEmployees();
                frmEmployees.Show();
                Hide();
            }
        }
Example #12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (IsValid())
            {
                Rent rent = rentACarEntities.Rents.Where(r => r.Id == Rent.Id).FirstOrDefault();
                rent.AmountPerDay = txtAmountPerDay.Value;
                rent.CarId        = (int)cbCar.SelectedValue;
                rent.Comments     = txtComments.Text;
                rent.CustomerId   = (int)cbCustomer.SelectedValue;
                rent.Days         = (int)txtDays.Value;
                rent.EmployeeId   = (int)cbEmployee.SelectedValue;

                rentACarEntities.Entry(rent).State = System.Data.Entity.EntityState.Modified;
                rentACarEntities.SaveChanges();
                MessageBox.Show("La renta fue editada correctamente.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                frmRents frmRents = new frmRents();
                frmRents.Show();
                Hide();
            }
        }