Ejemplo n.º 1
0
        public IActionResult PlanEdit(TSPlanning planning, string actionType)
        {
            int?Pid = planning.PlanSupId;

            if (actionType == "Update")
            {
                if (ModelState.IsValid)
                {
                    try{
                        _dbContext.TSPlannings.Update(planning);
                        _dbContext.SaveChanges();
                    }
                    catch {}
                }
                else
                {
                    CreateViewBags(Pid, planning.PlanProdId);
                    return(View(planning));
                }
            }
            var model = _dbContext.TSupliers
                        .SingleOrDefault(u => u.SupId.Equals(Pid));
            string sName = model.SupRasoc + " " + model.SupNif;

            ViewData["sName"] = sName;
            ViewData["SupId"] = Pid;

            CreateViewBags(Pid, planning.PlanProdId);
            ViewData["panel"] = 3;
            return(RedirectToAction("Edit", new{ id = Pid, panel = 3, move = 0, prod = planning.PlanProdId }));
        }
Ejemplo n.º 2
0
        private void  ValidateReqs(DateTime?F1, DateTime?F2, bool accStock)
        {
            //graba Planning data por proveedor,po, material, cantidad
            //actualiza material stock Location en transito con lo que lo
            //tendra en cuenta en el proximo calculo MRP
            CreateVB_cMRP(F1, F2, accStock);
            List <TExpMatd> mode_ = (List <TExpMatd>)ViewBag.ListMatPOT;

            foreach (TExpMatd rec in mode_)
            {
                int?   _idmat = rec.expcomp;
                double?qtyreq = rec.SPoPcRequ;
                int?   _idSup = rec.SupId;
                int?   _idPo  = rec.SPoId;
                //SpocprodId SporeferEx SposupId
                var qpo = (from po in _dbContext.TSPorders where po.SpocprodId == _idmat &&
                           po.SposupId == _idSup
                           select po.SporeferEx).ToList();
                int?_IdRe = qpo[0];
                try{
                    TSPlanning modpl = new TSPlanning();
                    modpl.PlanSupId    = _idSup;
                    modpl.PlanProdId   = _IdRe;
                    modpl.PlanDateFrom = F1;
                    modpl.PlanDateTo   = F2;
                    modpl.PlanQty      = qtyreq;
                    modpl.PlanFirmSt   = "PLAN";
                    _dbContext.TSPlannings.Add(modpl);
                    _dbContext.SaveChanges();
                }
                catch {}
                try{
                    var query = (from ml in _dbContext.TMLocations
                                 join lo in _dbContext.TLocations on ml.MLocLodId equals lo.LocId
                                 where lo.LocType == "TRAN" && ml.MLocMatId == _idmat
                                 select ml.MLocId).ToList();
                    int _locId = query[0];
                    var modlo  = _dbContext.TMLocations
                                 .SingleOrDefault(u => u.MLocId.Equals(_locId));
                    modlo.MLocStock += qtyreq;
                    _dbContext.TMLocations.Update(modlo);
                    _dbContext.SaveChanges();
                }
                catch {}
            }
        }
Ejemplo n.º 3
0
 public IActionResult PlanCreate(TSPlanning planning, int Pid, int prod, string actionType)
 {
     if (actionType == "Add")
     {
         if (ModelState.IsValid)
         {
             try{
                 _dbContext.TSPlannings.Add(planning);
                 _dbContext.SaveChanges();
             }
             catch { return(View("Error")); }
         }
         else
         {
             CreateViewBags(Pid, planning.PlanProdId);
             return(View(planning));
         }
     }
     CreateViewBags(Pid, planning.PlanProdId);
     ViewData["panel"] = 3;
     return(RedirectToAction("Edit", new{ id = Pid, panel = 3, move = 0, prod = planning.PlanProdId }));
 }