Exemple #1
0
        public IActionResult ProEdit(TCCproduct product, int id, string actionType)
        {
            int?Pid = product.CprodCustId;

            if (actionType == "Update")
            {
                if (ModelState.IsValid)
                {
                    try{
                        _dbContext.TCCproducts.Update(product);
                        _dbContext.SaveChanges();
                    }
                    catch {}
                }
                else
                {
                    //loadCustomerViewBag(Pid,product.CprodCplantId);
                    CreateViewBags(Pid, product.CprodId, product.CprodCplantId);
                    return(View(product));
                }
            }
            var model = _dbContext.TCustomers
                        .SingleOrDefault(u => u.CustId.Equals(Pid));

            CreateViewBags(Pid, product.CprodId, product.CprodCplantId);
            ViewData["panel"] = 2;
            //return View("Edit",model);
            return(RedirectToAction("Edit", new{ id = Pid, panel = 2, move = 0, prod = product.CprodId, plant = product.CprodCplantId }));

            //return RedirectToAction("Index");
        }
Exemple #2
0
        public IActionResult ProCreate(TCCproduct product, int Pid, int plant, string actionType)
        {
            ViewData["panel"] = 2;
            if (actionType == "Add")
            {
                if (ModelState.IsValid)
                {
                    try{
                        _dbContext.TCCproducts.Add(product);
                        _dbContext.SaveChanges();
                    }
                    catch { return(View("Error")); }
                }
                else
                {
                    //loadCustomerViewBag(Pid,product.CprodCplantId);
                    CreateViewBags(Pid, 0, product.CprodCplantId);
                    return(View(product));
                }
            }
            var model = _dbContext.TCustomers
                        .SingleOrDefault(u => u.CustId.Equals(Pid));

            CreateViewBags(Pid, 0, product.CprodCplantId);
            string cName = model.CustRasoc + " " + model.CustNif;

            ViewData["cName"] = cName;
            ViewData["CusId"] = Pid;
            ViewData["panel"] = 2;

            return(RedirectToAction("Edit", new{ id = Pid, panel = 2, move = 0, plant = product.CprodCplantId }));

            //return View("Edit",model);
        }