Esempio n. 1
0
        public async Task <IActionResult> EditLotes(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var lote = _context.LoteRecibos.Where(l => l.CajaId == id.Value).FirstOrDefault();

            ViewBag.Caja = _context.Caja.Find(id).Description;
            if (lote == null)
            {
                var newLote = new LoteRecibos
                {
                    CajaId = id.Value,
                    Actual = 0,
                    Final  = 0,
                    Inicio = 0
                };
                _context.LoteRecibos.Add(newLote);
                _context.SaveChanges();
                return(View(newLote));
            }

            decimal porcentaje = 0;

            if (Convert.ToInt16(lote.Final - lote.Inicio) != 0)
            {
                porcentaje = (Convert.ToDecimal(lote.Actual - lote.Inicio) / Convert.ToDecimal(lote.Final - lote.Inicio)) * 100;
            }

            ViewBag.Porcentaje = Math.Round(porcentaje, 2);
            return(View(lote));
        }
Esempio n. 2
0
        public async Task <IActionResult> saveLote(LoteRecibos lote)
        {
            var LoteActual = await _context.LoteRecibos.FindAsync(lote.Id);

            if (LoteActual == null)
            {
                return(NotFound());
            }

            LoteActual.Inicio = lote.Inicio;
            LoteActual.Final  = lote.Final;
            LoteActual.Actual = lote.Actual;
            await _context.SaveChangesAsync();

            return(Json(LoteActual));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("Id,NoCaja,Description")] Caja caja)
        {
            if (ModelState.IsValid)
            {
                _context.Add(caja);
                await _context.SaveChangesAsync();

                var loterecibo = new LoteRecibos
                {
                    CajaId = caja.Id,
                    Actual = 0,
                    Final  = 0,
                    Inicio = 0
                };

                _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(caja));
        }