public ActionResult Details(int RequisitionMasId) { ViewBag.RequisitionMasId = RequisitionMasId; var newProj = (from procRequisitionMas in db.Proc_RequisitionMas join procProject in db.ProcProject on procRequisitionMas.ProcProjectId equals procProject.Id join site in db.ProjectSite on procProject.ProjectSiteId equals site.Id join project in db.Project on site.ProjectId equals project.Id where procRequisitionMas.Id == RequisitionMasId select project).SingleOrDefault(); //foreach (var i in newProj) //{ // ViewBag.ProjectId = i.Id; // ViewBag.ProjectName = i.Name; //} ViewBag.ProjectId = newProj.Id; ViewBag.ProjectName = newProj.Name; var projectResources = db.ProjectResource.SingleOrDefault(x => x.ProjectId == newProj.Id); ViewBag.ProjectManager = NullHelper.ObjectToString(projectResources.CompanyResource.Name); var newSite = (from procRequisitionMas in db.Proc_RequisitionMas join procProject in db.ProcProject on procRequisitionMas.ProcProjectId equals procProject.Id join site in db.ProjectSite on procProject.ProjectSiteId equals site.Id where procRequisitionMas.Id == RequisitionMasId select site).SingleOrDefault(); //foreach (var i in newSite) //{ // ViewBag.SiteId = i.Id; // ViewBag.SiteName = i.Name; //} ViewBag.SiteId = newSite.Id; ViewBag.SiteName = newSite.Name; var projectSiteResources = db.ProjectSiteResource.SingleOrDefault(x => x.ProjectSiteId == newSite.Id); ViewBag.SiteEngineer = NullHelper.ObjectToString(projectSiteResources.CompanyResource.Name); var master = db.Proc_RequisitionMas.SingleOrDefault(x => x.Id == RequisitionMasId); ViewBag.ItemName = new SelectList(db.Item, "Id", "Name"); ViewBag.Unit = new SelectList(db.Unit, "Id", "Name"); var Req = db.Proc_RequisitionMas.SingleOrDefault(x => x.Id == RequisitionMasId); VMRequisitionMasterDetail vm = new VMRequisitionMasterDetail(); vm.requisitionMaster = db.Proc_RequisitionMas.SingleOrDefault(x => x.Id == RequisitionMasId); var Details = db.Proc_RequisitionDet.Where(x => x.Proc_RequisitionMasId == RequisitionMasId).ToList(); List <Proc_RequisitionDet> dt = new List <Proc_RequisitionDet>(); foreach (var detail in Details) { dt.Add(detail); } vm.requisitionDetail = dt; return(View(vm)); }
public ActionResult Edit(int RequisitionMasId) { ViewBag.RequisitionMasId = RequisitionMasId; var newProj = (from procRequisitionMas in db.Proc_RequisitionMas join procProject in db.ProcProject on procRequisitionMas.ProcProjectId equals procProject.Id join site in db.ProjectSite on procProject.ProjectSiteId equals site.Id join project in db.Project on site.ProjectId equals project.Id where procRequisitionMas.Id == RequisitionMasId select project).FirstOrDefault(); ViewBag.ProjectId = newProj.Id; ViewBag.ProjectName = newProj.Name; var projectResources = db.ProjectResource.SingleOrDefault(x => x.ProjectId == newProj.Id); ViewBag.ProjectManager = NullHelper.ObjectToString(projectResources.CompanyResource.Name); var newSite = (from procRequisitionMas in db.Proc_RequisitionMas join procProject in db.ProcProject on procRequisitionMas.ProcProjectId equals procProject.Id join site in db.ProjectSite on procProject.ProjectSiteId equals site.Id where procRequisitionMas.Id == RequisitionMasId select site).FirstOrDefault(); ViewBag.SiteId = newSite.Id; ViewBag.SiteName = newSite.Name; var projectSiteResources = db.ProjectSiteResource.SingleOrDefault(x => x.ProjectSiteId == newSite.Id); ViewBag.SiteEngineer = NullHelper.ObjectToString(projectSiteResources.CompanyResource.Name); var master = db.Proc_RequisitionMas.SingleOrDefault(x => x.Id == RequisitionMasId); List <SelectListItem> ItemList = new List <SelectListItem>(); var items = (from procProjectItem in db.ProcProjectItem join procproject in db.ProcProject on procProjectItem.ProcProjectId equals procproject.Id join site in db.ProjectSite on procproject.ProjectSiteId equals site.Id join project in db.Project on site.ProjectId equals project.Id where project.Id == newProj.Id && site.Id == newSite.Id select procProjectItem).ToList(); foreach (var x in items) { var itemName = db.Item.SingleOrDefault(m => m.Id == x.ItemId); ItemList.Add(new SelectListItem { Text = itemName.Name, Value = x.ItemId.ToString() }); } ViewBag.ItemName = ItemList; //ViewBag.ItemName = new SelectList(db.Item, "Id", "Name"); ViewBag.Unit = new SelectList(db.Unit, "Id", "Name"); var Req = db.Proc_RequisitionMas.SingleOrDefault(x => x.Id == RequisitionMasId); VMRequisitionMasterDetail vm = new VMRequisitionMasterDetail(); vm.requisitionMaster = db.Proc_RequisitionMas.SingleOrDefault(x => x.Id == RequisitionMasId); var Details = db.Proc_RequisitionDet.Where(x => x.Proc_RequisitionMasId == RequisitionMasId).ToList(); List <Proc_RequisitionDet> dt = new List <Proc_RequisitionDet>(); foreach (var detail in Details) { dt.Add(detail); } vm.requisitionDetail = dt; return(View(vm)); }