public DataTable getBundleDataByFilter(DateTime date, Guid?bcoid, string sackNo, int num)
        {
            BundleBL bundleBl = new BundleBL();

            List <Bundle> list = new List <Bundle>();

            if (num == 0)
            {
                list = bundleBl.GetAll().Where(x => x.RecordStatus == 1 && x.SackNo == sackNo).ToList();
            }
            else if (num == 1)
            {
                list = bundleBl.GetAll().Where(x => x.RecordStatus == 1 && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();
            }
            else if (num == 2)
            {
                // list = bundleBl.GetAll().Where(x => x.RecordStatus == 1 && x.User.Employee.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == bcoid && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();
                list = bundleBl.GetAll().Where(x => x.RecordStatus == 1 && x.BranchCorpOfficeID == bcoid && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();
            }

            List <BundleViewModel> bundleList = Match(list);

            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("Consignee", typeof(string)));
            dt.Columns.Add(new DataColumn("Address", typeof(string)));
            dt.Columns.Add(new DataColumn("Commodity Type", 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("Area", typeof(string)));
            dt.Columns.Add(new DataColumn("SackNo", typeof(string)));

            dt.Columns.Add(new DataColumn("CreatedDate", typeof(string)));
            dt.Columns.Add(new DataColumn("Destination", 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.BeginLoadData();
            int ctr = 1;

            foreach (BundleViewModel item in bundleList)
            {
                DataRow row = dt.NewRow();
                row[0]  = "" + ctr++;
                row[1]  = item.AirwayBillNo;
                row[2]  = item.Shipper;
                row[3]  = item.Consignee;
                row[4]  = item.Address;
                row[5]  = item.CommodityType;
                row[6]  = item.Commodity;
                row[7]  = item.Qty.ToString();
                row[8]  = item.AGW.ToString();
                row[9]  = item.ServiceMode;
                row[10] = item.PaymendMode;
                row[11] = item.Area;
                row[12] = item.SackNo;
                row[13] = item.CreatedDate.ToShortDateString();
                row[14] = item.Destination;

                row[15] = item.BCO;
                row[16] = item.BSO;

                row[17] = item.Scannedby;
                dt.Rows.Add(row);
            }
            dt.EndLoadData();

            return(dt);
        }
        public List <GatewayInboundViewModel> Match(List <GatewayInbound> _inbound)
        {
            PackageNumberBL _packageNumberService   = new PackageNumberBL();
            List <GatewayInboundViewModel> _results = new List <GatewayInboundViewModel>();
            PackageNumber _packageNumber            = new PackageNumber();
            BundleBL      bundleService             = new BundleBL();
            List <string> listCargo    = new List <string>();
            UserStore     _userService = new UserStore();

            foreach (GatewayInbound inbound in _inbound)
            {
                GatewayInboundViewModel model = new GatewayInboundViewModel();
                string _airwaybill            = "";
                try {
                    // _airwaybill = _packageNumberService.GetAll().Find(x => x.PackageNo == inbound.Cargo).Shipment.AirwayBillNo;
                    _packageNumber = _packageNumberService.FilterActive().Where(x => x.PackageNo == inbound.Cargo).FirstOrDefault();
                    if (_packageNumber == null)
                    {
                        GatewayInboundViewModel model1 = new GatewayInboundViewModel();
                        listCargo = bundleService.GetAll().Where(x => x.SackNo == inbound.Cargo).Select(y => y.Cargo).ToList();
                        if (listCargo != null && listCargo.Count != 0)
                        {
                            GatewayInboundViewModel isExist = _results.Find(x => x.AirwayBillNo == inbound.Cargo);
                            if (isExist != null)
                            {
                                isExist.Pieces++;
                            }
                            else
                            {
                                model1.AirwayBillNo  = inbound.Cargo;
                                model1.Gateway       = inbound.Gateway;
                                model1.Origin        = inbound.BranchCorpOffice.BranchCorpOfficeName;
                                model1.Pieces        = listCargo.Count;
                                model1.MAWB          = inbound.MasterAirwayBill;
                                model1.FlightNo      = inbound.FlightNumber;
                                model1.CommodityType = inbound.CommodityType.CommodityTypeName;
                                model1.CreatedDate   = inbound.CreatedDate;
                                //model1.ScannedBy = AppUser.User.Employee.FullName;
                                model1.ScannedBy = "N/A";
                                string employee = _userService.FindById(inbound.CreatedBy).Employee.FullName;
                                if (employee != "")
                                {
                                    model1.ScannedBy = employee;
                                }
                                _results.Add(model1);
                            }
                        }
                    }
                    else
                    {
                        _airwaybill = _packageNumber.Shipment.AirwayBillNo;

                        GatewayInboundViewModel isExist = _results.Find(x => x.AirwayBillNo == _airwaybill);
                        if (isExist != null)
                        {
                            isExist.Pieces++;
                        }
                        else
                        {
                            model.AirwayBillNo = _airwaybill;
                            model.Gateway      = inbound.Gateway;
                            model.Origin       = inbound.BranchCorpOffice.BranchCorpOfficeName;
                            model.Pieces++;
                            model.MAWB          = inbound.MasterAirwayBill;
                            model.FlightNo      = inbound.FlightNumber;
                            model.CommodityType = inbound.CommodityType.CommodityTypeName;
                            model.CreatedDate   = inbound.CreatedDate;
                            //model.ScannedBy = AppUser.User.Employee.FullName;
                            model.ScannedBy = "N/A";
                            string employee = _userService.FindById(inbound.CreatedBy).Employee.FullName;
                            if (employee != "")
                            {
                                model.ScannedBy = employee;
                            }
                            _results.Add(model);
                        }
                    }
                }
                catch (Exception) { continue; }
            }


            return(_results);
        }
        public List <CargoTransferViewModel> Match(List <CargoTransfer> _cargoTransfers)
        {
            PackageNumberBL _packageNumberService = new PackageNumberBL();
            ShipmentBL      shipment = new ShipmentBL();
            List <CargoTransferViewModel> _results = new List <CargoTransferViewModel>();
            BundleBL      bundleService            = new BundleBL();
            PackageNumber _packageNumber           = new PackageNumber();
            List <string> listCargo    = new List <string>();
            UserStore     _userService = new UserStore();

            foreach (CargoTransfer cargoTransfer in _cargoTransfers)
            {
                CargoTransferViewModel model = new CargoTransferViewModel();
                string _airwaybill           = "";
                try {
                    // _airwaybill = _packageNumberService.GetAll().Find(x => x.PackageNo == cargoTransfer.Cargo).Shipment.AirwayBillNo;
                    _packageNumber = _packageNumberService.FilterActive().Where(x => x.PackageNo == cargoTransfer.Cargo).FirstOrDefault();
                    if (_packageNumber == null)
                    {
                        CargoTransferViewModel model1 = new CargoTransferViewModel();
                        listCargo = bundleService.GetAll().Where(x => x.SackNo == cargoTransfer.Cargo).Select(y => y.Cargo).ToList();
                        if (listCargo != null && listCargo.Count != 0)
                        {
                            CargoTransferViewModel isExist = _results.Find(x => x.AWB == cargoTransfer.Cargo);
                            if (isExist != null)
                            {
                                isExist.QTY++;
                                model.Pieces++;
                            }
                            else
                            {
                                //List<Shipment> list = shipment.GetAll().Where(x => x.AirwayBillNo.Equals(_airwaybill)).ToList();
                                //model1.Origin = _airwaybill;
                                //foreach (Shipment x in list)
                                //{
                                //    model1.Origin = x.OriginCity.CityName;
                                //    model1.Destination = x.DestinationCity.CityName;
                                //}
                                model1.Origin      = "N/A";
                                model1.Destination = "N/A";
                                model1.Driver      = cargoTransfer.Driver;
                                model1.Checker     = cargoTransfer.Checker;
                                model1.Pieces      = listCargo.Count;
                                model1.PlateNo     = cargoTransfer.PlateNo;
                                model1.Batch       = cargoTransfer.Batch.BatchName;
                                model1.AWB         = cargoTransfer.Cargo;
                                model1.QTY         = listCargo.Count;
                                model1.CreatedDate = cargoTransfer.CreatedDate;

                                model1.BCO       = cargoTransfer.BranchCorpOffice.BranchCorpOfficeName;
                                model1.GATEWAY   = cargoTransfer.RevenueUnit.RevenueUnitName;
                                model1.SATELLITE = cargoTransfer.RevenueUnit.RevenueUnitName;
                                //model1.ScannedBy = AppUser.User.Employee.FullName;
                                model1.ScannedBy = "N/A";
                                string employee = _userService.FindById(cargoTransfer.CreatedBy).Employee.FullName;
                                if (employee != "")
                                {
                                    model1.ScannedBy = employee;
                                }
                                _results.Add(model1);
                            }
                        }
                    }
                    else
                    {
                        _airwaybill = _packageNumber.Shipment.AirwayBillNo;
                        CargoTransferViewModel isExist = _results.Find(x => x.AWB == _airwaybill);

                        if (isExist != null)
                        {
                            isExist.QTY++;
                            model.Pieces++;
                            //_results.Add(isExist);
                        }
                        else
                        {
                            List <Shipment> list = shipment.GetAll().Where(x => x.AirwayBillNo.Equals(_airwaybill)).ToList();
                            model.Origin = _airwaybill;
                            foreach (Shipment x in list)
                            {
                                model.Origin      = x.OriginCity.CityName;
                                model.Destination = x.DestinationCity.CityName;
                                model.BCO         = x.DestinationCity.BranchCorpOffice.BranchCorpOfficeName;
                            }
                            model.Driver  = cargoTransfer.Driver;
                            model.Checker = cargoTransfer.Checker;
                            model.Pieces++;
                            model.PlateNo = cargoTransfer.PlateNo;
                            model.Batch   = cargoTransfer.Batch.BatchName;
                            model.AWB     = _airwaybill;
                            model.QTY++;
                            model.CreatedDate = cargoTransfer.CreatedDate;

                            // model.BCO = cargoTransfer.BranchCorpOffice.BranchCorpOfficeName;
                            //model.BCO = cargoTransfer.BranchCorpOffice.BranchCorpOfficeName;
                            model.GATEWAY   = cargoTransfer.RevenueUnit.RevenueUnitName;
                            model.SATELLITE = cargoTransfer.RevenueUnit.RevenueUnitName;
                            //model.ScannedBy = AppUser.User.Employee.FullName;
                            model.ScannedBy = "N/A";
                            string employee = _userService.FindById(cargoTransfer.CreatedBy).Employee.FullName;
                            if (employee != "")
                            {
                                model.ScannedBy = employee;
                            }
                            _results.Add(model);
                        }
                    }
                }
                catch (Exception) { continue; }
            }
            return(_results);
        }
Example #4
0
        public List <GatewayOutboundViewModel> Match(List <GatewayInbound> _inbound, List <GatewayOutbound> _outbound)
        {
            PackageNumberBL _packageNumberService    = new PackageNumberBL();
            List <GatewayOutboundViewModel> _results = new List <GatewayOutboundViewModel>();
            PackageNumber _packageNumber             = new PackageNumber();
            List <string> listCargo     = new List <string>();
            BundleBL      bundleService = new BundleBL();
            UserStore     _userService  = new UserStore();

            foreach (GatewayOutbound outbound in _outbound)
            {
                GatewayOutboundViewModel model = new GatewayOutboundViewModel();
                string _airwaybill             = "";
                try {
                    //_airwaybill = _packageNumberService.GetAll().Find(x => x.PackageNo == outbound.Cargo).Shipment.AirwayBillNo;
                    _packageNumber = _packageNumberService.FilterActive().Where(x => x.PackageNo == outbound.Cargo).FirstOrDefault();
                    if (_packageNumber == null)
                    {
                        GatewayOutboundViewModel model1 = new GatewayOutboundViewModel();
                        listCargo = bundleService.GetAll().Where(x => x.SackNo == outbound.Cargo).Select(y => y.Cargo).ToList();
                        if (listCargo != null && listCargo.Count != 0)
                        {
                            GatewayOutboundViewModel isExist = _results.Find(x => x.AirwayBillNo == outbound.Cargo);
                            if (_inbound.Exists(x => x.Cargo == outbound.Cargo))
                            {
                                if (isExist != null)
                                {
                                    isExist.TotalRecieved++;
                                    isExist.Total = isExist.TotalRecieved;
                                }
                                else
                                {
                                    model1.AirwayBillNo  = outbound.Cargo;
                                    model1.Gateway       = outbound.Gateway;
                                    model1.Driver        = outbound.Driver;
                                    model1.PlateNo       = outbound.PlateNo;
                                    model1.Batch         = outbound.Batch.BatchName;
                                    model1.TotalRecieved = listCargo.Count;
                                    model1.Total         = model1.TotalRecieved;
                                    model1.Branch        = outbound.BranchCorpOffice.BranchCorpOfficeName;
                                    // 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(outbound.CreatedBy).Employee.FullName;
                                    if (employee != "")
                                    {
                                        model1.ScannedBy = employee;
                                    }
                                    model1.CommodityTypeName = "N/A";
                                    //model1.CommodityTypeName = _packageNumberService.FilterActiveBy(x => x.PackageNo == outbound.Cargo).First().Shipment.CommodityType.CommodityTypeName;
                                    _results.Add(model1);
                                }
                            }
                            else
                            {
                                if (isExist != null)
                                {
                                    isExist.TotalDiscrepency++;
                                    isExist.Total = isExist.TotalDiscrepency;
                                }
                                else
                                {
                                    model1.AirwayBillNo     = outbound.Cargo;
                                    model1.Gateway          = outbound.Gateway;
                                    model1.Driver           = outbound.Driver;
                                    model1.PlateNo          = outbound.PlateNo;
                                    model1.Batch            = outbound.Batch.BatchName;
                                    model1.TotalDiscrepency = listCargo.Count;
                                    model1.Total            = model1.TotalDiscrepency;
                                    model1.Branch           = outbound.BranchCorpOffice.BranchCorpOfficeName;
                                    //model1.ScannedBy = "N/A";
                                    string employee = _userService.FindById(outbound.CreatedBy).Employee.FullName;
                                    if (employee != "")
                                    {
                                        model1.ScannedBy = employee;
                                    }
                                    model1.CommodityTypeName = "N/A";
                                    //model1.CommodityTypeName = _packageNumberService.FilterActiveBy(x => x.PackageNo == outbound.Cargo).First().Shipment.CommodityType.CommodityTypeName;
                                    _results.Add(model1);
                                }
                            }
                        }
                    }
                    else
                    {
                        _airwaybill = _packageNumber.Shipment.AirwayBillNo;
                        GatewayOutboundViewModel isExist = _results.Find(x => x.AirwayBillNo == _airwaybill);
                        if (_inbound.Exists(x => x.Cargo == outbound.Cargo))
                        {
                            if (isExist != null)
                            {
                                isExist.TotalRecieved++;
                                isExist.Total = isExist.TotalRecieved;
                                //model.Total = model.TotalRecieved;
                                //_results.Add(isExist);
                            }
                            else
                            {
                                model.AirwayBillNo = _airwaybill;
                                model.Gateway      = outbound.Gateway;
                                model.Driver       = outbound.Driver;
                                model.PlateNo      = outbound.PlateNo;
                                model.Batch        = outbound.Batch.BatchName;
                                model.TotalRecieved++;
                                model.Total  = model.TotalRecieved;
                                model.Branch = outbound.BranchCorpOffice.BranchCorpOfficeName;
                                //model.ScannedBy = AppUser.User.Employee.FullName;
                                string employee = _userService.FindById(outbound.CreatedBy).Employee.FullName;
                                if (employee != "")
                                {
                                    model.ScannedBy = employee;
                                }
                                //model.CommodityTypeName = _inbound.Where(x => x.Cargo == outbound.Cargo).Select(x => x.CommodityType.CommodityTypeName).ToString();
                                // model.CommodityTypeName = _inbound.Find(x => x.Cargo == outbound.Cargo).CommodityType.CommodityTypeName;
                                model.CommodityTypeName = _packageNumberService.FilterActiveBy(x => x.PackageNo == outbound.Cargo).First().Shipment.CommodityType.CommodityTypeName;
                                _results.Add(model);
                            }
                        }
                        else
                        {
                            if (isExist != null)
                            {
                                isExist.TotalDiscrepency++;
                                isExist.Total = isExist.TotalDiscrepency;
                                //model.Total = model.TotalDiscrepency;
                                //_results.Add(isExist);
                            }
                            else
                            {
                                model.AirwayBillNo = _airwaybill;
                                model.Gateway      = outbound.Gateway;
                                model.Driver       = outbound.Driver;
                                model.PlateNo      = outbound.PlateNo;
                                model.Batch        = outbound.Batch.BatchName;
                                model.TotalDiscrepency++;
                                model.Total  = model.TotalDiscrepency;
                                model.Branch = outbound.BranchCorpOffice.BranchCorpOfficeName;
                                string employee = _userService.FindById(outbound.CreatedBy).Employee.FullName;
                                if (employee != "")
                                {
                                    model.ScannedBy = employee;
                                }
                                //model.CommodityTypeName = _inbound.Find(x => x.Cargo == outbound.Cargo).CommodityType.CommodityTypeName;
                                // model.CommodityTypeName = _inbound.Where(x => x.Cargo == outbound.Cargo).Select(x => x.CommodityType.CommodityTypeName).ToString();
                                model.CommodityTypeName = _packageNumberService.FilterActiveBy(x => x.PackageNo == outbound.Cargo).First().Shipment.CommodityType.CommodityTypeName;
                                _results.Add(model);
                            }
                        }
                    }
                }
                catch (Exception) { continue; }
            }


            return(_results);
        }