Пример #1
0
        public ActionResult SeleccionPago()
        {
            var currentUserId = User.Identity.GetUserId();

            // Unauthorized access
            if (string.IsNullOrEmpty(currentUserId))
            {
                return(new HttpUnauthorizedResult());
            }

            if (Session["fechas"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            BuscadorPrincipal buscador = (BuscadorPrincipal)Session["fechas"];

            Orden orden = new Orden();

            orden.userID             = currentUserId;
            orden.comuna             = buscador.Comuna;
            orden.desde              = buscador.Fechacompletadesde.Value.Date;
            orden.hasta              = buscador.Fechacompletahasta.Value.Date;
            orden.dias_totales       = buscador.Dias;
            orden.direccion          = buscador.Direccion;
            orden.estado             = (int)EstadoOrden.Creado;
            orden.fecha_desde        = buscador.Fechacompletadesde.Value;
            orden.fecha_hasta        = buscador.Fechacompletahasta.Value;
            orden.tiempo_desde       = buscador.Timedesde;
            orden.tiempo_hasta       = buscador.Timehasta;
            orden.total_final        = buscador.TotalFinal;
            orden.total_precio_abono = buscador.AbonoPorDias;
            orden.vehiculoID         = buscador.Idvehiculo;
            orden.total_precio_dias  = buscador.TotalPorDias;
            orden.fecha_creacion     = DateTime.Now;

            db.Orden.Add(orden);
            db.SaveChanges();

            int totalSeguro = 0;

            foreach (Seguro seg in buscador.Seguros)
            {
                DetalleSeguro detseguro = new DetalleSeguro();
                detseguro.id_orden  = orden.id;
                detseguro.id_seguro = seg.id;
                totalSeguro         = totalSeguro + seg.valor;
                db.DetalleSeguro.Add(detseguro);
            }

            orden.total_precio_seguro = totalSeguro;
            db.Entry(orden).State     = System.Data.Entity.EntityState.Modified;

            db.SaveChanges();

            Session.Remove("fechas");

            return(View());
        }
Пример #2
0
        public ActionResult Create([Bind(Include = "kenteken,merk,type,dagprijs,beschikbaar,foto")] auto auto)
        {
            if (ModelState.IsValid)
            {
                db.auto.Add(auto);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(auto));
        }
Пример #3
0
        public ActionResult Create([Bind(Include = "factuurnummer,klantcode,medewerkerscode,datum,factuurtotaal")] factuur factuur)
        {
            if (ModelState.IsValid)
            {
                db.factuur.Add(factuur);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.klantcode       = new SelectList(db.klant, "klantcode", "voorletters", factuur.klantcode);
            ViewBag.medewerkerscode = new SelectList(db.medewerker, "medewerkerscode", "voorletters", factuur.medewerkerscode);
            return(View(factuur));
        }
Пример #4
0
        public ActionResult Create(VehiculoModelo vehiculo, HttpPostedFileBase files)
        {
            if (ModelState.IsValid)
            {
                Vehiculo vehiculodb = new Vehiculo()
                {
                    abono = vehiculo.abono,
                    aire_acondicionado = vehiculo.aire_acondicionado,
                    capacidad          = vehiculo.capacidad,
                    valor               = vehiculo.valor,
                    categoriaID         = vehiculo.categoriaID,
                    cierre_centralizado = vehiculo.cierre_centralizado,
                    disponible          = vehiculo.disponible,
                    modelo              = vehiculo.modelo,
                    puertas             = vehiculo.puertas,
                    transmision         = vehiculo.transmision,
                    url_foto            = ""
                };

                db.Vehiculo.Add(vehiculodb);
                db.SaveChanges();



                //fotography
                ISupportedImageFormat format = new JpegFormat {
                    Quality = 90
                };
                Size size = new Size(650, 0);
                //https://naimhamadi.wordpress.com/2014/06/25/processing-images-in-c-easily-using-imageprocessor/
                // Initialize the ImageFactory using the overload to preserve EXIF metadata.
                using (ImageFactory imageFactory = new ImageFactory(preserveExifData: true))
                {
                    var path = Path.Combine(Server.MapPath("~/imagenes/Autos"), string.Format("{0}.{1}", vehiculodb.id.ToString("00000"), "jpg"));

                    // Load, resize, set the format and quality and save an image.
                    imageFactory.Load(files.InputStream)
                    .Resize(size)
                    .Format(format)
                    .Save(path);
                }
                vehiculodb.url_foto = string.Format("/imagenes/Autos/{0}.jpg", vehiculodb.id.ToString("00000"));
                Edit(vehiculodb);


                return(RedirectToAction("Index"));
            }

            ViewBag.categoriaID = new SelectList(db.Categoria, "id", "nombre", vehiculo.categoriaID);
            return(View(vehiculo));
        }
        private void btnCrear_Click(object sender, EventArgs e)
        {
            if (txtCombustible.Text != "")
            {
                model.NOMBRE = txtCombustible.Text.Trim();
                model.ESTADO = cbEstado.Checked;

                using (RentaCarEntities db = new RentaCarEntities())
                {
                    if (model.ID == 0)
                    {
                        db.COMBUSTIBLE_VEHICULO.Add(model);
                        MessageBox.Show("El combustible ha sido agregado");
                    }
                    else
                    {
                        db.Entry(model).State = EntityState.Modified;
                        MessageBox.Show("El combustible ha sido modificado");
                    }
                    db.SaveChanges();
                }
                Limpiar();
                getCombustibles();
            }
            else
            {
                MessageBox.Show("Rellene los campos");
            }
        }
        private void btnCrear_Click(object sender, EventArgs e)
        {
            if (cmbMarca.SelectedIndex != -1 || !string.IsNullOrWhiteSpace(txtModelo.Text))
            {
                model.ID_MARCA_VEHICULO = int.Parse(cmbMarca.SelectedValue.ToString());
                model.NOMBRE            = txtModelo.Text;
                model.ESTADO            = cbEstado.Checked;

                using (RentaCarEntities db = new RentaCarEntities()) {
                    if (model.ID == 0)
                    {
                        db.MODELO_VEHICULO.Add(model);
                        MessageBox.Show("Modelo de la marca agregado");
                    }
                    else
                    {
                        db.Entry(model).State = EntityState.Modified;
                        MessageBox.Show("Modelo de la marca modificado");
                    }
                    db.SaveChanges();
                }
                Limpiar();
                getModelos();
            }
            else
            {
                MessageBox.Show("Rellene los campos");
            }
        }
        private void btnCrear_Click(object sender, EventArgs e)
        {
            if (validarData())
            {
                using (RentaCarEntities db = new RentaCarEntities())
                {
                    if (renta.ID > 0)
                    {
                        renta.ID_CLIENTE       = Convert.ToInt32(cmbCliente.SelectedValue);
                        renta.ID_VEHICULO      = Convert.ToInt32(cmbVehiculo.SelectedValue);
                        renta.FECHA_RENTA      = dpRenta.Value;
                        renta.FECHA_DEVOLUCION = dpDevolucion.Value;
                        renta.CANTIDAD_DIAS    = Convert.ToInt32(lblDias.Text);
                        renta.MONTO_DIA        = Convert.ToInt32(numericCostePorDia.Value);
                        renta.DESCRIPCION      = txtDescripcion.Text;
                        renta.ESTADO           = cbEstado.Checked;

                        db.Entry(renta).State = EntityState.Modified;
                        MessageBox.Show("Renta actualizada");
                    }
                    else
                    {
                        //Inspección
                        inspeccion.ID_VEHICULO              = Convert.ToInt32(cmbVehiculo.SelectedValue);
                        inspeccion.CODIGO                   = CodigoAleatorio();
                        inspeccion.ID_CANTIDAD_COMBUSTIBLE  = Convert.ToInt32(cmbCantidadCombustible.SelectedValue);
                        inspeccion.TIENE_RAYADURAS          = rayaduras.Checked;
                        inspeccion.TIENE_ROTURA_CRISTAL     = cristalesRotos.Checked;
                        inspeccion.TIENE_GATO               = gato.Checked;
                        inspeccion.FECHA_CREACION           = DateTime.Now;
                        inspeccion.GOMA_REPUESTO            = gomaRepuesto.Checked;
                        inspeccion.GOMA_DELANTERA_DERECHA   = gomaDD.Checked;
                        inspeccion.GOMA_DELANTERA_IZQUIERDA = gomaDI.Checked;
                        inspeccion.GOMA_TRASERA_DERECHA     = gomaTD.Checked;
                        inspeccion.GOMA_TRASERA_IZQUIERDA   = gomaTI.Checked;

                        db.INSPECCION.Add(inspeccion);

                        //Renta
                        renta.ID_INSPECCION    = inspeccion.ID;
                        renta.ID_CLIENTE       = Convert.ToInt32(cmbCliente.SelectedValue);
                        renta.ID_EMPLEADO      = empleado.ID;
                        renta.ID_VEHICULO      = Convert.ToInt32(cmbVehiculo.SelectedValue);
                        renta.FECHA_RENTA      = dpRenta.Value;
                        renta.FECHA_DEVOLUCION = dpDevolucion.Value;
                        renta.FECHA_CREACION   = DateTime.Now;
                        renta.CANTIDAD_DIAS    = Convert.ToInt32(lblDias.Text);
                        renta.MONTO_DIA        = Convert.ToDecimal(numericCostePorDia.Value);
                        renta.DESCRIPCION      = txtDescripcion.Text;
                        renta.CODIGO           = CodigoAleatorio();
                        renta.ESTADO           = false;
                        db.RENTA.Add(renta);
                        MessageBox.Show("Renta agregada");
                    }
                    db.SaveChanges();
                    Limpiar();
                    getRentas();
                }
            }
        }
Пример #8
0
        private void btnCrear_Click(object sender, EventArgs e)
        {
            if (cedulaValidate())
            {
                model.NOMBRES         = txtNombres.Text;
                model.APELLIDOS       = txtApellidos.Text;
                model.CEDULA          = txtCedula.Text;
                model.TELEFONO        = txtTelefono.Text;
                model.EMAIL           = txtEmail.Text;
                model.TARJETA_CREDITO = txtTarjetaCredito.Text;
                model.LIMITE_CREDITO  = numericLimiteCredito.Value;
                model.ID_TIPO_CLIENTE = Convert.ToInt32(cmbTipoCliente.SelectedValue);
                model.ESTADO          = Convert.ToBoolean(cbEstado.Checked);
                model.FECHA_CREACION  = Convert.ToDateTime(lblFechaHoy.Text);

                using (RentaCarEntities db = new RentaCarEntities())
                {
                    if (model.ID == 0)
                    {
                        db.CLIENTE.Add(model);
                        MessageBox.Show("Cliente agregado");
                    }
                    else
                    {
                        db.Entry(model).State = EntityState.Modified;
                        MessageBox.Show("Cliente actualizado");
                    }
                    db.SaveChanges();
                    getClientes();
                    Limpiar();
                }
            }
        }
 private void btnCrear_Click(object sender, EventArgs e)
 {
     model.DESCRIPCION = textBox1.Text.Trim();
     model.ESTADO      = checkBox1.Checked;
     if (string.IsNullOrWhiteSpace(textBox1.Text))
     {
         MessageBox.Show("Llene los campos");
     }
     else
     {
         using (RentaCarEntities db = new RentaCarEntities())
         {
             if (model.ID == 0)
             {
                 db.TANDA.Add(model);
                 MessageBox.Show("Tanda Agregada");
             }
             else
             {
                 db.Entry(model).State = EntityState.Modified;
                 MessageBox.Show("Tanda modificada");
             }
             db.SaveChanges();
         }
         Limpiar();
         getTandas();
     }
 }
        private void btnBorrar_Click(object sender, EventArgs e)
        {
            string Preg = (renta.ESTADO == true) ? "Desea desactivar a esta Renta?" : "Desea activar a esta renta?";

            if (MessageBox.Show(Preg, "Mensaje", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                renta.ESTADO = !renta.ESTADO;
                using (RentaCarEntities db = new RentaCarEntities())
                {
                    db.Entry(renta).State = EntityState.Modified;
                    db.SaveChanges();
                }
                Limpiar();
                getRentas();
            }
        }
Пример #11
0
        private void button2_Click(object sender, EventArgs e)
        {
            string Preg = (model.ESTADO == true) ? "Desea desactivar a este cliente?" : "Desea activar a este cliente?";

            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();
                getClientes();
            }
        }
Пример #12
0
 private void btnBorrar_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Desea borrar esta tanda?", "Mensaje", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         using (RentaCarEntities db = new RentaCarEntities())
         {
             var entry = db.Entry(model);
             if (entry.State == EntityState.Detached)
             {
                 db.TANDA.Attach(model);
             }
             db.TANDA.Remove(model);
             db.SaveChanges();
             Limpiar();
             getTandas();
         }
     }
 }
 private void btnCrear_Click(object sender, EventArgs e)
 {
     model.DESCRIPCION = txtCantidadCombustible.Text;
     using (RentaCarEntities db = new RentaCarEntities())
     {
         if (model.ID == 0)
         {
             db.CANTIDAD_COMBUSTIBLE.Add(model);
         }
         else
         {
             db.Entry(model).State = EntityState.Modified;
         }
         db.SaveChanges();
         getCantidades();
         Limpiar();
     }
 }
 private void btnBorrar_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Desea borrar este modelo de vehículo?", "Mensaje", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         using (RentaCarEntities db = new RentaCarEntities())
         {
             var entry = db.Entry(model);
             if (entry.State == EntityState.Detached)
             {
                 db.MODELO_VEHICULO.Attach(model);
             }
             db.MODELO_VEHICULO.Remove(model);
             db.SaveChanges();
             MessageBox.Show("Modelo de vehículo eliminado");
             getModelos();
             Limpiar();
         }
     }
 }
 private void btnBorrar_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Desea borrar este tipo de cliente?", "Mensaje", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         using (RentaCarEntities db = new RentaCarEntities())
         {
             var entry = db.Entry(model);
             if (entry.State == EntityState.Detached)
             {
                 db.TIPO_CLIENTE.Attach(model);
             }
             db.TIPO_CLIENTE.Remove(model);
             db.SaveChanges();
             MessageBox.Show("Tipo de cliente eliminado");
             Limpiar();
             getTipoClientes();
         }
     }
 }
 private void btnBorrar_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Desea borrar esta cantidad de combustible?", "Mensaje", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         using (RentaCarEntities db = new RentaCarEntities())
         {
             var entry = db.Entry(model);
             if (entry.State == EntityState.Detached)
             {
                 db.CANTIDAD_COMBUSTIBLE.Attach(model);
             }
             db.CANTIDAD_COMBUSTIBLE.Remove(model);
             db.SaveChanges();
             MessageBox.Show("Cantidad eliminada");
             Limpiar();
             getCantidades();
         }
     }
 }
 private void btnCrear_Click(object sender, EventArgs e)
 {
     if (txtTipoCliente.Text != "")
     {
         model.DESCRIPCION = txtTipoCliente.Text.Trim();
         using (RentaCarEntities db = new RentaCarEntities())
         {
             if (model.ID == 0)
             {
                 db.TIPO_CLIENTE.Add(model);
                 MessageBox.Show("Tipo de cliente agregado");
             }
             else
             {
                 db.Entry(model).State = EntityState.Modified;
                 MessageBox.Show("Tipo de cliente modificado");
             }
             db.SaveChanges();
             getTipoClientes();
             Limpiar();
         }
     }
 }
 private void btnCrear_Click(object sender, EventArgs e)
 {
     if (txtTipoEmpleado.Text != "")
     {
         model.DESCRIPCION = txtTipoEmpleado.Text.Trim();
         using (RentaCarEntities db = new RentaCarEntities())
         {
             if (model.ID == 0)
             {
                 db.TIPO_EMPLEADO.Add(model);
                 MessageBox.Show("El tipo de empleado ha sido agregado");
             }
             else
             {
                 db.Entry(model).State = EntityState.Modified;
                 MessageBox.Show("El tipo de empleado ha sido modificado");
             }
             db.SaveChanges();
             getTiposEmpleados();
             Limpiar();
         }
     }
 }