private DataTable GetDetailsTable(Guid orderId) { DataTable table = new DataTable(); var dbContext = new SCMSEntities(); IEnumerable <Model.OrderRequestItem> items = dbContext.OrderRequestItems.Where(i => i.OrderRequestId == orderId); table.Columns.Add("No.", typeof(string)); table.Columns.Add("Description", typeof(string)); table.Columns.Add("Unit", typeof(string)); table.Columns.Add("Qty", typeof(string)); table.Columns.Add("Estimated Price", typeof(string)); table.Columns.Add("Estimated Total Price", typeof(string)); table.Columns.Add("BL", typeof(string)); table.Columns.Add("PN", typeof(string)); table.Columns.Add("Remarks", typeof(string)); decimal total1 = 0; decimal total2 = 0; if (items != null) { int count = 1; foreach (Model.OrderRequestItem i in items) { Model.Item it = dbContext.Items.First(t => t.Id == i.ItemId); Model.UnitOfMeasure um = dbContext.UnitOfMeasures.First(m => m.Id == i.Item.UnitOfMeasure.Id); Model.ProjectBudget line = dbContext.ProjectBudgets.First(m => m.Id == i.BudgetLineId); Model.ProjectDonor pDonor = dbContext.ProjectDonors.First(m => m.Id == i.OrderRequest.ProjectDonorId); table.Rows.Add(count.ToString(), it.Name, um.Code, i.Quantity.ToString(), i.EstimatedUnitPrice.ToString("#,###.##"), i.EstimatedPrice.ToString("#,###.##"), line.LineNumber, pDonor.ProjectNumber, i.Remarks); count++; total1 += i.EstimatedPrice; total2 += i.EstimatedPrice; } table.Rows.Add("", "", "", "", "Total", total1.ToString("#,###.##"), "OR Value", "", ""); //Currency of Request table.Rows.Add("", "", "", "", "Total", total2.ToString("#,###.##"), "OR Value", "", ""); //Master Budget Currency } return(table); // Return reference. }
public static ViewWayBill prepareWB(Guid wbId) { using (var db = new SCMSEntities()) { WayBill entitymodel = db.WayBills.First(p => p.Id == wbId); ViewWayBill model = new ViewWayBill(); model.EntityWBill = entitymodel; WarehouseRelease wrn = model.EntityWBill.WarehouseRelease; model.issuer = db.VStaffDetails.FirstOrDefault(p => p.StaffID == entitymodel.PreparedBy); model.consignee = db.VStaffDetails.FirstOrDefault(p => p.StaffID == entitymodel.Consignee); model.ReceivedBy = db.VStaffDetails.FirstOrDefault(p => p.StaffID == entitymodel.ReceivedBy); model.OrrignWH = db.WareHouses.FirstOrDefault(p => p.Id == entitymodel.IssuerWarehouse); model.destinationWH = db.WareHouses.FirstOrDefault(p => p.Id == entitymodel.DestinationWarehouse); model.DestnationOfiice = db.CountrySubOffices.FirstOrDefault(p => p.Id == entitymodel.DestinationOffice); Model.Location loc = model.destinationWH.Location; Model.CountrySubOffice cso = model.destinationWH.CountrySubOffice; model.OrignSOfiice = db.CountrySubOffices.First(p => p.Id == entitymodel.IssuingOffice); Model.Location l = model.OrignSOfiice.Location; Model.Location lok = model.DestnationOfiice.Location; List <WarehouseReleaseItem> writems = entitymodel.WarehouseRelease.WarehouseReleaseItems.ToList(); foreach (WarehouseReleaseItem item in writems) { Model.Inventory inv = item.Inventory; Model.Item it = inv.Item; Model.ItemCategory ic = it.ItemCategory; Model.UnitOfMeasure u = it.UnitOfMeasure; Model.Asset ast = item.Asset; } model.WRItems = writems; //dummies var person = entitymodel.Staff.Person; if (entitymodel.Staff1 != null) { person = entitymodel.Staff1.Person; } return(model); } }
public ActionResult WBReceive() { using (var db = new SCMSEntities()) { WarehouseRelease wrn = db.WarehouseReleases.FirstOrDefault <WarehouseRelease>(); List <WarehouseReleaseItem> itmz = wrn != null?wrn.WarehouseReleaseItems.ToList() : new List <WarehouseReleaseItem>(); foreach (WarehouseReleaseItem item in itmz) { Model.Inventory iv = item.Inventory; Model.Item it = iv.Item; Model.ItemCategory itc = it.ItemCategory; Model.Asset ast = item.Asset; Model.UnitOfMeasure u = it.UnitOfMeasure; } //Use this to populate items on load for any changes in the stolen code //WayBill wb = db.WayBills.First(p => p.Id == new Guid("0D88562F-BBEC-4722-941B-91FC4D82BB1C")); //List<WarehouseReleaseItem> wrnn = db.WarehouseReleases.FirstOrDefault(p => p.Id == wb.WRNId).WarehouseReleaseItems.ToList(); //foreach (WarehouseReleaseItem item in wrnn) //{ // Model.Asset ass = item.Asset; // Model.Inventory iv = item.Inventory; // Model.Item it = iv.Item; // Model.ItemCategory ic = it.ItemCategory; // Model.UnitOfMeasure u = it.UnitOfMeasure; //} var model = new ReceiveWB() { EntityWBill = new WayBill(), IssuingOffice = new SelectList(WBService.GetSubOffices(countryProg.Id), "Id", "Name"), WBlist = new SelectList(WBService.GetWayBillsNotReceived(countryProg.Id), "Id", "RefNumber"), WRItems = new List <WarehouseReleaseItem>()//wrnn }; return(View(model)); } }