public DataTable getBundleData(DateTime date)
        {
            UnbundleBL unbundlebl = new UnbundleBL();
            BundleBL   bundlebl   = new BundleBL();

            List <Unbundle> unbundleList = unbundlebl.FilterActive().Where(x => x.RecordStatus == 1 && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();
            List <Bundle>   bundleList   = bundlebl.FilterActive().Where(x => x.RecordStatus == 1 && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();

            List <UnbundleViewModel> modelList = Match(unbundleList, bundleList);

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("No", typeof(string)));
            dt.Columns.Add(new DataColumn("Sack No", typeof(string)));
            dt.Columns.Add(new DataColumn("Total Pieces", typeof(string)));
            dt.Columns.Add(new DataColumn("Scanned Pieces", typeof(string)));
            dt.Columns.Add(new DataColumn("Discrepancy Pieces", typeof(string)));
            dt.Columns.Add(new DataColumn("Origin", typeof(string)));
            dt.Columns.Add(new DataColumn("Weight", typeof(string)));
            dt.Columns.Add(new DataColumn("AWB", typeof(string)));
            dt.Columns.Add(new DataColumn("CreatedDate", typeof(string)));
            dt.Columns.Add(new DataColumn("Branch", typeof(string)));
            dt.Columns.Add(new DataColumn("ScannedBy", typeof(string)));
            dt.BeginLoadData();
            int ctr = 1;

            foreach (UnbundleViewModel item in modelList)
            {
                DataRow row = dt.NewRow();
                row[0]  = "" + ctr++;
                row[1]  = item.SackNo;
                row[2]  = item.TotalPcs;
                row[3]  = item.ScannedPcs;
                row[4]  = item.TotalDiscrepency;
                row[5]  = item.Origin;
                row[6]  = item.Weight;
                row[7]  = item.AirwayBillNo;
                row[8]  = item.CreatedDate;
                row[9]  = item.Branch;
                row[10] = item.ScannedBy;
                dt.Rows.Add(row);
            }
            dt.EndLoadData();

            return(dt);
        }
        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 DataTable getBundleData(DateTime date)
        {
            BundleBL bundleBl = new BundleBL();

            List <Bundle>          list       = bundleBl.FilterActive().Where(x => x.RecordStatus == 1 && 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);
        }
Ejemplo n.º 4
0
        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);
        }
        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);
        }
        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);
        }
Ejemplo n.º 7
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);
        }
        public DataTable getUnbundleDataByFilter(DateTime date, Guid?bcoid, string sackNo, int num)
        {
            UnbundleBL               unbundlebl   = new UnbundleBL();
            BundleBL                 bundlebl     = new BundleBL();
            BranchCorpOfficeBL       bcoService   = new BranchCorpOfficeBL();
            List <Unbundle>          unbundleList = new List <Unbundle>();
            List <Bundle>            bundleList   = bundlebl.FilterActive().Where(x => x.RecordStatus == 1 && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();
            List <UnbundleViewModel> modelList    = new List <UnbundleViewModel>();

            string sackNum = "";

            sackNum = sackNo;
            string bcoName = "";

            if (bcoid != null && bcoid != Guid.Empty)
            {
                bcoName = bcoService.FilterActive().Find(x => x.BranchCorpOfficeId == bcoid).BranchCorpOfficeName;
            }

            if (num == 0)
            {
                //unbundleList = unbundlebl.GetAll().Where(x => x.RecordStatus == 1 && x.CreatedDate.ToShortDateString() == date.ToShortDateString() && x.SackNo == sackNo).ToList();
                unbundleList = unbundlebl.FilterActive().Where(x => x.RecordStatus == 1 && x.SackNo == sackNo).ToList();
                modelList    = Match(unbundleList, bundleList).FindAll(x => x.SackNo == sackNum);
                //bundleList = bundlebl.GetAll().Where(x => x.RecordStatus == 1 && x.BranchCorpOfficeID == GlobalVars.DeviceBcoId && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();
            }
            else if (num == 1)
            {
                unbundleList = unbundlebl.FilterActive().Where(x => x.RecordStatus == 1 && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();
                modelList    = Match(unbundleList, bundleList);
            }
            else if (num == 2)
            {
                unbundleList = unbundlebl.FilterActive().Where(x => x.RecordStatus == 1 && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();
                modelList    = Match(unbundleList, bundleList).FindAll(x => x.Branch == bcoName);
            }



            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("No", typeof(string)));
            dt.Columns.Add(new DataColumn("Sack No", typeof(string)));
            dt.Columns.Add(new DataColumn("Total Pieces", typeof(string)));
            dt.Columns.Add(new DataColumn("Scanned Pieces", typeof(string)));
            dt.Columns.Add(new DataColumn("Discrepancy Pieces", typeof(string)));
            dt.Columns.Add(new DataColumn("Origin", typeof(string)));
            dt.Columns.Add(new DataColumn("Weight", typeof(string)));
            dt.Columns.Add(new DataColumn("AWB", typeof(string)));
            dt.Columns.Add(new DataColumn("CreatedDate", typeof(string)));
            dt.Columns.Add(new DataColumn("Branch", typeof(string)));
            dt.Columns.Add(new DataColumn("ScannedBy", typeof(string)));
            dt.BeginLoadData();
            int ctr = 1;

            foreach (UnbundleViewModel item in modelList)
            {
                DataRow row = dt.NewRow();
                row[0]  = "" + ctr++;
                row[1]  = item.SackNo;
                row[2]  = item.TotalPcs;
                row[3]  = item.ScannedPcs;
                row[4]  = item.TotalDiscrepency;
                row[5]  = item.Origin;
                row[6]  = item.Weight;
                row[7]  = item.AirwayBillNo;
                row[8]  = item.CreatedDate;
                row[9]  = item.Branch;
                row[10] = item.ScannedBy;
                dt.Rows.Add(row);
            }
            dt.EndLoadData();

            return(dt);
        }