public FreeSIPC getSIPCLists(int reqId, int CommodityID)
        {
            var hubId = _hubAllocationService.GetAllocatedHubId(reqId);
            List <LedgerService.AvailableShippingCodes> freeSICodes = _ledgerService.GetFreeSICodesByCommodity(hubId, CommodityID);
            List <LedgerService.AvailableProjectCodes>  freePCCodes = _ledgerService.GetFreePCCodesByCommodity(hubId, CommodityID);
            FreeSIPC free = new FreeSIPC {
                FreePCCodes = freePCCodes, FreeSICodes = freeSICodes
            };

            return(free);
        }
        public ActionResult Assign(int reqId, double remaining, double totalAssigned)
        {
            var previousModelState = TempData["ModelState"] as ModelStateDictionary;

            if (previousModelState != null)
            {
                foreach (KeyValuePair <string, ModelState> kvp in previousModelState)
                {
                    if (!ModelState.ContainsKey(kvp.Key))
                    {
                        ModelState.Add(kvp.Key, kvp.Value);
                    }
                }
            }

            var hubId = _hubAllocationService.GetAllocatedHubId(reqId);
            ReliefRequisition listOfRequsitions = _requisitionService.Get(r => r.RequisitionID == reqId).SingleOrDefault();

            List <LedgerService.AvailableShippingCodes> freeSICodes = _ledgerService.GetFreeSICodesByCommodity(hubId, (int)listOfRequsitions.CommodityID);
            List <LedgerService.AvailableProjectCodes>  freePCCodes = _ledgerService.GetFreePCCodesByCommodity(hubId, (int)listOfRequsitions.CommodityID);

            ViewBag.FreeSICodes = freeSICodes;
            ViewBag.FreePCCodes = freePCCodes;
            ViewBag.SI          = new SelectList(freeSICodes, "siCodeId", "SIcode");
            ViewBag.PC          = new SelectList(freePCCodes, "pcCodeId", "PCcode");



            // ViewBag.SI = new SelectList(_shippingInstructionService.GetAllShippingInstruction(), "ShippingInstructionID", "Value");
            ViewBag.Total = totalAssigned;
            //ViewBag.PC = new SelectList(_projectCodeService.GetAllProjectCode(), "ProjectCodeID", "Value");
            ViewBag.RequetedAmount = Math.Round(listOfRequsitions.ReliefRequisitionDetails.Sum(a => a.Amount));
            ViewBag.Hub            = _hubAllocationService.GetAllocatedHub(reqId);
            ViewBag.ReqId          = listOfRequsitions.RequisitionID;
            ViewBag.Remaining      = Math.Round(remaining);
            return(View());
        }
Exemple #3
0
        public ActionResult PrintSummary(int id)
        {
            var reportPath = Server.MapPath("~/Report/Logisitcs/TransportRequisitionSummary.rdlc");
            var transportR = _transportRequisitionService.FindBy(t => t.TransportRequisitionID == id);

            var transportRequisitonViewModel = new TransportRequisitionViewModel();
            var headerInfo = new List <TransportRequisitionViewModel>();

            headerInfo.Add(transportRequisitonViewModel);

            var datePref             = _userAccountService.GetUserInfo(HttpContext.User.Identity.Name).DatePreference;
            var statuses             = _workflowStatusService.GetStatus(WORKFLOW.TRANSPORT_REQUISITION);
            var users                = _userAccountService.GetUsers();
            var transportRequisition = _transportRequisitionService.FindById(id);

            transportRequisitonViewModel = TransportRequisitionViewModelBinder.
                                           BindTransportRequisitionViewModel(
                transportRequisition,
                statuses,
                datePref,
                users
                );

            //transportRequisitonViewModel.TransportRequisitionDetailViewModels = GetDetail(transportRequisition.TransportRequisitionDetails.ToList());
            //var transportRequisition = _transportRequisitionService.FindById(id);

            var details = GetDetail(transportRequisition.TransportRequisitionDetails.ToList());
            var header  = (from requisition in headerInfo
                           select new
            {
                //TransportRequisitionID=requisition.TransportRequisitionNo,
                //requisition.Remark,
                //DateRequested=requisition.RequestedDate,
                //DateRecieved = requisition.CertifiedDate,
                //requisition.RequestedBy,
                //requisition.CertifiedBy
                requisition.TransportRequisitionNo,
                requisition.Remark,
                DateRequested = requisition.RequestedDate,
                DateRecieved = requisition.CertifiedDate,
                RequestedBy = requisition.RequestedBy,
                CertifiedBy = requisition.CertifiedBy
            });


            var requisitionsSummary =
                (from transportRequisitionDetail in details
                 select new
            {
                Commodity = transportRequisitionDetail.CommodityName,
                RequisitionNumber = transportRequisitionDetail.RequisitionNo,
                Amount = transportRequisitionDetail.QuanityInQtl,
                Warehouse = transportRequisitionDetail.OrignWarehouse,
                Region = transportRequisitionDetail.Region,
                Zone = transportRequisitionDetail.Zone,
                Program = transportRequisitionDetail.Program,
                Donor = "WFP",
                transportRequisitionDetail.RequisitionID,
                fromSIPC = (from projectCodeAllocation in _projectCodeAllocationService.FindBy(p => p.HubAllocationID == _hubAllocationService.GetAllocatedHubId(transportRequisitionDetail.RequisitionID))
                            select new
                {
                    CommodityName = transportRequisitionDetail.CommodityName,
                    fromSIPC = projectCodeAllocation.Amount_FromSI,
                    //fromSIPCKEy = projectCodeAllocation.ProjectCodeAllocationID
                }
                            )
            }
                );

            var detailsT =
                (
                    from requisition in requisitionsSummary
                    select requisition.fromSIPC
                );

            //foreach (var detail in details)
            //{
            //    var hubAllocationID = _hubAllocationService.GetAllocatedHubId(detail.RequisitionID);
            //    var projectCodeAllocations = _projectCodeAllocationService.FindBy(p=>p.HubAllocationID==hubAllocationID);
            //    var ds = from projectCodeAllocation in projectCodeAllocations
            //             select new
            //             {
            //                 CommodityName = detail.CommodityName,
            //                 fromSIPC = projectCodeAllocation.Amount_FromSI,
            //                 fromSIPCKEy = projectCodeAllocation.ProjectCodeAllocationID
            //             }
            //}

            /*
             * var detail =
             *    (from projectCodeAllocation in _projectCodeAllocationService.FindBy(
             *             p =>
             *             p.HubAllocationID ==
             *             _hubAllocationService.GetAllocatedHubId(transportRequisitionDetail.RequisitionID))
             *     select new
             *         {
             *             CommodityName = transportRequisitionDetail.CommodityName,
             *             fromSIPC = projectCodeAllocation.Amount_FromSI,
             *             fromSIPCKEy = projectCodeAllocation.ProjectCodeAllocationID
             *         }
             *    );
             *
             * //var data = (from requisition in transportRequisition
             * //            select new
             * //                {
             * //                    requisition.TransportRequisitionID,
             * //                    requisition.Remark,
             * //                    requisition.RequestedDate,
             * //                    requisition.CertifiedDate,
             * //                    requisition.RequestedBy,
             * //                    requisition.CertifiedBy,
             * //                    requisitionsSummary = (from transportRequisitionDetail in GetDetail(requisition.TransportRequisitionDetails.ToList())
             * //                                           select new
             * //                                               {
             * //                                                   Commodity = transportRequisitionDetail.CommodityName,
             * //                                                   RequisitionNumber = transportRequisitionDetail.RequisitionNo,
             * //                                                   Amount = transportRequisitionDetail.QuanityInQtl,
             * //                                                   Warehouse = transportRequisitionDetail.OrignWarehouse,
             * //                                                   Region = transportRequisitionDetail.Region,
             * //                                                   Zone = transportRequisitionDetail.Zone,
             * //                                                   Donor = "WFP",
             * //                                                   RecievedDate = DateTime.Now,
             * //                                                   DateofRequisition = DateTime.Now,
             * //                                                   fromSIPC = (from projectCodeAllocation in _projectCodeAllocationService.FindBy(p => p.HubAllocationID == _hubAllocationService.GetAllocatedHubId(transportRequisitionDetail.RequisitionID))
             * //                                                               select new
             * //                                                                   {
             * //                                                                       CommodityName = transportRequisitionDetail.CommodityName,
             * //                                                                       fromSIPC = projectCodeAllocation.Amount_FromSI,
             * //                                                                       fromSIPCKEy = projectCodeAllocation.ProjectCodeAllocationID
             * //                                                                   }
             * //                                                              )
             * //                                               }
             * //                                          )
             *
             * //                }
             * //           );
             *
             *
             *
             * var reportData = (from detail in details
             *                  select new
             *                  {
             *                      Commodity = detail.CommodityName,
             *                      RequisitionNumber = detail.RequisitionNo,
             *                      Amount = detail.QuanityInQtl,
             *                      Warehouse = detail.OrignWarehouse,
             *                      Region = detail.Region,
             *                      Zone= detail.Zone,
             *                      Donor = "WFP",
             *                      RecievedDate= DateTime.Now,
             *                      DateofRequisition = DateTime.Now,
             *                      Remark = transportRequisition.Remark,
             *                      RequestedBy = transportRequisition.RequestedBy,
             *                      CertifiedBy = transportRequisition.CertifiedBy,
             *                      //fromSIPCAllocations = detail.
             *                  });*/

            //var dataSourceName = "RequisitionsSummary";
            //var dataSourceName2 = "Header";
            //var dataSourceName3 = "details";

            var dataSources = new string[3];

            // dataSources[0] = "";
            dataSources[0] = "Header";
            dataSources[1] = "RequisitionsSummary";
            dataSources[2] = "details";

            var reportData = new IEnumerable[3];

            reportData[0] = new Collection <TransportRequisitionViewModel> {
                transportRequisitonViewModel
            };
            reportData[1] = requisitionsSummary;
            reportData[2] = detailsT;

            var result = ReportHelper.PrintReport(reportPath, reportData, dataSources);

            return(File(result.RenderBytes, result.MimeType));
        }