Example #1
0
 private void btnCrear_Click(object sender, EventArgs e)
 {
     model.NOMBRE = txtMarcaVehiculo.Text.Trim();
     model.ESTADO = cbEstado.Checked;
     if (string.IsNullOrWhiteSpace(txtMarcaVehiculo.Text))
     {
         MessageBox.Show("Llene los campos");
     }
     else
     {
         using (RentaCarEntities db = new RentaCarEntities())
         {
             if (model.ID == 0)
             {
                 db.MARCA_VEHICULO.Add(model);
                 MessageBox.Show("Marca de vehículo agregada.");
             }
             else
             {
                 db.Entry(model).State = EntityState.Modified;
                 MessageBox.Show("Marca de vehículo actualizada.");
             }
             db.SaveChanges();
         }
         LimpiarCampos();
         getMarcaVehiculos();
     }
 }
 private void btnCrear_Click(object sender, EventArgs e)
 {
     if (ValidarData())
     {
         model.NOMBRES            = txtNombres.Text;
         model.APELLIDOS          = txtApellidos.Text;
         model.EMAIL              = txtEmail.Text;
         model.CLAVE              = txtClave.Text;
         model.ID_TANDA           = Convert.ToInt32(cmbTanda.SelectedValue);
         model.PORCIENTO_COMISION = Convert.ToInt32(numericComision.Value);
         model.FECHA_INGRESO      = datePicker.Value;
         model.FECHA_CREACION     = Convert.ToDateTime(lblFechaHoy.Text);
         model.ID_TIPO_EMPLEADO   = Convert.ToInt32(cmbTipoEmpleado.SelectedValue);
         model.ESTADO             = cbEstado.Checked;
         using (RentaCarEntities db = new RentaCarEntities())
         {
             if (model.ID == 0)
             {
                 db.EMPLEADO.Add(model);
                 MessageBox.Show("Empleado agregado");
             }
             else
             {
                 db.Entry(model).State = EntityState.Modified;
                 MessageBox.Show("Empleado actualizado");
             }
             db.SaveChanges();
             getEmpleados();
             Limpiar();
         }
     }
 }
 private void btnCrear_Click(object sender, EventArgs e)
 {
     if (ValidarData())
     {
         model.DESCRIPCION         = txtDescripcion.Text.Trim();
         model.NUMERO_CHASIS       = txtNumeroChasis.Text.Trim();
         model.NUMERO_MOTOR        = txtNumeroMotor.Text.Trim();
         model.NUMERO_PLACA        = txtNumeroPlaca.Text.Trim();
         model.ID_TIPO_VEHICULO    = Convert.ToInt32(cmbTipoVehiculo.SelectedValue);
         model.ID_MODELO_VEHICULO  = Convert.ToInt32(cmbModeloVehiculo.SelectedValue);
         model.ID_TIPO_COMBUSTIBLE = Convert.ToInt32(cmbCombustible.SelectedValue);
         model.ESTADO         = Convert.ToBoolean(cbEstado.Checked);
         model.FECHA_CREACION = Convert.ToDateTime(lblFechaValor.Text);
         using (RentaCarEntities db = new RentaCarEntities())
         {
             if (model.ID == 0)
             {
                 db.VEHICULO.Add(model);
                 MessageBox.Show("Vehiculo agregado exitosamente");
             }
             else
             {
                 db.Entry(model).State = EntityState.Modified;
                 MessageBox.Show("Vehiculo modificado exitosamente");
             }
             db.SaveChanges();
         }
         getVehiculos();
         Limpiar();
     }
 }
        private void button2_Click(object sender, EventArgs e)
        {
            string Preg = (model.ESTADO == true) ? "Desea desactivar a este Empleado?" : "Desea activar a este Empleado?";

            if (MessageBox.Show(Preg, "Mensaje", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                model.ESTADO = !model.ESTADO;
                using (RentaCarEntities db = new RentaCarEntities())
                {
                    db.Entry(model).State = EntityState.Modified;
                    MessageBox.Show("Estado modificado");
                    db.SaveChanges();
                }
                Limpiar();
                getEmpleados();
            }
        }
Example #5
0
 private void btnBorrar_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("¿Desea borrar este tipo de vehículo?", "Mensaje", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         using (RentaCarEntities db = new RentaCarEntities())
         {
             var entry = db.Entry(model);
             if (entry.State == EntityState.Detached)
             {
                 db.MARCA_VEHICULO.Attach(model);
             }
             db.MARCA_VEHICULO.Remove(model);
             db.SaveChanges();
             getMarcaVehiculos();
             LimpiarCampos();
             MessageBox.Show("Tipo de vehículo eliminado");
         }
     }
 }