public IActionResult BLDCreate(int id, int Pid, string actionType) { CreateViewBags(Pid); TInputBLH mat = (from ma in _dbContext.TInputBLHs where ma.InBLId == Pid select ma).SingleOrDefault(); ViewData["panel"] = 1; VTBLDet queryco = (from ma in _dbContext.TInputBLHs join co in _dbContext.TInputBLDs on ma.InBLId equals co.InBLId into RefComp from pco in RefComp.DefaultIfEmpty() where ma.InBLId == Pid select new VTBLDet { InBLDId = 0, InBLId = Pid, //InBLDateRec=System.DateTime.Now, InBLDMatUnMed = "", InBLDMDescr = "", InBLDMRefer = "", //InBLDNum="", InBLDProdId = 0, InBLDQty = 0, InBLDStat = "", InBLDUM = 0, InBLDUMRef = "" }).Distinct().SingleOrDefault(); //ViewBag.ListMatComp=queryco; return(View((VTBLDet)queryco)); }
public IActionResult BLDCreate(VTBLDet routing, int id, string actionType) { routing.InBLId = id; ViewData["panel"] = 1; if (actionType == "Add") { if (ModelState.IsValid) { try{ TInputBLD nmod = new TInputBLD(); //nmod.InBLDId=routing.InBLDId, nmod.InBLId = id;//routing.InBLId; //nmod.InBLDateRec=routing.InBLDateRec; //nmod.InBLDMatUnMed=routing.InBLDMatUnMed; //nmod.InBLDMDescr=routing.InBLDMDescr; //nmod.InBLDMRefer=routing.InBLDMRefer; //nmod.InBLDNum=routing.InBLDNum; nmod.InBLDProdId = routing.InBLDProdId; nmod.InBLDQty = routing.InBLDQty; nmod.InBLDStat = routing.InBLDStat; nmod.InBLDUM = routing.InBLDUM; nmod.InBLDUMRef = routing.InBLDUMRef; _dbContext.TInputBLDs.Add(nmod); _dbContext.SaveChanges(); } catch (Exception ex) { string mensaje = ex.Message; return(View("Error")); } } else { CreateViewBags(id); return(View(routing)); } } else { if (actionType == "Cancel") { } else { try{ //cambia el material componente idicar la unidad de medida }catch {} CreateViewBags(id); return(View(routing)); } } //CreateViewBags(0,0); ViewData["panel"] = 1; return(RedirectToAction("BLHEdit", new{ id = id })); }
public IActionResult BLDEdit(int id, int?Hid, int pamen) { var mode = _dbContext.TInputBLDs .SingleOrDefault(u => u.InBLDId.Equals(id)); Hid = mode.InBLId; CreateViewBags(Hid); ViewData["panel"] = 1; try{ VTBLDet model = (from pl in _dbContext.TInputBLDs join p in _dbContext.TMaterials on pl.InBLDProdId equals p.MatId //orderby pl.InBLId where pl.InBLDId == id select new VTBLDet { InBLDId = pl.InBLDId, InBLId = pl.InBLId, //InBLDateRec=pl.InBLDateRec, InBLDMatUnMed = p.MatUnMed, InBLDMDescr = p.MatDescr, InBLDMRefer = p.MatRefer, //InBLDNum=pl.InBLDNum, InBLDProdId = pl.InBLDProdId, InBLDQty = pl.InBLDQty, InBLDStat = pl.InBLDStat, InBLDUM = pl.InBLDUM, InBLDUMRef = pl.InBLDUMRef }).SingleOrDefault(); /* * MId=model.RoRoMatId; * var mode = _dbContext.TMaterials * .SingleOrDefault(u => u.MatId.Equals(MId)); * ViewBag.Material=mode; */ return(View(model)); } catch { return(View("Error")); } }