public List <BundleViewModel> Match(List <Bundle> bundle) { PackageNumberBL _packageNumberService = new PackageNumberBL(); List <BundleViewModel> _results = new List <BundleViewModel>(); ShipmentBL shipment = new ShipmentBL(); //UserBL _userService = new UserBL(); UserStore _userService = new UserStore(); foreach (Bundle _bundle in bundle) { BundleViewModel model = new BundleViewModel(); string _airwaybill = ""; try { _airwaybill = _packageNumberService.FilterActive().Find(x => x.PackageNo == _bundle.Cargo).Shipment.AirwayBillNo; }catch (Exception) { continue; } BundleViewModel isExist = _results.Find(x => x.AirwayBillNo == _airwaybill); if (isExist != null) { isExist.Qty++; //_results.Add(isExist); } else { model.AirwayBillNo = _airwaybill; List <Shipment> list = shipment.FilterActive().Where(x => x.AirwayBillNo == _airwaybill).ToList(); foreach (Shipment ship in list) { model.Shipper = ship.Shipper.FullName; model.Consignee = ship.Consignee.FullName; model.Address = ship.Consignee.Address1; model.CommodityType = ship.Commodity.CommodityType.CommodityTypeName; model.Commodity = ship.Commodity.CommodityName; model.Qty++; model.AGW += ship.Weight; model.ServiceMode = ship.ServiceMode.ServiceModeName; model.PaymendMode = ship.PaymentMode.PaymentModeName; model.Area = ship.OriginCity.CityName; model.CreatedDate = ship.CreatedDate; model.Destination = ship.DestinationCity.CityName; model.BSO = ship.OriginCity.CityName; } model.SackNo = _bundle.SackNo; model.BCO = _bundle.BranchCorpOffice.BranchCorpOfficeName; //model.Scannedby = AppUser.User.Employee.FullName; model.Scannedby = "N/A"; //string employee = _userService.FilterActive().Find(x => x.UserId == _bundle.CreatedBy).Employee.FullName; string employee = _userService.FindById(_bundle.CreatedBy).Employee.FullName; if (employee != "") { model.Scannedby = employee; } _results.Add(model); } } return(_results); }
//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); }
public DataTable getPickUpCargoData(DateTime date) { //GET LIST ShipmentBL _shipmentService = new ShipmentBL(); List <Shipment> _shipments = _shipmentService.FilterActive().Where(x => x.Booking.BookingStatus.BookingStatusName == "Picked-up" && x.AcceptedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && (x.CreatedDate).ToShortDateString() == date.ToShortDateString()).ToList(); List <PickupCargoManifestViewModel> modelList = Match(_shipments).OrderByDescending(x => x.AirwayBillNo).Distinct().ToList(); DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("No", typeof(string))); dt.Columns.Add(new DataColumn("AWB", typeof(string))); dt.Columns.Add(new DataColumn("Shipper", typeof(string))); dt.Columns.Add(new DataColumn("Shipper Address", typeof(string))); dt.Columns.Add(new DataColumn("Consignee", typeof(string))); dt.Columns.Add(new DataColumn("Consignee Address", typeof(string))); dt.Columns.Add(new DataColumn("Commodity", typeof(string))); dt.Columns.Add(new DataColumn("QTY", typeof(string))); dt.Columns.Add(new DataColumn("AGW", typeof(string))); dt.Columns.Add(new DataColumn("Service Mode", typeof(string))); dt.Columns.Add(new DataColumn("Payment Mode", typeof(string))); dt.Columns.Add(new DataColumn("Amount", typeof(string))); dt.Columns.Add(new DataColumn("Area", typeof(string))); dt.Columns.Add(new DataColumn("Driver", typeof(string))); dt.Columns.Add(new DataColumn("Checker", typeof(string))); dt.Columns.Add(new DataColumn("ScannedBy", typeof(string))); dt.BeginLoadData(); int ctr = 1; foreach (PickupCargoManifestViewModel item in modelList) { DataRow row = dt.NewRow(); row[0] = (ctr++).ToString(); row[1] = item.AirwayBillNo; row[2] = item.Shipper; row[3] = item.ShipperAddress; row[4] = item.Consignee; row[5] = item.ConsigneeAddress; row[6] = item.Commodity; row[7] = item.QTY.ToString(); row[8] = item.AGW.ToString(); row[9] = item.ServiceMode; row[10] = item.PaymentMode; row[11] = item.Amount; row[12] = item.Area; row[13] = item.Driver; row[14] = item.Checker; row[15] = item.ScannedBy; dt.Rows.Add(row); } dt.EndLoadData(); return(dt); }
//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); }
public List <GatewayTransmitalViewModel> Match(List <GatewayTransmittal> _transmital) { List <GatewayTransmitalViewModel> _results = new List <GatewayTransmitalViewModel>(); CommodityBL commodityService = new CommodityBL(); GatewayTransmittalBL transmitalService = new GatewayTransmittalBL(); ShipmentBL shipmentService = new ShipmentBL(); PackageNumberBL _packageNumberService = new PackageNumberBL(); BundleBL bundleService = new BundleBL(); UserStore _userService = new UserStore(); foreach (GatewayTransmittal transmital in _transmital) { GatewayTransmitalViewModel model = new GatewayTransmitalViewModel(); Shipment _shipment = new Shipment(); string _airwaybill = ""; //List<string> listCargo = new List<string>(); //List<string> listAirwayBill = new List<string>(); List <Tuple <string, decimal> > listofSack = new List <Tuple <string, decimal> >(); int numberOfCargo = 0; decimal WeightOfCargo = 0; decimal totalWeightOfCargo = 0; _shipment = shipmentService.FilterActive().Where(x => x.AirwayBillNo == transmital.AirwayBillNo).FirstOrDefault(); // _shipment = shipmentService.FilterActive().Where(x => x.AirwayBillNo == transmital.AirwayBillNo && x.Booking.BookedBy.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId).FirstOrDefault(); if (_shipment == null) { listofSack = bundleService.FilterActive().Where(x => x.SackNo == transmital.AirwayBillNo).Select(x => new Tuple <string, decimal>(x.Cargo, x.Weight)).ToList(); if (listofSack != null) { for (int i = 0; i < listofSack.Count; i++) { WeightOfCargo = listofSack[i].Item2; totalWeightOfCargo += WeightOfCargo; numberOfCargo++; } GatewayTransmitalViewModel model1 = new GatewayTransmitalViewModel(); GatewayTransmitalViewModel isExistSackNo = _results.Find(x => x.AirwayBillNo == transmital.AirwayBillNo); if (isExistSackNo != null) { isExistSackNo.QTY++; isExistSackNo.AGW += Convert.ToDecimal(totalWeightOfCargo); } else { model1.AirwayBillNo = transmital.AirwayBillNo; model1.Shipper = "N/A"; model1.Consignee = "N/A"; model1.Address = "N/A"; model1.CommodityType = transmital.CommodityType.CommodityTypeName; model1.Commodity = "N/A"; model1.QTY = listofSack.Count; model1.AGW = Convert.ToDecimal(totalWeightOfCargo); model1.ServiceMode = "N/A"; model1.PaymentMode = "N/A"; model1.Gateway = transmital.Gateway; model1.Destination = transmital.BranchCorpOffice.BranchCorpOfficeName; model1.Batch = transmital.Batch.BatchName; model1.CreatedDate = transmital.CreatedDate; model1.PlateNo = transmital.PlateNo; model1.MAWB = transmital.MasterAirwayBillNo; //model1.ScannedBy = AppUser.User.Employee.FullName; model1.ScannedBy = "N/A"; //string employee = _userService.FilterActive().Find(x => x.UserId == _bundle.CreatedBy).Employee.FullName; string employee = _userService.FindById(transmital.CreatedBy).Employee.FullName; if (employee != "") { model1.ScannedBy = employee; } _results.Add(model1); } } } else { _airwaybill = _shipment.AirwayBillNo; GatewayTransmitalViewModel isExist = _results.Find(x => x.AirwayBillNo == _airwaybill); if (isExist != null) { isExist.QTY++; isExist.AGW += Convert.ToDecimal(shipmentService.FilterActive().Find(x => x.AirwayBillNo == transmital.AirwayBillNo).Weight); } else { model.AirwayBillNo = transmital.AirwayBillNo; model.Shipper = _shipment.Shipper.FullName; model.Consignee = _shipment.Consignee.FullName; model.Address = _shipment.Consignee.Address1; model.CommodityType = transmital.CommodityType.CommodityTypeName; model.Commodity = _shipment.Commodity.CommodityName; model.QTY++; model.AGW = _shipment.Weight; model.ServiceMode = _shipment.ServiceMode.ServiceModeName; model.PaymentMode = _shipment.PaymentMode.PaymentModeName; model.Gateway = transmital.Gateway; model.Destination = transmital.BranchCorpOffice.BranchCorpOfficeName; model.Batch = transmital.Batch.BatchName; model.CreatedDate = transmital.CreatedDate; model.PlateNo = transmital.PlateNo; model.MAWB = transmital.MasterAirwayBillNo; //model.ScannedBy = AppUser.User.Employee.FullName; model.ScannedBy = "N/A"; //string employee = _userService.FilterActive().Find(x => x.UserId == _bundle.CreatedBy).Employee.FullName; string employee = _userService.FindById(transmital.CreatedBy).Employee.FullName; if (employee != "") { model.ScannedBy = employee; } _results.Add(model); } } } return(_results); }