Beispiel #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            rentas rentas = db.rentas.Find(id);

            db.rentas.Remove(rentas);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult Edit([Bind(Include = "id,folio,fechaCreacion,fechaModificacion,fechaRenta,fechaVence,subtotal,total,cantidadTotalProd,idEstatus,idUSuario,idCliente,idDescuento")] rentas rentas)
        {
            if (ModelState.IsValid)
            {
                db.Entry(rentas).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rentas));
        }
Beispiel #3
0
        // GET: rentas/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            rentas rentas = db.rentas.Find(id);

            if (rentas == null)
            {
                return(HttpNotFound());
            }
            return(View(rentas));
        }
Beispiel #4
0
        public ActionResult AgregarRenta(rentasModelFinal rentaObject)
        {
            var response = new { ok = true, error = "null" };

            try
            {
                // Creacion de objeto de la renta a agregar
                rentas rentaAdd = new rentas();

                rentaAdd.folio             = rentaObject.folio;
                rentaAdd.fechaCreacion     = DateTime.Now;
                rentaAdd.fechaModificacion = DateTime.Now;
                rentaAdd.fechaRenta        = rentaObject.fechaRenta;
                rentaAdd.fechaVence        = rentaObject.fechaVence;
                rentaAdd.total             = rentaObject.total;
                rentaAdd.subtotal          = rentaObject.subtotal;
                rentaAdd.cantidadTotalProd = rentaObject.listadoProducto.Count;

                // Insercion del encabezado de la RENTA
                db.rentas.Add(rentaAdd);
                db.SaveChanges();

                // Obtenemos el ultimo ID de la RENTA para agregar su DETALLE
                var idRenta = db.rentas.ToList().Max(x => x.id);

                // Iteracion para obetener los productos a insertar el DETALLE DE LA RENTA
                foreach (var producto in rentaObject.listadoProducto)
                {
                    // Creacion de objeto de Detalle de la renta
                    rentaDetalle detalleRenta = new rentaDetalle();

                    detalleRenta.idProducto     = producto.id;
                    detalleRenta.cantidad       = producto.cantidad;
                    detalleRenta.precioUnitario = producto.precioUnitario;
                    detalleRenta.entregado      = 0;
                    detalleRenta.idRenta        = idRenta;

                    // Seccion de insercion a la tabla rentaDetalle
                    db.rentaDetalle.Add(detalleRenta);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                var controlarExcepcion = ex.Message;
            }

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
        private void FrmInspeccion_Load(object sender, EventArgs e)
        {
            // TODO: esta línea de código carga datos en la tabla 'rentcarDataSetEmpleadoInspeccionSelect.empleados' Puede moverla o quitarla según sea necesario.
            this.empleadosTableAdapter.FillByEstado(this.rentcarDataSetEmpleadoInspeccionSelect.empleados);
            using (RentcarEntities db = new RentcarEntities())
            {
                if (this.action == "New")
                {
                    oRenta = db.rentas.Find(this.id);
                }
                else
                {
                    oRenta = db.rentas.Find(oInspeccion.renta_id);
                    cmb_empleado.SelectedValue = oInspeccion.empleado_id;
                }

                dtp_fecha_inspeccion.MinDate = oRenta.fecha_renta.Value;
            }
        }
Beispiel #6
0
        // GET: rentas/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            rentas rentas = db.rentas.Find(id);

            // Datos del detalle de la renta
            ViewBag.idRenta = id;


            if (rentas == null)
            {
                return(HttpNotFound());
            }


            return(View(rentas));
        }
        private void loadData()
        {
            using (RentcarEntities db = new RentcarEntities())
            {
                oRenta = db.rentas.Find(this.id);

                dtp_fecha_renta.Value      = oRenta.fecha_renta.Value;
                dtp_fecha_devolucion.Value = oRenta.fecha_devolucion.Value;
                txt_monto.Value            = int.Parse(oRenta.monto.ToString());
                txt_dias.Value             = int.Parse(oRenta.dias.ToString());
                txt_comentario.Text        = oRenta.comentario;

                if (oRenta.estado == true)
                {
                    radioButton1.Checked = Convert.ToBoolean(1);
                }
                else
                {
                    radioButton2.Checked = Convert.ToBoolean(1);
                }
            }
        }
Beispiel #8
0
        private void button3_Click(object sender, EventArgs e)
        {
            int?id = getId();

            if (id != null)
            {
                DialogResult msg = MessageBox.Show("¿Seguro que deseas eliminar esta renta?",
                                                   "Rentas", MessageBoxButtons.YesNo);

                if (msg == DialogResult.Yes)
                {
                    using (RentcarEntities db = new RentcarEntities())
                    {
                        rentas oRenta = db.rentas.Find(id);
                        db.rentas.Remove(oRenta);

                        db.SaveChanges();
                    }
                    refreshDataGrid();
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            using (RentcarEntities db = new RentcarEntities())
            {
                if (string.IsNullOrEmpty(cmb_empleado.Text) || string.IsNullOrEmpty(cmb_vehiculo.Text) || string.IsNullOrEmpty(cmb_cliente.Text) || int.Parse(txt_monto.Text) == 0 || int.Parse(txt_dias.Text) == 0 || !radioButton1.Checked && !radioButton2.Checked && this.id != null)
                {
                    MessageBox.Show("Completar los campos que son obligatorios.");
                }
                else if (dtp_fecha_renta.Value > dtp_fecha_devolucion.Value)
                {
                    MessageBox.Show("La fecha de renta no puede ser mayor a la fecha de devolucion.");
                }
                else
                {
                    int       vehiculo_id = int.Parse(cmb_vehiculo.SelectedValue.ToString());
                    vehiculos oVehiculo   = db.vehiculos.Find(vehiculo_id);

                    if (this.id == null)
                    {
                        rentas oRenta = new rentas();
                        oRenta.fecha_renta      = dtp_fecha_renta.Value;
                        oRenta.fecha_devolucion = dtp_fecha_devolucion.Value;
                        oRenta.monto            = int.Parse(txt_monto.Value.ToString());
                        oRenta.dias             = int.Parse(txt_dias.Value.ToString());
                        oRenta.comentario       = txt_comentario.Text.Trim();
                        oRenta.empleado_id      = int.Parse(cmb_empleado.SelectedValue.ToString());
                        oRenta.vehiculo_id      = vehiculo_id;
                        oRenta.cliente_id       = int.Parse(cmb_cliente.SelectedValue.ToString());
                        oRenta.estado           = true;
                        oVehiculo.estado        = true;

                        //Cambiar el estado del vehiculo
                        oVehiculo.estado = false;

                        db.rentas.Add(oRenta);
                        db.Entry(oVehiculo).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        this.Close();
                    }
                    else
                    {
                        //Verificar si el vehiculo seleccionado esta en renta
                        oRenta = db.rentas.Find(this.id);
                        int confirmRenta = db.rentas.Where(c => c.vehiculo_id == vehiculo_id).Where(c => c.id != oRenta.id).Count(c => c.estado == true);

                        //Si el vehiculo ya esta en renta
                        if (confirmRenta > 0)
                        {
                            MessageBox.Show("El vehiculo que ha seleccionado ya esta en renta.");
                        }
                        else
                        {
                            //Si el vehiculo de renta es diferente al vehiculo rentado en ese momento
                            if (vehiculo_id != oRenta.vehiculo_id)
                            {
                                vehiculos changeEstado = db.vehiculos.Find(oRenta.vehiculo_id);
                                changeEstado.estado          = true;
                                db.Entry(changeEstado).State = System.Data.Entity.EntityState.Modified;
                            }

                            oRenta.fecha_renta      = dtp_fecha_renta.Value;
                            oRenta.fecha_devolucion = dtp_fecha_devolucion.Value;
                            oRenta.monto            = int.Parse(txt_monto.Value.ToString());
                            oRenta.dias             = int.Parse(txt_dias.Value.ToString());
                            oRenta.comentario       = txt_comentario.Text.Trim();
                            oRenta.empleado_id      = int.Parse(cmb_empleado.SelectedValue.ToString());
                            oRenta.vehiculo_id      = vehiculo_id;
                            oRenta.cliente_id       = int.Parse(cmb_cliente.SelectedValue.ToString());

                            if (radioButton1.Checked)
                            {
                                oRenta.estado    = true;
                                oVehiculo.estado = false;
                            }
                            else if (radioButton2.Checked)
                            {
                                oRenta.estado    = false;
                                oVehiculo.estado = true;
                            }

                            db.Entry(oRenta).State    = System.Data.Entity.EntityState.Modified;
                            db.Entry(oVehiculo).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                            this.Close();
                        }
                    }
                }
            }
        }
Beispiel #10
0
        private void ShowRentaData_Load(object sender, EventArgs e)
        {
            using (RentcarEntities db = new RentcarEntities())
            {
                oRenta              = db.rentas.Find(this.id);
                oVehiculo           = db.vehiculos.Find(oRenta.vehiculo_id);
                oCliente            = db.clientes.Find(oRenta.cliente_id);
                oModelo             = db.modelos.Find(oVehiculo.modelo_id);
                oMarca              = db.marcas.Find(oVehiculo.marca_id);
                oInspeccion         = db.inspeccions.Where(c => c.renta_id == oRenta.id).First();
                oEmpleado           = db.empleados.Find(oRenta.empleado_id);
                oEmpleadoInspeccion = db.empleados.Find(oInspeccion.empleado_id);
            }
            //Detalles de renta
            label19.Text = oRenta.fecha_renta.Value.ToString("dd/MM/yyyy");
            label20.Text = oRenta.fecha_devolucion.Value.ToString("dd/MM/yyyy");
            label21.Text = oMarca.nombre + " " + oModelo.nombre + " " + oVehiculo.anio;
            label22.Text = oCliente.full_name + " ( " + oCliente.cedula + " )";
            label23.Text = oEmpleado.full_name + " ( " + oEmpleado.email + " )";
            label24.Text = "RD$" + oRenta.monto.ToString();
            label25.Text = oRenta.dias.ToString();
            label26.Text = "RD$" + (oRenta.monto * oRenta.dias).ToString();

            if (oRenta.estado == true)
            {
                label27.Text = "En renta";
            }
            else
            {
                label27.Text = "Devuelto";
            }

            label28.Text = oRenta.comentario;

            //Detalles de inspeccion
            label29.Text = oInspeccion.fecha_inspeccion.Value.ToString("dd/MM/yyyy");
            label30.Text = getValueOfBoolean(oInspeccion.ralladura.Value);
            label31.Text = getValueOfBoolean(oInspeccion.gato.Value);
            label32.Text = getValueOfBoolean(oInspeccion.goma_repuesto.Value);
            label33.Text = getValueOfBoolean(oInspeccion.rotura_cristal.Value);
            label34.Text = oEmpleadoInspeccion.full_name + " ( " + oEmpleado.email + " )";
            label39.Text = oInspeccion.combustible;

            if (oInspeccion.goma_superior_derecha == true)
            {
                label35.Text = "Goma superior derecha";
            }
            if (oInspeccion.goma_superior_izquierda == true && oInspeccion.goma_superior_derecha == true)
            {
                label35.Text += ", Goma superior izquierda";
            }
            else
            {
                label35.Text += "Goma superior izquierda";
            }

            if (oInspeccion.goma_inferior_derecha == true)
            {
                label36.Text = "Goma inferior derecha";
            }
            if (oInspeccion.goma_inferior_izquierda == true && oInspeccion.goma_inferior_derecha == true)
            {
                label36.Text += ", Goma inferior izquierda";
            }
            else
            {
                label36.Text += "Goma inferior izquierda";
            }

            if (oInspeccion.estado == true)
            {
                label40.Text = "Activo";
            }
            else
            {
                label40.Text = "Inactivo";
            }
        }