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 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);
        }