Esempio n. 1
0
        //Filter By BCOID and Driver and ALl batch
        public DataTable getBranchAcceptanceData1(DateTime date, Guid revenueUnitId, string driver)
        {
            BranchAcceptanceBL branchAcceptanceBl = new BranchAcceptanceBL();
            ShipmentBL         shipmentService    = new ShipmentBL();
            //List<Shipment> shipments = shipmentService.FilterActive().Where(x => x.AcceptedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();
            //List<BranchAcceptance> branchAcceptance = branchAcceptanceBl.GetAll().Where(x => x.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.BatchID == batchId).ToList();
            List <Shipment> shipments = shipmentService.FilterActive().Where(x => x.AcceptedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.Booking.BookingStatus.BookingStatusName == "Picked-up").ToList();

            //List<BranchAcceptance> branchAcceptance = branchAcceptanceBl.GetAll().Where(x => x.RecordStatus == 1 && x.Users.Employee.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.Users.Employee.AssignedToArea.RevenueUnitId == revenueUnitId && x.Driver == driver && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).Distinct().ToList();
            List <BranchAcceptance>          branchAcceptance = branchAcceptanceBl.FilterActive().Where(x => x.RecordStatus == 1 && x.Users.Employee.AssignedToArea.RevenueUnitId == revenueUnitId && x.Driver == driver && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).Distinct().ToList();
            List <BranchAcceptanceViewModel> list             = Match(branchAcceptance, shipments).FindAll(x => x.Area != "N/A" && !x.Area.Contains("Walk-in"));

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("No", typeof(string)));
            dt.Columns.Add(new DataColumn("Area/Branch", typeof(string)));
            dt.Columns.Add(new DataColumn("Driver", typeof(string)));
            dt.Columns.Add(new DataColumn("Checker", typeof(string)));
            dt.Columns.Add(new DataColumn("Plate #", typeof(string)));
            dt.Columns.Add(new DataColumn("Batch", typeof(string)));
            dt.Columns.Add(new DataColumn("AWB", typeof(string)));
            dt.Columns.Add(new DataColumn("Recieved(Qty)", typeof(string)));
            dt.Columns.Add(new DataColumn("Discrepancy(Qty)", typeof(string)));
            dt.Columns.Add(new DataColumn("Total Qty", typeof(string)));
            dt.Columns.Add(new DataColumn("BCO", typeof(string)));
            dt.Columns.Add(new DataColumn("BSO", typeof(string)));

            dt.Columns.Add(new DataColumn("ScannedBy", typeof(string)));
            dt.Columns.Add(new DataColumn("Remarks", typeof(string)));
            dt.Columns.Add(new DataColumn("Notes", typeof(string)));
            dt.BeginLoadData();
            int ctr = 1;

            foreach (BranchAcceptanceViewModel item in list.Distinct())
            {
                DataRow row = dt.NewRow();
                row[0] = ctr++.ToString();
                row[1] = item.Area.ToString();
                row[2] = item.Driver.ToString();
                row[3] = item.Checker.ToString();
                row[4] = item.PlateNo.ToString();
                row[5] = item.Batch.ToString();
                row[6] = item.AirwayBillNo.ToString();
                row[7] = item.TotalRecieved.ToString();
                row[8] = item.TotalDiscrepency.ToString();
                row[9] = item.Total.ToString();

                row[10] = item.BCO;
                row[11] = item.BSO;
                row[12] = item.ScannedBy;
                row[13] = item.Remarks;
                row[14] = item.Notes;
                dt.Rows.Add(row);
            }
            dt.EndLoadData();

            return(dt);
        }
Esempio n. 2
0
        public List <PickupCargoManifestViewModel> Match(List <Shipment> _shipment)
        {
            BranchAcceptanceBL branchAcceptanceBL        = new BranchAcceptanceBL();
            PackageNumberBL    _packageNumberService     = new PackageNumberBL();
            List <PickupCargoManifestViewModel> _results = new List <PickupCargoManifestViewModel>();

            List <PackageNumber> packageList = new List <PackageNumber>();
            int numberOfPackage = 0;

            foreach (Shipment shipment  in _shipment)
            {
                PickupCargoManifestViewModel model = new PickupCargoManifestViewModel();
                try {
                    packageList     = _packageNumberService.FilterActive().Where(x => x.ShipmentId == shipment.ShipmentId).Distinct().ToList();
                    numberOfPackage = packageList.Count;
                }
                catch (Exception) { continue; }
                foreach (PackageNumber number in packageList)
                {
                    List <BranchAcceptance> branchList = branchAcceptanceBL.FilterActive().Where(x => x.Cargo == number.PackageNo).Distinct().ToList();
                    foreach (BranchAcceptance branch in branchList)
                    {
                        model.Driver  = (branch.Driver != null || branch.Driver != "") ? branch.Driver : "N/A";
                        model.Checker = (branch.Checker != null || branch.Checker != "") ? branch.Checker : "N/A";
                    }
                }
                PickupCargoManifestViewModel isExist = _results.Find(x => x.AirwayBillNo == shipment.AirwayBillNo);

                if (isExist != null)
                {
                    isExist.QTY++;
                }
                else
                {
                    model.AirwayBillNo = shipment.AirwayBillNo;
                    model.Shipper      = shipment.Shipper.FullName;
                    model.Consignee    = shipment.Consignee.FullName;

                    model.ConsigneeAddress = shipment.Consignee.Address1 + " " + shipment.Consignee.Address2;
                    model.ShipperAddress   = shipment.Shipper.Address1 + " " + shipment.Shipper.Address2;
                    model.Commodity        = shipment.Commodity.CommodityName;
                    // model.QTY++;
                    model.QTY         = numberOfPackage;
                    model.AGW        += shipment.Weight;
                    model.ServiceMode = shipment.ServiceMode.ServiceModeName;
                    model.PaymentMode = shipment.PaymentMode.PaymentModeName;
                    model.Amount      = shipment.TotalAmount.ToString();
                    model.ScannedBy   = shipment.AcceptedBy.FullName;
                    try
                    {
                        model.Area = (shipment.Booking.AssignedToArea != null) ? shipment.Booking.AssignedToArea.City.CityName : "N/A";
                    }
                    catch (Exception)
                    {
                        model.Area = "N/A";
                    }
                    _results.Add(model);
                }
            }

            return(_results);
        }
Esempio n. 3
0
        //Complete Filter
        public DataTable getBranchAcceptanceDataByFilter(DateTime date, Guid?revenueUnitId, string driver, Guid?batchId)
        {
            RevenueUnitBL      revenueunitservice = new RevenueUnitBL();
            BatchBL            batchservice       = new BatchBL();
            BranchAcceptanceBL branchAcceptanceBl = new BranchAcceptanceBL();
            ShipmentBL         shipmentService    = new ShipmentBL();
            BranchCorpOfficeBL bcoService         = new BranchCorpOfficeBL();

            //List<Shipment> shipments = shipmentService.FilterActive().Where(x => x.AcceptedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();
            List <Shipment> shipments = shipmentService.FilterActive().Where(x => x.AcceptedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.Booking.BookingStatus.BookingStatusName == "Picked-up" && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();
            // List<BranchAcceptance> branchAcceptance = branchAcceptanceBl.GetAll().Where(x => x.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.BatchID == batchId && x.Driver == driver).ToList();
            //List<BranchAcceptance> branchAcceptance = branchAcceptanceBl.GetAll().Where(x => x.Users.Employee.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.Users.Employee.AssignedToArea.RevenueUnitId == revenueUnitId && x.RecordStatus == 1 && x.BatchID == batchId && x.Driver == driver && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();

            List <BranchAcceptanceViewModel> list             = new List <BranchAcceptanceViewModel>();
            List <BranchAcceptance>          branchAcceptance = branchAcceptanceBl.FilterActive().
                                                                Where(
                x => x.RecordStatus == 1
                //&& ((x.Users.Employee.AssignedToArea.RevenueUnitId == revenueUnitId && x.Users.Employee.AssignedToArea.RevenueUnitId != Guid.Empty) || (x.Users.Employee.AssignedToArea.RevenueUnitId == x.Users.Employee.AssignedToArea.RevenueUnitId && revenueUnitId == Guid.Empty))
                && ((x.BatchID == batchId && x.BatchID != Guid.Empty) || (x.BatchID == x.BatchID && batchId == Guid.Empty)) &&
                ((x.Driver == driver && x.Driver != "All") || (x.Driver == x.Driver && driver == "All")) &&
                x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();

            string revenueunitname = "";
            string batchname       = "";
            string bcoName         = "";

            if (batchId != Guid.Empty)
            {
                batchname = batchservice.FilterActive().Find(x => x.BatchID == batchId).BatchName;
            }
            else
            {
                batchname = "All";
            }

            if (revenueUnitId != Guid.Empty)
            {
                revenueunitname = revenueunitservice.FilterActive().Find(x => x.RevenueUnitId == revenueUnitId).RevenueUnitName;
            }
            else
            {
                revenueunitname = "All";
            }

            bcoName = bcoService.FilterActive().Find(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).BranchCorpOfficeName;

            list = Match(branchAcceptance, shipments).
                   FindAll
                       (x =>
                       ((x.Area == revenueunitname && x.Area != "N/A") || (x.Area == x.Area && revenueunitname == "All")) &&
                       ((x.Driver == driver && x.Driver != "N/A") || (x.Driver == x.Driver && driver == "All")) &&
                       ((x.Batch == batchname && x.Batch != "N/A") || (x.Batch == x.Batch && batchname == "All")) &&
                       ((x.BCO == bcoName && x.BCO != "N/A") || (x.BCO == x.BCO && bcoName == "")) &&
                       !x.Area.Contains("Walk-in"));

            //if (revenueUnitId != Guid.Empty && batchId !=Guid.Empty)
            //{
            //    batchname = batchservice.GetAll().Find(x => x.BatchID == batchId).BatchName;
            //    revenueunitname = revenueunitservice.GetAll().Find(x => x.RevenueUnitId == revenueUnitId).RevenueUnitName;
            //    list = Match(branchAcceptance, shipments).FindAll(x => x.Area == revenueunitname && x.Batch == batchname);
            //}
            //else if (revenueUnitId == Guid.Empty && batchId != Guid.Empty)
            //{
            //    batchname = batchservice.GetAll().Find(x => x.BatchID == batchId).BatchName;
            //    list = Match(branchAcceptance, shipments).FindAll(x => x.Batch == batchname && x.Area != "N/A");
            //}
            //else if (revenueUnitId != Guid.Empty && batchId == Guid.Empty)
            //{
            //    revenueunitname = revenueunitservice.GetAll().Find(x => x.RevenueUnitId == revenueUnitId).RevenueUnitName;
            //    list = Match(branchAcceptance, shipments).FindAll(x => x.Area == revenueunitname);
            //}
            //else
            //{
            //    bcoName = bcoService.GetAll().Find(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).BranchCorpOfficeName;
            //    list = Match(branchAcceptance, shipments).FindAll(x => x.BCO == bcoName && x.Area != "N/A");
            //    //list = Match(branchAcceptance, shipments);
            //}

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("No", typeof(string)));
            dt.Columns.Add(new DataColumn("Area/Branch", typeof(string)));
            dt.Columns.Add(new DataColumn("Driver", typeof(string)));
            dt.Columns.Add(new DataColumn("Checker", typeof(string)));
            dt.Columns.Add(new DataColumn("Plate #", typeof(string)));
            dt.Columns.Add(new DataColumn("Batch", typeof(string)));
            dt.Columns.Add(new DataColumn("AWB", typeof(string)));
            dt.Columns.Add(new DataColumn("Recieved(Qty)", typeof(string)));
            dt.Columns.Add(new DataColumn("Discrepancy(Qty)", typeof(string)));
            dt.Columns.Add(new DataColumn("Total Qty", typeof(string)));
            dt.Columns.Add(new DataColumn("BCO", typeof(string)));
            dt.Columns.Add(new DataColumn("BSO", typeof(string)));

            dt.Columns.Add(new DataColumn("ScannedBy", typeof(string)));
            dt.Columns.Add(new DataColumn("Remarks", typeof(string)));
            dt.Columns.Add(new DataColumn("Notes", typeof(string)));
            dt.BeginLoadData();
            int ctr = 1;

            foreach (BranchAcceptanceViewModel item in list)
            {
                DataRow row = dt.NewRow();
                row[0] = ctr++.ToString();
                row[1] = item.Area.ToString();
                row[2] = item.Driver.ToString();
                row[3] = item.Checker.ToString();
                row[4] = item.PlateNo.ToString();
                row[5] = item.Batch.ToString();
                row[6] = item.AirwayBillNo.ToString();
                row[7] = item.TotalRecieved.ToString();
                row[8] = item.TotalDiscrepency.ToString();
                row[9] = item.Total.ToString();

                row[10] = item.BCO;
                row[11] = item.BSO;
                row[12] = item.ScannedBy;
                row[13] = item.Remarks;
                row[14] = item.Notes;
                dt.Rows.Add(row);
            }
            dt.EndLoadData();

            return(dt);
        }