Ejemplo n.º 1
0
        public IHttpActionResult PutUsuario(int id, Usuario usuario)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != usuario.UserId)
            {
                return(BadRequest());
            }

            db.Entry(usuario).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UsuarioExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutVehicleType(int id, VehicleType vehicleType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != vehicleType.VehicleTypeId)
            {
                return(BadRequest());
            }

            db.Entry(vehicleType).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VehicleTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        public IHttpActionResult PutBrand(int id, Brand brand)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != brand.BrandId)
            {
                return(BadRequest());
            }

            db.Entry(brand).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BrandExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 4
0
        private void FormInspeccion_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                //validacion de campos vacios
                foreach (Control item in this.Controls)
                {
                    if (item.GetType() == typeof(TextBox))
                    {
                        if (string.IsNullOrEmpty(item.Text))
                        {
                            MessageBox.Show("Favor llene todos los campos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            item.Focus();
                            e.Cancel = true;
                            return;
                        }
                    }
                }

                //completar edicion
                var c = inspeccionBindingSource.Current as Inspeccion;
                c.Empleado        = (int?)cbEmpleado.SelectedValue;
                c.Vehiculo        = (int?)cbVehiculo.SelectedValue;
                c.CantCombustible = (string)cbCombustible.SelectedText;
                c.Fecha           = DateTime.Now;

                db.Inspeccions.Add(c);
                db.SaveChanges();

                e.Cancel = false;
            }
            e.Cancel = false;
        }
Ejemplo n.º 5
0
        private void FormVehiculoTipoAddEdit_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                //validacion de campos vacios
                if (string.IsNullOrEmpty(txtDescripcion.Text))
                {
                    MessageBox.Show("Favor llene todos los campos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtDescripcion.Focus();
                    e.Cancel = true;
                    return;
                }

                //completar edicion
                if (edit)
                {
                    var t  = tipoVehiculoBindingSource.Current as Tipo_Vehiculo;
                    var tt = db.Tipo_Vehiculo.Where(q => q.ID.Equals(t.ID)).FirstOrDefault();
                    tt.Descripcion = t.Descripcion;
                }
                db.SaveChanges();
                e.Cancel = false;
            }
            e.Cancel = false;
        }
Ejemplo n.º 6
0
 private void FormRentaAddEdit_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (DialogResult == DialogResult.OK)
     {
         //validacion de campos vacios
         foreach (Control item in this.Controls)
         {
             if (item.GetType() == typeof(TextBox))
             {
                 if (string.IsNullOrEmpty(item.Text))
                 {
                     MessageBox.Show("Favor llene todos los campos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     item.Focus();
                     e.Cancel = true;
                     return;
                 }
             }
         }
         //validacion campos numericos
         if (Convert.ToInt32(txtDias.Text) < 0)
         {
             MessageBox.Show("Favor revise los dias.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtDias.Focus();
             e.Cancel = true;
             return;
         }
         if (Convert.ToInt32(txtMonto.Text) < 0)
         {
             MessageBox.Show("Favor revise el Monto.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtMonto.Focus();
             e.Cancel = true;
             return;
         }
         //completar edicion
         var c = rentaBindingSource.Current as Renta;
         c.Cliente    = (int?)cbCliente.SelectedValue;
         c.Empleado   = (int?)cbEmpleado.SelectedValue;
         c.Vehiculo   = vehiculo;
         c.FechaRenta = DateTime.Now;
         if (edit)
         {
             var cc = db.Rentas.Where(q => q.ID.Equals(c.ID)).FirstOrDefault();
             cc.Cliente     = c.Cliente;
             cc.Empleado    = c.Empleado;
             cc.Vehiculo    = c.Vehiculo;
             cc.Comentario  = c.Comentario;
             cc.FechaRenta  = c.FechaRenta;
             cc.MontoDiario = c.MontoDiario;
             cc.CantDias    = c.CantDias;
         }
         if (!edit)
         {
             db.Rentas.Add(c);
         }
         db.SaveChanges();
         e.Cancel = false;
     }
     e.Cancel = false;
 }
Ejemplo n.º 7
0
        private void FormClienteAddEdit_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                //validacion de campos vacios
                foreach (Control item in this.Controls)
                {
                    if (item.GetType() == typeof(TextBox))
                    {
                        if (string.IsNullOrEmpty(item.Text))
                        {
                            MessageBox.Show("Favor llene todos los campos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            item.Focus();
                            e.Cancel = true;
                            return;
                        }
                    }
                }

                //validacion campo numerico
                if (Convert.ToInt32(txtLimite.Text) < 0)
                {
                    MessageBox.Show("Favor revise el limite.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtLimite.Focus();
                    e.Cancel = true;
                    return;
                }

                // validacion de cedula
                bool valida = Utilidades.validaCedula(txtCedula.Text);
                if (!valida)
                {
                    MessageBox.Show("Favor revise la cedula.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtCedula.Focus();
                    e.Cancel = true;
                    return;
                }

                //completar edicion
                if (edit)
                {
                    var c  = clienteBindingSource.Current as Cliente;
                    var cc = db.Clientes.Where(q => q.ID.Equals(c.ID)).FirstOrDefault();
                    cc.Cedula        = c.Cedula;
                    cc.LimiteCredito = c.LimiteCredito;
                    cc.Nombre        = c.Nombre;
                    cc.TarjetaCR     = c.TarjetaCR;
                    cc.TipoPersona   = c.TipoPersona;
                }

                db.SaveChanges();
                e.Cancel = false;
            }
            e.Cancel = false;
        }
Ejemplo n.º 8
0
        private void FormEmpleadoAddEdit_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                //validacion de campos vacios
                foreach (Control item in this.Controls)
                {
                    if (item.GetType() == typeof(TextBox))
                    {
                        if (string.IsNullOrEmpty(item.Text))
                        {
                            MessageBox.Show("Favor llene todos los campos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            item.Focus();
                            e.Cancel = true;
                            return;
                        }
                    }
                }

                //validacion campo numerico
                if (Convert.ToInt32(txtPorciento.Text) < 0)
                {
                    MessageBox.Show("Favor revise el limite.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtPorciento.Focus();
                    e.Cancel = true;
                    return;
                }

                // validacion de cedula
                bool valida = Utilidades.validaCedula(txtCedula.Text);
                if (!valida)
                {
                    MessageBox.Show("Favor revise la cedula.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtCedula.Focus();
                    e.Cancel = true;
                    return;
                }

                //completar edicion
                if (edit)
                {
                    var em = empleadoBindingSource.Current as Empleado;
                    var ee = db.Empleadoes.Where(q => q.ID.Equals(em.ID)).FirstOrDefault();
                    ee.FechaIngreso      = em.FechaIngreso;
                    ee.Nombre            = em.Nombre;
                    ee.PorcientoComision = em.PorcientoComision;
                    ee.Tanda             = em.Tanda;
                }

                db.SaveChanges();
                e.Cancel = false;
            }
            e.Cancel = false;
        }
Ejemplo n.º 9
0
 private void btnDesactivar_Click(object sender, EventArgs e)
 {
     if (tipoVehiculoBindingSource != null)
     {
         var confirm = MessageBox.Show("Seguro que desea desactivar el tipo de vehiculo?", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (confirm == DialogResult.Yes)
         {
             var tp = tipoVehiculoBindingSource.Current as Tipo_Vehiculo;
             tp.Estado = false;
             db.SaveChanges();
             tipoVehiculoBindingSource.DataSource = db.Tipo_Vehiculo.ToList();
         }
     }
 }
Ejemplo n.º 10
0
 private void btnDesactivar_Click(object sender, EventArgs e)
 {
     if (empleadoBindingSource.Current != null)
     {
         var confirm = MessageBox.Show("Seguro que desea desactivar el empleado?", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (confirm == DialogResult.Yes)
         {
             var emp = empleadoBindingSource.Current as Empleado;
             emp.Estado = false;
             db.SaveChanges();
             empleadoBindingSource.DataSource = db.Empleadoes.ToList();
         }
     }
 }
Ejemplo n.º 11
0
 private void btnDesactivar_Click(object sender, EventArgs e)
 {
     if (marcaVehiculoBindingSource.Current != null)
     {
         var confirm = MessageBox.Show("Seguro que desea desactivar el cliente?", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (confirm == DialogResult.Yes)
         {
             var obj = marcaVehiculoBindingSource.Current as Marca_Vehiculo;
             obj.Estado = false;
             db.SaveChanges();
             marcaVehiculoBindingSource.DataSource = db.Marca_Vehiculo.ToList();
         }
     }
 }
Ejemplo n.º 12
0
        private void FormVehiculoAddEdit_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                //validacion de campos vacios
                foreach (Control item in this.Controls)
                {
                    if (item.GetType() == typeof(TextBox))
                    {
                        if (string.IsNullOrEmpty(item.Text))
                        {
                            MessageBox.Show("Favor llene todos los campos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            item.Focus();
                            e.Cancel = true;
                            return;
                        }
                    }
                }

                //completar edicion
                var c = vehiculoBindingSource.Current as Vehiculo;
                c.Tipo_Combustible_Vehiculo = (int?)cbCombustible.SelectedValue;
                c.Tipo_Vehiculo             = (int?)cbTipo.SelectedValue;
                c.Marca_Vehiculo            = (int?)cbMarca.SelectedValue;
                c.Modelo_Vehiculo           = (int?)cbModelo.SelectedValue;
                if (edit)
                {
                    var cc = db.Vehiculoes.Where(q => q.ID.Equals(c.ID)).FirstOrDefault();
                    cc.Descripcion = c.Descripcion;
                    cc.ChasisNum   = c.ChasisNum;
                    cc.MotorNum    = c.MotorNum;
                    cc.PlacaNum    = c.PlacaNum;
                    cc.Tipo_Combustible_Vehiculo = c.Tipo_Combustible_Vehiculo;
                    cc.Tipo_Vehiculo             = c.Tipo_Vehiculo;
                    cc.Marca_Vehiculo            = c.Marca_Vehiculo;
                    cc.Modelo_Vehiculo           = c.Modelo_Vehiculo;
                }
                if (!edit)
                {
                    db.Vehiculoes.Add(c);
                }
                db.SaveChanges();
                e.Cancel = false;
            }
            e.Cancel = false;
        }
Ejemplo n.º 13
0
        private void btnDesactivar_Click(object sender, EventArgs e)
        {
            int o   = (int)dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[0].Value;
            var obj = db.Modelo_Vehiculo.Select(q => q).Where(q => q.ID == o).FirstOrDefault();

            if (obj == null)
            {
                return;
            }

            var confirm = MessageBox.Show("Seguro que desea desactivar el modelo?", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (confirm == DialogResult.Yes)
            {
                obj.Estado = false;
                db.SaveChanges();
                FormVehiculoModelo_Load(sender, e);
            }
        }
Ejemplo n.º 14
0
        private void btnDevolver_Click(object sender, EventArgs e)
        {
            int o   = (int)dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[0].Value;
            var obj = db.Rentas.Select(q => q).Where(q => q.ID == o).FirstOrDefault();

            if (obj == null)
            {
                return;
            }

            var confirm = MessageBox.Show("El vehiculo ha sido devuelto?", "Confirmar", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (confirm == DialogResult.Yes)
            {
                obj.Estado          = false;
                obj.FechaDevolucion = DateTime.Now;
                var vehiculo = db.Vehiculoes.Select(q => q).Where(q => q.ID == obj.Vehiculo).FirstOrDefault();
                vehiculo.Estado = "Activo";
                db.SaveChanges();
                FormRenta_Load(sender, e);
            }
        }