public DataTable getData(DateTime fromdate, DateTime todate)
        {
            HoldCargoBL        holdcargoBl = new HoldCargoBL();
            BranchCorpOfficeBL bcoService  = new BranchCorpOfficeBL();
            List <HoldCargo>   list        = holdcargoBl.GetAll().Where(x => x.CreatedDate >= fromdate && x.CreatedDate <= todate).ToList();
            string             bcoName     = bcoService.GetAll().Find(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).BranchCorpOfficeName;

            //List<HoldCargoViewModel> modelList = Match(list).FindAll(x => x.Branch == bcoName);
            List <HoldCargoViewModel> modelList = Match(list);

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("No", typeof(string)));
            dt.Columns.Add(new DataColumn("Date", 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("Payment Mode", typeof(string)));
            dt.Columns.Add(new DataColumn("Service Mode", typeof(string)));
            dt.Columns.Add(new DataColumn("Status", typeof(string)));
            dt.Columns.Add(new DataColumn("Reason", typeof(string)));
            dt.Columns.Add(new DataColumn("Endorse by", typeof(string)));
            dt.Columns.Add(new DataColumn("Scanned by", typeof(string)));
            dt.Columns.Add(new DataColumn("Prepared by(Cut by)", typeof(string)));
            dt.Columns.Add(new DataColumn("Aging", typeof(string)));

            dt.Columns.Add(new DataColumn("Branch", typeof(string)));

            dt.Columns.Add(new DataColumn("BSO", typeof(string)));

            dt.BeginLoadData();
            int ctr = 1;

            foreach (HoldCargoViewModel item in modelList)
            {
                DataRow row = dt.NewRow();
                row[0]  = (ctr++).ToString();
                row[1]  = item.Date.ToShortDateString();
                row[2]  = item.AirwayBillNo;
                row[3]  = item.Shipper;
                row[4]  = item.Consignee;
                row[5]  = item.Address;
                row[6]  = item.PaymentMode;
                row[7]  = item.ServiceMode;
                row[8]  = item.Status;
                row[9]  = item.Reason;
                row[10] = item.EndorseBy;
                row[11] = item.ScannedBy;
                row[12] = item.PreparedBy;
                row[13] = item.Aging; //Present Date - Transaction Date
                row[14] = item.Branch;
                row[15] = item.BSO;
                dt.Rows.Add(row);
            }
            dt.EndLoadData();

            return(dt);
        }
        private void CmsDbCon_Load(object sender, EventArgs e)
        {
            Worker.WorkerReportsProgress      = true;
            Worker.WorkerSupportsCancellation = true;
            radProgressBar1.Value1            = 0;
            lblProgressState.Text             = "";
            btnSaveSync.Enabled = false;

            this.isLocalConnected       = false;
            this.isMainConnected        = false;
            testMainConnection.Visible  = false;
            testLocalConnection.Visible = false;

            bcoService             = new BranchCorpOfficeBL(GlobalVars.UnitOfWork);
            revenutUnitTypeService = new RevenueUnitTypeBL(GlobalVars.UnitOfWork);
            revenueUnitService     = new RevenueUnitBL(GlobalVars.UnitOfWork);

            _branchCorpOffices = bcoService.FilterActive().OrderBy(x => x.BranchCorpOfficeName).ToList();
            revenueUnitTypes   = revenutUnitTypeService.FilterActive().OrderBy(x => x.RevenueUnitTypeName).ToList();
            revenueUnits       = revenueUnitService.FilterActive().OrderBy(x => x.RevenueUnitName).ToList();

            // Load BranchCorpOffices
            lstBco.DataSource    = _branchCorpOffices;
            lstBco.DisplayMember = "BranchCorpOfficeName";
            lstBco.ValueMember   = "BranchCorpOfficeId";

            // Load RevenueUnitTypes
            lstRevenueUnitType.DataSource    = revenueUnitTypes;
            lstRevenueUnitType.DisplayMember = "RevenueUnitTypeName";
            lstRevenueUnitType.ValueMember   = "RevenueUnitTypeId";

            // Load RevenueUnits
            lstRevenueUnit.DataSource    = revenueUnits;
            lstRevenueUnit.DisplayMember = "RevenueUnitName";
            lstRevenueUnit.ValueMember   = "RevenueUnitId";

            _branchCorpOfficeId    = GlobalVars.DeviceBcoId.ToString();
            _filter                = ConfigurationManager.AppSettings["Filter"].ToString();
            _localConnectionString = ConfigurationManager.ConnectionStrings["Cms"].ConnectionString;
            _mainConnectionString  = ConfigurationManager.ConnectionStrings["CmsCentral"].ConnectionString;
            _isSubserver           = ConfigurationManager.AppSettings["isSubserver"].ToString();

            SetChekcBoxes();
            SetEntities();
            gridTables.DataSource   = _entities;
            radProgressBar1.Maximum = _entities.Count() + 5;

            if (_isSubserver.ToLower() == "false")
            {
                txtServerIP.Enabled       = false;
                txtServerDbName.Enabled   = false;
                txtServerUsername.Enabled = false;
                txtServerPassword.Enabled = false;
                isMainConnected           = true;
                radPageViewPage2.Enabled  = false;
            }
        }
Пример #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);
        }
Пример #4
0
        public DataTable getBranchAcceptanceData(DateTime date)
        {
            BranchCorpOfficeBL bcoService         = new BranchCorpOfficeBL();
            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() && x.Booking.BookingStatus.BookingStatusName == "Picked-up").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.FilterActive().Where(x => x.Users.Employee.AssignedToArea.City.BranchCorpOffice.BranchCorpOfficeId == GlobalVars.DeviceBcoId && x.RecordStatus == 1 && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();

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

            List <BranchAcceptanceViewModel> list = Match(branchAcceptance, shipments).FindAll(x => x.BCO == bcoName &&
                                                                                               x.Area != "N/A" && !x.Area.Contains("Walk-in"));

            // List<BranchAcceptanceViewModel> list = Match(branchAcceptance, shipments).FindAll(x => x.BCO == bcoName
            //&& x.Area != "N/A");

            // ((x.Driver == driver && x.Driver != "All") || (x.Driver == x.Driver && driver == "All"))
            //List<BranchAcceptanceViewModel> 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 <DeliveryStatusViewModel> Match(List <Delivery> _deliveries)
        {
            BranchCorpOfficeBL bcoService             = new BranchCorpOfficeBL();
            DeliveryStatusBL   status                 = new DeliveryStatusBL();
            DeliveryRemarkBL   remark                 = new DeliveryRemarkBL();
            DistributionBL     distributionService    = new DistributionBL();
            DeliveryReceiptBL  deliveryReceiptService = new DeliveryReceiptBL();
            ShipmentBL         shipmentService        = new ShipmentBL();
            PackageNumberBL    _packageNumberService  = new PackageNumberBL();

            List <DeliveryStatusViewModel> _results = new List <DeliveryStatusViewModel>();

            List <Distribution> distributions = distributionService.GetAll().ToList();

            List <DeliveryReceipt> deliveryReceipt = deliveryReceiptService.GetAll().ToList();
            UserStore _userService = new UserStore();

            foreach (Delivery delivery in _deliveries)
            {
                DeliveryStatusViewModel model = new DeliveryStatusViewModel();

                DeliveryStatusViewModel isExist = _results.Find(x => x.AirwayBillNo == delivery.Shipment.AirwayBillNo);


                if (isExist != null)
                {
                    isExist.QTY++;
                }
                else
                {
                    model.AirwayBillNo = delivery.Shipment.AirwayBillNo;
                    model.QTY          = _packageNumberService.FilterActiveBy(x => x.Shipment.AirwayBillNo == delivery.Shipment.AirwayBillNo).Count;
                    model.Status       = delivery.DeliveryStatus.DeliveryStatusName;
                    model.Remarks      = "NA";
                    model.DeliveredBy  = delivery.DeliveredBy.FullName;
                    if (delivery.DeliveryRemarkId != null)
                    {
                        model.Remarks = delivery.DeliveryRemark.DeliveryRemarkName;
                    }
                    Distribution    dis      = distributions.Find(x => x.ShipmentId == delivery.ShipmentId);
                    DeliveryReceipt dReceipt = deliveryReceipt.Find(x => x.DeliveryId == delivery.DeliveryId);
                    //List<Distribution> list = distributions.Where( x => x.ShipmentId == delivery.ShipmentId).Distinct().ToList();
                    //foreach(Distribution dis in list)
                    //{
                    //    //model.Area = dis.Area.RevenueUnitName;
                    //    model.Driver = dis.Driver;
                    //    model.Checker = dis.Checker;
                    //    model.Batch = dis.Batch.BatchName;
                    //    model.PlateNo = dis.PlateNo;
                    //    model.BCO = dis.Area.City.BranchCorpOffice.BranchCorpOfficeName;
                    //}
                    model.Area    = dis.Area.RevenueUnitName;
                    model.Driver  = dis.Driver;
                    model.Checker = dis.Checker;
                    model.Batch   = dis.Batch.BatchName;
                    model.PlateNo = dis.PlateNo;
                    model.BCO     = dis.Area.City.BranchCorpOffice.BranchCorpOfficeName;
                    //model.ScannedBy = AppUser.User.Employee.FullName;
                    model.ScannedBy = "N/A";
                    string employee = _userService.FindById(dis.CreatedBy).Employee.FullName;
                    if (employee != "")
                    {
                        model.ScannedBy = employee;
                    }
                    model.ReceivedBy = "NA";
                    if (dReceipt != null)
                    {
                        model.ReceivedBy = dReceipt.ReceivedBy;
                    }

                    _results.Add(model);
                }
            }

            //List<BranchCorpOffice> _bco= bcoService.GetAll().Where(x => x.RecordStatus == 1 && x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).ToList();
            //string bcoName = bcoService.GetAll().Where(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).Select(x => x.BranchCorpOfficeName).ToString();
            //string bcoName = _bco.Select(x => x.BranchCorpOfficeName).ToString();
            string bcoName = bcoService.GetAll().Find(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).BranchCorpOfficeName;
            List <DeliveryStatusViewModel> _resultsFilter = _results.FindAll(x => x.BCO == bcoName);

            //List<DeliveryStatusViewModel> resultList = modelList.FindAll(x => x.Area == revenueUnitName);
            //return _results;
            return(_resultsFilter);
        }
        public DataTable getCTDataByFilter(DateTime date, Guid?destinationId, Guid?revenueunitId, string plateno, Guid?batchId)
        {
            BranchCorpOfficeBL bcoService      = new BranchCorpOfficeBL();
            CargoTransferBL    cargoTransferBl = new CargoTransferBL();

            List <CargoTransferViewModel> modelList = new List <CargoTransferViewModel>();
            List <CargoTransfer>          list      = cargoTransferBl.GetAll().Where
                                                          (x => x.RecordStatus == 1 &&
                                                          ((x.BranchCorpOfficeID == destinationId && x.BranchCorpOfficeID != Guid.Empty) || (x.BranchCorpOfficeID == x.BranchCorpOfficeID && destinationId == Guid.Empty)) &&
                                                          ((x.RevenueUnitID == revenueunitId && x.RevenueUnitID != Guid.Empty) || (x.RevenueUnitID == x.RevenueUnitID && revenueunitId == Guid.Empty)) &&
                                                          ((x.BatchID == batchId && x.BatchID != Guid.Empty) || (x.BatchID == x.BatchID && batchId == Guid.Empty)) &&
                                                          ((x.PlateNo == plateno && x.PlateNo != "All") || (x.PlateNo == x.PlateNo && plateno == "All")) &&
                                                          x.CreatedDate.ToShortDateString() == date.ToShortDateString()
                                                          ).GroupBy(x => x.Cargo).Select(y => y.First()).ToList();

            //List<CargoTransferViewModel> modelList = Match(list);

            string _bco = "";

            if (destinationId != Guid.Empty)
            {
                _bco      = bcoService.GetAll().Find(x => x.BranchCorpOfficeId == destinationId).BranchCorpOfficeName;
                modelList = Match(list).FindAll(x => x.BCO == _bco);
            }
            else
            {
                modelList = Match(list);
            }

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("No", typeof(string)));
            dt.Columns.Add(new DataColumn("Origin", typeof(string)));
            dt.Columns.Add(new DataColumn("Destination", typeof(string)));
            dt.Columns.Add(new DataColumn("Driver", typeof(string)));
            dt.Columns.Add(new DataColumn("Checker", typeof(string)));
            dt.Columns.Add(new DataColumn("Pieces", 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("QTY", typeof(string)));

            dt.Columns.Add(new DataColumn("CreatedDate", typeof(string)));

            dt.Columns.Add(new DataColumn("BCO", typeof(string)));
            dt.Columns.Add(new DataColumn("GATEWAY", typeof(string)));
            dt.Columns.Add(new DataColumn("SATELLITE", typeof(string)));
            dt.Columns.Add(new DataColumn("ScannedBy", typeof(string)));
            dt.BeginLoadData();
            int ctr = 1;

            foreach (CargoTransferViewModel item in modelList)
            {
                DataRow row = dt.NewRow();
                row[0]  = (ctr++).ToString();
                row[1]  = item.Origin;
                row[2]  = item.Destination;
                row[3]  = item.Driver;
                row[4]  = item.Checker;
                row[5]  = item.Pieces;
                row[6]  = item.PlateNo;
                row[7]  = item.Batch;
                row[8]  = item.AWB;
                row[9]  = item.QTY;
                row[10] = item.CreatedDate.ToShortDateString();

                row[11] = item.BCO;
                row[12] = item.GATEWAY;
                row[13] = item.SATELLITE;

                row[14] = item.ScannedBy;

                dt.Rows.Add(row);
            }
            dt.EndLoadData();

            return(dt);
        }
Пример #7
0
        public DataTable getGODatabyFilter(DateTime date, Guid?bcoid, string driver, string gateway, Guid?batchid, Guid?commodityTypeId, string mawb, int num)
        {
            GatewayOutboundBL  gatewayOutboundBl = new GatewayOutboundBL();
            GatewayInboundBL   gatewayInboundBl  = new GatewayInboundBL();
            CommodityTypeBL    comtypeService    = new CommodityTypeBL();
            BranchCorpOfficeBL bcoService        = new BranchCorpOfficeBL();


            List <GatewayInbound>           Inboundlist  = gatewayInboundBl.GetAll().GroupBy(x => x.Cargo).Select(y => y.First()).ToList();
            List <GatewayOutbound>          Outboundlist = new List <GatewayOutbound>();
            List <GatewayOutboundViewModel> modelList    = new List <GatewayOutboundViewModel>();

            if (num == 0)
            {
                Outboundlist = gatewayOutboundBl.GetAll().Where
                                   (x => x.RecordStatus == 1
                                   //&& x.CreatedDate.ToShortDateString() == date.ToShortDateString()
                                   && x.MasterAirwayBill == mawb).GroupBy(x => x.Cargo).Select(y => y.First()).ToList();
            }
            else if (num == 1)
            {
                Outboundlist = gatewayOutboundBl.GetAll().Where
                                   (x => x.RecordStatus == 1
                                   //&& ((x.PackageNumber.Shipment.DestinationCity.BranchCorpOfficeId == bcoid && x.PackageNumber.Shipment.DestinationCity.BranchCorpOfficeId != null) || (x.PackageNumber.Shipment.DestinationCity.BranchCorpOfficeId == x.PackageNumber.Shipment.DestinationCity.BranchCorpOfficeId && x.PackageNumber.Shipment.DestinationCity.BranchCorpOfficeId == null))
                                   && ((x.Driver == driver && x.Driver != "All") || (x.Driver == x.Driver && driver == "All")) &&
                                   ((x.Gateway == gateway && x.Gateway != "All") || (x.Gateway == x.Gateway && gateway == "All")) &&
                                   ((x.BatchID == batchid && x.BatchID != Guid.Empty) || (x.BatchID == x.BatchID && batchid == Guid.Empty)) &&
                                   x.CreatedDate.ToShortDateString() == date.ToShortDateString() &&
                                   ((x.MasterAirwayBill == mawb && x.MasterAirwayBill != "") || (x.MasterAirwayBill == x.MasterAirwayBill && mawb == ""))
                                   ).GroupBy(x => x.Cargo).Select(y => y.First()).ToList();
            }
            string comType = "";
            string _bco    = "";

            if (commodityTypeId != Guid.Empty && bcoid != Guid.Empty)
            {
                //string comType = comtypeService.GetAll().Where(x => x.RecordStatus == 1 && x.CommodityTypeId == commodityTypeId).Select(x => x.CommodityTypeName).ToString();
                //string _bco = bcoService.GetAll().Where(x => x.RecordStatus == 1 && x.BranchCorpOfficeId == bcoid).Select(x => x.BranchCorpOfficeName).ToString();
                //List<CommodityType> _ctype = comtypeService.FilterActiveBy(x => x.CommodityTypeId == commodityTypeId).ToList();
                //string comType = _ctype.Select(x => x.CommodityTypeName).ToString();

                //List<BranchCorpOffice> _branch = bcoService.FilterActiveBy(x => x.BranchCorpOfficeId == bcoid).ToList();
                //string _bco = _branch.Select(x => x.BranchCorpOfficeName).ToString();

                comType = comtypeService.GetAll().Find(x => x.CommodityTypeId == commodityTypeId).CommodityTypeName;
                _bco    = bcoService.GetAll().Find(x => x.BranchCorpOfficeId == bcoid).BranchCorpOfficeName;

                modelList = Match(Inboundlist, Outboundlist).FindAll(x => x.CommodityTypeName == comType && x.Branch == _bco);
            }
            else if (commodityTypeId != Guid.Empty && bcoid == Guid.Empty)
            {
                //string comType = comtypeService.GetAll().Where(x => x.RecordStatus == 1 && x.CommodityTypeId == commodityTypeId).Select(x => x.CommodityTypeName).ToString();
                //List<CommodityType> _ctype = comtypeService.FilterActiveBy(x => x.CommodityTypeId == commodityTypeId).ToList();
                //string comType = _ctype.Select(x => x.CommodityTypeName).ToString();
                comType   = comtypeService.GetAll().Find(x => x.CommodityTypeId == commodityTypeId).CommodityTypeName;
                modelList = Match(Inboundlist, Outboundlist).FindAll(x => x.CommodityTypeName == comType);
            }
            else if (commodityTypeId == Guid.Empty && bcoid != Guid.Empty)
            {
                //string _bco = bcoService.GetAll().Where(x => x.RecordStatus == 1 && x.BranchCorpOfficeId == bcoid).Select(x => x.BranchCorpOfficeName).ToString();
                //List<BranchCorpOffice> _branch = bcoService.FilterActiveBy(x => x.BranchCorpOfficeId == bcoid).ToList();
                //string _bco = _branch.Select(x => x.BranchCorpOfficeName).ToString();
                _bco      = bcoService.GetAll().Find(x => x.BranchCorpOfficeId == bcoid).BranchCorpOfficeName;
                modelList = Match(Inboundlist, Outboundlist).FindAll(x => x.Branch == _bco);
            }
            else
            {
                modelList = Match(Inboundlist, Outboundlist);
            }



            //modelList.GroupBy(x => x.AirwayBillNo).ToList();

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("No", typeof(string)));
            dt.Columns.Add(new DataColumn("Gateway", typeof(string)));
            dt.Columns.Add(new DataColumn("Driver", 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("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 (GatewayOutboundViewModel item in modelList)
            {
                DataRow row = dt.NewRow();
                row[0]  = (ctr++).ToString();
                row[1]  = item.Gateway.ToString();
                row[2]  = item.Driver.ToString();
                row[3]  = item.PlateNo.ToString();
                row[4]  = item.Batch;
                row[5]  = item.AirwayBillNo.ToString();
                row[6]  = item.TotalRecieved.ToString();
                row[7]  = item.TotalDiscrepency.ToString();
                row[8]  = item.Total.ToString();
                row[9]  = item.CreatedDate.ToShortDateString();
                row[10] = item.Branch;
                row[11] = item.ScannedBy;
                dt.Rows.Add(row);
            }
            dt.EndLoadData();

            return(dt);
        }
        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);
        }
        public List <UnbundleViewModel> Match(List <Unbundle> _unbundle, List <Bundle> _bundle)
        {
            BranchCorpOfficeBL       bcoService            = new BranchCorpOfficeBL();
            PackageNumberBL          _packageNumberService = new PackageNumberBL();
            List <UnbundleViewModel> _results = new List <UnbundleViewModel>();
            ShipmentBL shipment     = new ShipmentBL();
            Shipment   _shipment    = new Shipment();
            UserStore  _userService = new UserStore();
            //string bcoName = bcoService.FilterActive().Find(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).BranchCorpOfficeName;
            string bcoName = "";
            Guid   bcoid;
            Guid   userid;

            foreach (Bundle bundle in _bundle)
            {
                UnbundleViewModel model = new UnbundleViewModel();
                try
                {
                    _shipment = _packageNumberService.FilterActive().Find(x => x.PackageNo == bundle.Cargo).Shipment;
                }
                catch (Exception ex)
                {
                    Logs.ErrorLogs("", "Unbundle Match", ex.Message);
                    continue;
                }
                UnbundleViewModel isExist = _results.Find(x => x.AirwayBillNo == _shipment.AirwayBillNo);

                if (_unbundle.Exists(x => x.Cargo == bundle.Cargo))
                {
                    if (isExist != null)
                    {
                        isExist.ScannedPcs++;
                        //isExist.TotalPcs += isExist.ScannedPcs;
                        isExist.TotalPcs = isExist.ScannedPcs;
                    }

                    else
                    {
                        model.AirwayBillNo = _shipment.AirwayBillNo;
                        model.SackNo       = bundle.SackNo;
                        model.ScannedPcs++;
                        model.Weight     += bundle.Weight;
                        model.TotalPcs    = model.ScannedPcs;
                        model.Origin      = _shipment.OriginCity.CityName;
                        model.CreatedDate = bundle.CreatedDate;
                        model.Branch      = "N/A";
                        bcoid             = _unbundle.Find(x => x.Cargo == bundle.Cargo).BranchCorpOfficeID;
                        if (bcoid != null && bcoid != Guid.Empty)
                        {
                            bcoName      = bcoService.FilterActive().Find(x => x.BranchCorpOfficeId == bcoid).BranchCorpOfficeName;
                            model.Branch = bcoName;
                        }
                        //model.ScannedBy = AppUser.User.Employee.FullName;
                        model.ScannedBy = "N/A";
                        userid          = _unbundle.Find(x => x.Cargo == bundle.Cargo).CreatedBy;
                        string employee = _userService.FindById(userid).Employee.FullName;
                        if (employee != "")
                        {
                            model.ScannedBy = employee;
                        }
                        _results.Add(model);
                    }
                }
                else
                {
                    if (isExist != null)
                    {
                        isExist.TotalDiscrepency++;
                        //isExist.TotalPcs += isExist.TotalDiscrepency;
                        isExist.TotalPcs = isExist.TotalDiscrepency;
                    }

                    else
                    {
                        model.AirwayBillNo = _shipment.AirwayBillNo;
                        model.SackNo       = bundle.SackNo;
                        model.TotalDiscrepency++;
                        model.TotalPcs = model.TotalDiscrepency;
                        model.Weight  += bundle.Weight;

                        model.Origin      = _shipment.OriginCity.CityName;
                        model.CreatedDate = bundle.CreatedDate;
                        model.Branch      = "N/A";
                        bcoName           = _packageNumberService.FilterActive().Find(x => x.PackageNo == bundle.Cargo).Shipment.OriginCity.BranchCorpOffice.BranchCorpOfficeName;
                        if (bcoName != "")
                        {
                            //bcoName = bcoService.FilterActive().Find(x => x.BranchCorpOfficeId == bcoid).BranchCorpOfficeName;
                            model.Branch = bcoName;
                        }
                        //model.Branch = bundle.BranchCorpOffice.BranchCorpOfficeName;
                        model.ScannedBy = "N/A";
                        _results.Add(model);
                    }
                }
            }
            return(_results);
        }
Пример #10
0
        public DataTable getSGDatabyFilter(DateTime date, Guid?originbcoid, string driver, string plateno, Guid?batchid)
        {
            SegregationBL      segregationBL = new SegregationBL();
            BranchCorpOfficeBL bcoService    = new BranchCorpOfficeBL();

            List <SegregationViewModel> modelList = new List <SegregationViewModel>();

            List <Segregation> _segregation = segregationBL.GetAll().Where
                                                  (x => x.RecordStatus == 1
                                                  //&& ((x.PackageNumber.Shipment.OriginCity.BranchCorpOfficeId == originbcoid && x.PackageNumber.Shipment.OriginCity.BranchCorpOfficeId != null) || (x.PackageNumber.Shipment.OriginCity.BranchCorpOfficeId == x.PackageNumber.Shipment.OriginCity.BranchCorpOfficeId && x.PackageNumber.Shipment.OriginCity.BranchCorpOfficeId == null))
                                                  && ((x.Driver == driver && x.Driver != "All") || (x.Driver == x.Driver && driver == "All")) &&
                                                  ((x.PlateNo == plateno && x.PlateNo != "All") || (x.PlateNo == x.PlateNo && plateno == "All")) &&
                                                  ((x.BatchID == batchid && x.BatchID != null) || (x.BatchID == x.BatchID && batchid == null)) &&
                                                  x.CreatedDate.ToShortDateString() == date.ToShortDateString()).ToList();

            string bcoName = "";

            if (originbcoid != null)
            {
                //List<BranchCorpOffice> _bco = bcoService.GetAll().Where(x => x.RecordStatus == 1 && x.BranchCorpOfficeId == originbcoid).ToList();
                //string bcoName = bcoService.GetAll().Where(x => x.BranchCorpOfficeId == GlobalVars.DeviceBcoId).Select(x => x.BranchCorpOfficeName).ToString();
                //string bcoName = _bco.Select(x => x.BranchCorpOfficeName).ToString();
                //string _bco = bcoService.GetAll().Where(x => x.RecordStatus == 1 && x.BranchCorpOfficeId == originbcoid).Select(x => x.BranchCorpOfficeName).ToString();
                bcoName   = bcoService.GetAll().Find(x => x.BranchCorpOfficeId == originbcoid).BranchCorpOfficeName;
                modelList = Macth(_segregation).FindAll(x => x.BranchCorpOffice == bcoName);
            }
            else
            {
                modelList = Macth(_segregation);
            }

            // List<SegregationViewModel> modelList = Macth(_segregation);

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("No", typeof(string)));
            dt.Columns.Add(new DataColumn("Branch Corp Office", 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("Qty", typeof(string)));
            dt.Columns.Add(new DataColumn("Area", typeof(string)));
            dt.Columns.Add(new DataColumn("CreatedDate", typeof(string)));

            dt.Columns.Add(new DataColumn("ScannedBy", typeof(string)));

            dt.BeginLoadData();
            int ctr = 1;

            foreach (SegregationViewModel item in modelList)
            {
                DataRow row = dt.NewRow();
                row[0]  = ctr++.ToString();
                row[1]  = item.BranchCorpOffice;
                row[2]  = item.Driver;
                row[3]  = item.Checker;
                row[4]  = item.PlateNo;
                row[5]  = item.Batch;
                row[6]  = item.AirwayBillNo;
                row[7]  = item.Qty.ToString();
                row[8]  = item.Area;
                row[9]  = item.CreatedDate.ToShortDateString();
                row[10] = item.ScannedBy;

                dt.Rows.Add(row);
            }
            dt.EndLoadData();

            return(dt);
        }