public JsonResult DeletaPeca(int id)
        {
            ORDEM_ACABAMENTO_PECAS ordem_acabamento_pecas = db.ORDEM_ACABAMENTO_PECAS.Find(id);

            if (ordem_acabamento_pecas == null)
            {
                return(Json(false));
            }

            int peca  = ordem_acabamento_pecas.ID_PECA;
            int ordem = ordem_acabamento_pecas.ID_ORDEM_ACABAMENTO;

            ORDEM_ACABAMENTO ordem_acabamento = db.ORDEM_ACABAMENTO.Find(ordem);

            ordem_acabamento.KILOS_ORIGINAIS = ordem_acabamento.KILOS_ORIGINAIS - ordem_acabamento_pecas.PESO;
            db.Entry(ordem_acabamento).State = EntityState.Modified;

            PECAS pecacrua = db.PECAS.Find(peca);

            pecacrua.SITUACAO        = eSituacaoPeca.Disponivel;
            db.Entry(pecacrua).State = EntityState.Modified;

            db.ORDEM_ACABAMENTO_PECAS.Remove(ordem_acabamento_pecas);

            db.SaveChanges();

            return(Json(true));
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            ORDEM_ACABAMENTO ordem_acabamento = db.ORDEM_ACABAMENTO.Find(id);

            db.ORDEM_ACABAMENTO.Remove(ordem_acabamento);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
        public ActionResult Delete(int id = 0)
        {
            ORDEM_ACABAMENTO ordem_acabamento = db.ORDEM_ACABAMENTO.Find(id);

            if (ordem_acabamento == null)
            {
                return(HttpNotFound());
            }
            return(View(ordem_acabamento));
        }
예제 #4
0
 public ActionResult Edit(ORDEM_ACABAMENTO ordem_acabamento)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ordem_acabamento).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ordem_acabamento));
 }
예제 #5
0
        public ActionResult Emissao(int id = 0)
        {
            ORDEM_ACABAMENTO ordem_acabamento = db.ORDEM_ACABAMENTO.Find(id);
            List <ORDEM_ACABAMENTO_PECAS> ordem_acabamento_pecas = db.ORDEM_ACABAMENTO_PECAS.Where(p => p.ID_ORDEM_ACABAMENTO == id).ToList();

            ordem_acabamento.ORDEM_ACABAMENTO_PECAS = ordem_acabamento_pecas;
            if (ordem_acabamento == null)
            {
                return(HttpNotFound());
            }
            return(View(ordem_acabamento));
        }
예제 #6
0
        public ActionResult Create(ORDEM_ACABAMENTO ordem_acabamento)
        {
            if (ModelState.IsValid)
            {
                db.ORDEM_ACABAMENTO.Add(ordem_acabamento);
                db.SaveChanges();
                return(RedirectToAction("Programado"));
            }

            ViewBag.ID_PRODUTO = new SelectList(db.PRODUTO, "ID_PRODUTO", "NOME_PRODUTO");
            ViewBag.ID_COR     = new SelectList(db.COR, "ID_COR", "NOME_COR");
            return(View(ordem_acabamento));
        }
        public ActionResult InserirPecas(FormCollection form)
        {
            var vidordem = form.GetValues("ID_ORDEM_ACABAMENTO");
            var vidpecas = form.GetValues("checkboxPecas");
            int idordem  = Convert.ToInt32(vidordem[0]);

            if (vidpecas == null)
            {
                ModelState.AddModelError("", "None of the reconds has been selected for delete action !");
                return(View());
            }

            foreach (var item in vidpecas)
            {
                try
                {
                    int   id    = Convert.ToInt32(item);
                    PECAS pecas = db.PECAS.Find(id);
                    if ((pecas.SITUACAO == eSituacaoPeca.Disponivel) && (pecas.TIPO_PECA == eTipoPeca.Cru))
                    {
                        ORDEM_ACABAMENTO_PECAS ordem_acabamento_pecas = new ORDEM_ACABAMENTO_PECAS();
                        ordem_acabamento_pecas.ID_ORDEM_ACABAMENTO = idordem;
                        ordem_acabamento_pecas.ID_PECA             = pecas.ID_PECA;
                        if (pecas.METROS.HasValue)
                        {
                            ordem_acabamento_pecas.METROS = (double)pecas.METROS;
                        }
                        ordem_acabamento_pecas.PESO = pecas.PESO_LIQUIDO;
                        db.ORDEM_ACABAMENTO_PECAS.Add(ordem_acabamento_pecas);

                        ORDEM_ACABAMENTO ordem_acabamento = db.ORDEM_ACABAMENTO.Find(idordem);
                        ordem_acabamento.KILOS_ORIGINAIS = ordem_acabamento.KILOS_ORIGINAIS + pecas.PESO_LIQUIDO;
                        db.Entry(ordem_acabamento).State = EntityState.Modified;

                        PECAS pecacrua = db.PECAS.Find(id);
                        pecacrua.SITUACAO        = eSituacaoPeca.Producao;
                        db.Entry(pecacrua).State = EntityState.Modified;

                        db.SaveChanges();
                    }
                }
                catch (Exception err)
                {
                    ModelState.AddModelError("", "Failed On Id " + item.ToString() + " : " + err.Message);
                    return(View());
                }
            }


            return(RedirectToAction("Emissao", "OrdemAcabamento", new { id = idordem }));
        }
예제 #8
0
        public JsonResult Recebimento(int id)
        {
            ORDEM_ACABAMENTO ordem_acabamento = db.ORDEM_ACABAMENTO.Find(id);

            if (ordem_acabamento == null)
            {
                return(Json(false));
            }

            ordem_acabamento.SITUACAO        = eTipoSituacao.Recebido;
            db.Entry(ordem_acabamento).State = EntityState.Modified;
            db.SaveChanges();
            return(Json(true));
        }
예제 #9
0
        public ActionResult Revisao(int id = 0)
        {
            ORDEM_ACABAMENTO ordem_acabamento = db.ORDEM_ACABAMENTO.Find(id);
            List <ORDEM_ACABAMENTO_PECAS> ordem_acabamento_pecas = db.ORDEM_ACABAMENTO_PECAS.Where(p => p.ID_ORDEM_ACABAMENTO == id).ToList();

            ordem_acabamento.ORDEM_ACABAMENTO_PECAS = ordem_acabamento_pecas;
            var acondicionamento = from c in db.ACONDICIONAMENTO select c;

            ViewData["acondicionamento"] = new SelectList(acondicionamento, "ID_ACONDICIONAMENTO", "NOME_ACONDICIONAMENTO");
            if (ordem_acabamento == null)
            {
                return(HttpNotFound());
            }
            return(View(ordem_acabamento));
        }