コード例 #1
0
        public DataTable getData(DateTime date)
        {
            GatewayOutboundBL gatewayOutboundBl = new GatewayOutboundBL();
            GatewayInboundBL  gatewayInboundBl  = new GatewayInboundBL();

            List <GatewayOutbound> Outboundlist = gatewayOutboundBl.GetAll().Where(x => x.RecordStatus == 1 && x.CreatedDate.ToShortDateString() == date.ToShortDateString()).GroupBy(x => x.Cargo).Select(y => y.First()).ToList();
            List <GatewayInbound>  Inboundlist  = gatewayInboundBl.GetAll().GroupBy(x => x.Cargo).Select(y => y.First()).ToList();

            List <GatewayOutboundViewModel> 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);
        }
コード例 #2
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);
        }