Esempio n. 1
0
    protected void LinqDataSourceStart_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    {
        ucDateRange.Validated();

        RedBloodDataContext db = new RedBloodDataContext();

        e.Result = db.vw_PackRemainDailies.Where(r => r.Date == ucDateRange.FromDate.Value.AddDays(-1))
                   .ToList()
                   .GroupBy(r => new { r.ProductCode, r.ProductDesc }, (r, sub) => new
        {
            r.ProductCode,
            r.ProductDesc,
            Total            = sub.Sum(r1 => r1.Count),
            BloodGroupSumary = sub.GroupBy(r1 => r1.BloodGroup, (r1, BGSub) => new
            {
                BloodGroupDesc = BloodGroupBLL.GetDescription(r1),
                Total          = BGSub.Sum(r3 => r3.Count)
            }),
            VolumeSumary = sub.GroupBy(r1 => r1.Volume, (r1, VolSub) => new
            {
                Volume = r1,
                Total  = VolSub.Sum(r3 => r3.Count)
            })
        })
                   .OrderBy(r => r.ProductDesc);
    }
Esempio n. 2
0
    protected void LinqDataSourceOut_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    {
        ucDateRange.Validated();

        RedBloodDataContext db = new RedBloodDataContext();

        e.Result = db.vw_PackTrans.Where(r => PackTransactionBLL.OutTypeList.Contains(r.Type) &&
                                         ucDateRange.FromDate <= r.Date &&
                                         r.Date <= ucDateRange.ToDate)
                   .ToList()
                   .GroupBy(r => new { r.ProductCode, r.ProductDesc }, (r, sub) => new
        {
            r.ProductCode,
            r.ProductDesc,
            Total         = sub.Sum(r1 => r1.Count),
            TotalOutOrder = sub.Where(r1 => PackTransactionBLL.OutOrderTypeList.Contains(r1.Type))
                            .Sum(r1 => r1.Count),
            TotalOutProduct = sub.Where(r1 => r1.Type == PackTransaction.TypeX.Out_Product)
                              .Sum(r1 => r1.Count),
            TotalOutDelete = sub.Where(r1 => r1.Type == PackTransaction.TypeX.Out_Delete)
                             .Sum(r1 => r1.Count),
            BloodGroupSumary = sub.GroupBy(r1 => r1.BloodGroup, (r1, BGSub) => new
            {
                BloodGroupDesc = BloodGroupBLL.GetDescription(r1),
                Total          = BGSub.Sum(r3 => r3.Count)
            }),
            VolumeSumary = sub.GroupBy(r1 => r1.Volume, (r1, VolSub) => new
            {
                Volume = r1,
                Total  = VolSub.Sum(r3 => r3.Count)
            })
        })
                   .OrderBy(r => r.ProductDesc);
    }
Esempio n. 3
0
    protected void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    {
        RedBloodDataContext db = new RedBloodDataContext();

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