コード例 #1
0
ファイル: Rpt910.aspx.cs プロジェクト: ghostnguyen/redblood
        protected void LinqDataSourceRpt_Selecting(object sender, LinqDataSourceSelectEventArgs e)
        {
            ucDateRange.Validated();

            RedBloodDataContext db = new RedBloodDataContext();

            e.Result = db.Campaigns.Where(r => ucDateRange.FromDate <= r.Date && r.Date <= ucDateRange.ToDate)
                       .ToList()
                       .Select(r => new
            {
                r.ID,
                Url = RedBloodSystem.Url4CollectRpt920
                      + "CampaignID=" + r.ID.ToString(),
                r.Name,
                r.Date,
                Total         = r.CollectedDonations.Count(),
                HostName      = r.HostOrg.Name,
                CoopName      = r.CoopOrg.Name,
                TestResultPos = RedBloodSystem.CheckingInfection.Select(r1 => new
                {
                    r1.Name,
                    Total = r.Donations.Where(r2 => r2.OrgPackID.HasValue && r1.Decode(r2.InfectiousMarkers) == TR.pos.Name).Count()
                }).Where(r1 => r1.Total > 0),
                TestResultNA = RedBloodSystem.CheckingInfection.Select(r1 => new
                {
                    r1.Name,
                    Total = r.Donations.Where(r2 => r2.OrgPackID.HasValue && r1.Decode(r2.InfectiousMarkers) == TR.na.Name).Count()
                }).Where(r1 => r1.Total > 0),
                BloodGroupSumary = r.Donations.Where(r2 => r2.OrgPackID.HasValue).GroupBy(r1 => r1.BloodGroup, (r2, BGSub) => new
                {
                    BloodGroupDesc = BloodGroupBLL.GetDescription(r2),
                    Total          = BGSub.Count()
                }).OrderBy(r1 => r1.BloodGroupDesc)
            });
        }
コード例 #2
0
ファイル: Count.aspx.cs プロジェクト: ghostnguyen/redblood
        public object GetData(bool?IsNeg)
        {
            RedBloodDataContext db = new RedBloodDataContext();

            var v =
                //db.vw_ProductCounts
                db.Packs
                .Where(r => r.Status == Pack.StatusX.Product)
                .Select(r => new
            {
                TestResultStatus = r.Donation.TestResultStatus,
                r.ProductCode,
                r.Status,
                r.ExpirationDate,
                BloodGroup = r.Donation.BloodGroup,
                r.Volume,
            })
                .ToList()

                .Where(r => !IsNeg.HasValue || (IsNeg.Value ? r.TestResultStatus == Donation.TestResultStatusX.Negative
                    : r.TestResultStatus != Donation.TestResultStatusX.Negative))


                .GroupBy(r => new { r.ProductCode, r.Status }, (r, sub) => new
            {
                r.ProductCode,
                ProductDesc = ProductBLL.GetDesc(r.ProductCode),
                r.Status,
                //Total = sub.Sum(r1 => r1.Count),
                Total        = sub.Count(),
                TotalExpired = sub.Where(r1 => r1.ExpirationDate.Value.Expired())
                               .Count().ToStringRemoveZero(),
                //.Sum(r1 => r1.Count).ToStringRemoveZero(),
                TotalExpiredInDays = sub.Where(r1 => r1.ExpirationDate.Value.ExpiredInDays(ExpiredInDays))
                                     .Count().ToStringRemoveZero(),
                //.Sum(r1 => r1.Count).ToStringRemoveZero(),
                TotalTRNA = sub.Where(r1 => r1.TestResultStatus == Donation.TestResultStatusX.Non)
                            .Count().ToStringRemoveZero(),
                //.Sum(r1 => r1.Count).ToStringRemoveZero(),
                TotalTRNeg = sub.Where(r1 => r1.TestResultStatus == Donation.TestResultStatusX.Negative)
                             .Count().ToStringRemoveZero(),
                //.Sum(r1 => r1.Count).ToStringRemoveZero(),
                TotalTRPos = sub.Where(r1 => r1.TestResultStatus == Donation.TestResultStatusX.Positive)
                             .Count().ToStringRemoveZero(),
                //.Sum(r1 => r1.Count).ToStringRemoveZero(),
                BloodGroupSumary = sub.GroupBy(r1 => BloodGroupBLL.GetLetter(r1.BloodGroup), (r1, BGSub) => new
                {
                    //BloodGroupDesc = BloodGroupBLL.GetDescription(r1),
                    BloodGroupDesc = r1,
                    Total          = BGSub.Count(), // BGSub.Sum(r3 => r3.Count),
                    VolumeSumary   = BGSub.GroupBy(r2 => r2.Volume, (r2, VolSub) => new
                    {
                        Volume = r2.HasValue ? r2.Value.ToString() : "_",
                        Total  = VolSub.Count(),   // VolSub.Sum(r3 => r3.Count)
                    }).OrderBy(r2 => r2.Volume)
                }).OrderBy(r1 => r1.BloodGroupDesc),
                VolumeSumary = sub.GroupBy(r1 => r1.Volume, (r1, VolSub) => new
                {
                    Volume = r1.HasValue ? r1.Value.ToString() : "_",
                    Total  = VolSub.Count(),   // VolSub.Sum(r3 => r3.Count)
                }).OrderBy(r1 => r1.Volume)
            })
                .OrderBy(r => r.ProductDesc);

            return(v);
        }