Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Descricao")] FORMA_PAGAMENTO fORMA_PAGAMENTO)
        {
            if (id != fORMA_PAGAMENTO.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(fORMA_PAGAMENTO);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FORMA_PAGAMENTOExists(fORMA_PAGAMENTO.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(fORMA_PAGAMENTO));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Descricao")] FORMA_PAGAMENTO fORMA_PAGAMENTO)
        {
            if (ModelState.IsValid)
            {
                _context.Add(fORMA_PAGAMENTO);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(fORMA_PAGAMENTO));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Create(FORMA_PAGAMENTO formaPagamento)
        {
            if (Session.IsFuncionario())
            {
                if (string.IsNullOrEmpty(formaPagamento.DESCRICAO))
                {
                    ModelState.AddModelError("", "Informe uma descrição!");
                }

                if (string.IsNullOrEmpty(formaPagamento.SITUACAO))
                {
                    ModelState.AddModelError("", "Informe uma situação!");
                }


                if (!string.IsNullOrEmpty(formaPagamento.DESCRICAO))
                {
                    formaPagamento.DESCRICAO = formaPagamento.DESCRICAO.ToUpper();
                }

                if (ModelState.IsValid)
                {
                    _db.FORMA_PAGAMENTO.Add(formaPagamento);
                    await _db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }

                ViewBag.BANCO = new SelectList(await _db.BANCO.Where(b => b.SITUACAO == "A").ToArrayAsync(), "ID", "DESCRICAO");

                return(View(formaPagamento));
            }
            else
            {
                return(RedirectToAction("", ""));
            }
        }
Ejemplo n.º 4
0
        public ActionResult Edit(FORMA_PAGAMENTO formaPagamento)
        {
            if (Session.IsFuncionario())
            {
                #region Validações

                if (string.IsNullOrEmpty(formaPagamento.DESCRICAO))
                {
                    return(Json(new { status = 100, ex = "Informe uma descrição!" }));
                }

                if (string.IsNullOrEmpty(formaPagamento.SITUACAO))
                {
                    return(Json(new { status = 100, ex = "Informe uma situação!" }));
                }

                #endregion

                #region Alterar Forma de Pagamento

                if (!string.IsNullOrEmpty(formaPagamento.DESCRICAO))
                {
                    formaPagamento.DESCRICAO = formaPagamento.DESCRICAO.ToUpper();
                }

                _db.Entry(formaPagamento).State = EntityState.Modified;
                _db.SaveChanges();

                #endregion

                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("", ""));
            }
        }