Beispiel #1
0
        public IActionResult PlanCreate(int Pid, int prod, int plant, string actionType)
        {
            var queryc = (from p in _dbContext.TCustomers
                          where p.CustId == Pid
                          select p).SingleOrDefault();

            ViewBag.Customer = queryc;
            CreateViewBags(Pid, prod, plant, Pid);

            var query = (from p in _dbContext.TCCplants
                         where p.CplantId == plant
                         select p).FirstOrDefault();

            ViewData["truck"] = query.CplantTruckId;

            TCCplanning model = (TCCplanning)(from p in _dbContext.TCCplannings
                                              where p.CplanCustId == Pid && p.CplanCplantId == plant
                                              select p).FirstOrDefault();

            try{
                model.CplanCprodId  = prod;
                model.CplanDateFrom = System.DateTime.Now;
                model.CplanDateTo   = System.DateTime.Now;
                model.CplanFirmSt   = "";
                model.CplanQty      = 0;
            }
            catch {
                model = new TCCplanning();
                model.CplanCplantId = plant;
                model.CplanCustId   = Pid;
            }
            return(View(model));
        }
Beispiel #2
0
        public IActionResult PlanEdit(TCCplanning planning, string actionType, int?CplantId, int?CprodId, string sallpprods)
        {
            bool allpprods = Convert.ToBoolean(sallpprods);

            ViewData["panel"] = 4;
            ViewData["Allpp"] = allpprods;
            int?Pid = planning.CplanCustId;

            if (actionType == "Update")
            {
                if (ModelState.IsValid)
                {
                    try{
                        //planning.CplanCplantId=CplantId;
                        //planning.CplanCprodId=CprodId;
                        _dbContext.TCCplannings.Update(planning);
                        _dbContext.SaveChanges();
                    }
                    catch {}
                }
                else
                {
                    //loadCustomerViewBag(Pid,porder.CpocplantId);
                    CreateViewBags(Pid, planning.CplanCprodId, planning.CplanCplantId);
                    return(View(planning));
                }
            }

            var model = _dbContext.TCustomers
                        .SingleOrDefault(u => u.CustId.Equals(Pid));

            string cName = model.CustRasoc + " " + model.CustNif;

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

            if (actionType == "Cancel" || actionType == "Update")
            {
                CreateViewBags(Pid, planning.CplanCprodId, planning.CplanCplantId);
                return(RedirectToAction("Edit", new{ id = Pid, panel = 4, move = 0, prod = planning.CplanCprodId, plant = planning.CplanCplantId, allpprods = allpprods }));
            }
            else
            {
                planning.CplanCplantId = CplantId;
                planning.CplanCprodId  = CprodId;
                CreateViewBags(Pid, planning.CplanCprodId, planning.CplanCplantId);
                return(View(planning));
            }
        }
Beispiel #3
0
        public IActionResult PlanCreate(TCCplanning planning, int Pid, int prod, int?plant, string actionType, int?CplantId, int?CprodId, int?CPlanTruckId, string sallpprods)
        {
            bool allpprods = Convert.ToBoolean(sallpprods);

            ViewData["Allpp"] = allpprods;
            var model = _dbContext.TCustomers
                        .SingleOrDefault(u => u.CustId.Equals(Pid));

            string cName = model.CustRasoc + " " + model.CustNif;

            ViewData["cName"] = cName;
            ViewData["CusId"] = Pid;
            ViewData["panel"] = 4;
            if (actionType == "Add")
            {
                if (ModelState.IsValid)
                {
                    try{
                        if (planning.CplanCprodId == null || planning.CplanCprodId == 0)
                        {
                            planning.CplanCprodId = CprodId;
                        }
                        _dbContext.TCCplannings.Add(planning);
                        _dbContext.SaveChanges();
                    }
                    catch { return(View("Error")); }
                }
                else
                {
                    //loadCustomerViewBag(Pid,product.CprodCplantId);
                    CreateViewBags(Pid, 0, planning.CplanCplantId);
                    return(View(planning));
                }
            }
            if (actionType == "Cancel" || actionType == "Add")
            {
                CreateViewBags(Pid, planning.CplanCprodId, planning.CplanCplantId);
                return(RedirectToAction("Edit", new{ id = Pid, panel = 4, move = 0, prod = planning.CplanCprodId, plant = planning.CplanCplantId, allpprods = allpprods }));
            }
            else
            {
                planning.CplanCplantId = CplantId;
                planning.CplanCprodId  = CprodId;
                CreateViewBags(Pid, planning.CplanCprodId, planning.CplanCplantId);
                return(View(planning));
            }
        }
Beispiel #4
0
        public IActionResult PlanEdit(TCCplanning planning, string actionType, int?CplantId, int?CprodId)
        {
            int?Pid = planning.CplanCustId;

            if (actionType == "Update")
            {
                if (ModelState.IsValid)
                {
                    try{
                        planning.CplanCplantId = CplantId;
                        planning.CplanCprodId  = CprodId;
                        _dbContext.TCCplannings.Update(planning);
                        _dbContext.SaveChanges();
                    }
                    catch {}
                }
                else
                {
                    //loadCustomerViewBag(Pid,porder.CpocplantId);
                    CreateViewBags(Pid, planning.CplanCprodId, planning.CplanCplantId);
                    return(View(planning));
                }
            }

            ViewData["panel"] = 4;
            if (actionType == "Cancel" || actionType == "Update")
            {
                CreateViewBags(Pid, planning.CplanCprodId, planning.CplanCplantId);
                return(RedirectToAction("Edit", new{ id = Pid, panel = 4, move = 0, prod = planning.CplanCprodId, plant = planning.CplanCplantId }));
            }
            else
            {
                planning.CplanCplantId = CplantId;
                planning.CplanCprodId  = CprodId;
                CreateViewBags(Pid, planning.CplanCprodId, planning.CplanCplantId);
                return(View(planning));
            }
        }
Beispiel #5
0
 public IActionResult PlanCreate(TCCplanning planning, int Pid, int prod, int?plant, string actionType, int?CplantId, int?CprodId, int?CPlanTruckId)
 {
     ViewData["panel"] = 4;
     if (actionType == "Add")
     {
         if (ModelState.IsValid)
         {
             try{
                 if (planning.CplanCprodId == null || planning.CplanCprodId == 0)
                 {
                     planning.CplanCprodId = CprodId;
                 }
                 _dbContext.TCCplannings.Add(planning);
                 _dbContext.SaveChanges();
             }
             catch { return(View("Error")); }
         }
         else
         {
             //loadCustomerViewBag(Pid,product.CprodCplantId);
             CreateViewBags(Pid, 0, planning.CplanCplantId);
             return(View(planning));
         }
     }
     if (actionType == "Cancel" || actionType == "Add")
     {
         CreateViewBags(Pid, planning.CplanCprodId, planning.CplanCplantId);
         return(RedirectToAction("Edit", new{ id = Pid, panel = 4, move = 0, prod = planning.CplanCprodId, plant = planning.CplanCplantId }));
     }
     else
     {
         planning.CplanCplantId = CplantId;
         planning.CplanCprodId  = CprodId;
         CreateViewBags(Pid, planning.CplanCprodId, planning.CplanCplantId);
         return(View(planning));
     }
 }
Beispiel #6
0
        public IActionResult PlanCreate(int Pid, int prod, int plant, string actionType, bool allpprods)
        {
            ViewData["Allpp"] = allpprods;
            if (prod == null)
            {
                prod = 0;
            }
            if (plant == null)
            {
                plant = 0;
            }
            ViewData["Plant"] = plant;
            ViewData["Prod"]  = prod;

            var queryc = (from p in _dbContext.TCustomers
                          where p.CustId == Pid
                          select p).SingleOrDefault();

            ViewBag.Customer = queryc;
            CreateViewBags(Pid, prod, plant, Pid);

            try{
                var query = (from p in _dbContext.TCCplants
                             where p.CplantId == plant
                             select p).FirstOrDefault();
                ViewData["truck"] = query.CplantTruckId;
            }
            catch {}
            object xmodel = null;

            try{
                TCCplanning model = (TCCplanning)(from p in _dbContext.TCCplannings
                                                  where p.CplanCustId == Pid && p.CplanCplantId == plant
                                                  select p).FirstOrDefault();
                try{
                    model.CplanCprodId  = prod;
                    model.CplanDateFrom = System.DateTime.Now;
                    model.CplanDateTo   = System.DateTime.Now;
                    model.CplanFirmSt   = "";
                    model.CplanQty      = 0;
                }
                catch {
                    model               = new TCCplanning();
                    model.CplanCustId   = Pid;
                    model.CplanCplantId = plant;
                    model.CplanCprodId  = prod;
                }
                xmodel = model;
            }
            catch {}
            var cmodel = _dbContext.TCustomers
                         .SingleOrDefault(u => u.CustId.Equals(Pid));

            string cName = cmodel.CustRasoc + " " + cmodel.CustNif;

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

            ViewData["panel"] = 4;
            return(View(xmodel));
        }