Ejemplo 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);
    }
Ejemplo 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);
    }
Ejemplo n.º 3
0
        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)
            });
        }
Ejemplo n.º 4
0
    public void Fill_Letter(Donation e)
    {
        LabelName.Text = e.People.Name;
        LabelDOB.Text  = e.People.DOBToString;

        LabelPackCode.Text = e.DIN;
        LabelAddress.Text  = e.People.FullResidentalAddress;

        LabelHIV.Text = e.Markers.HIV;
        //if (e.Markers.HIV == TR.na.Name)
        //    LabelHIV.Text = "Không có";
        //else if (e.Markers.HIV == TR.neg.Name)
        //    LabelHIV.Text = "Âm tính";
        //else if (e.Markers.HIV == TR.pos.Name)
        //    LabelHIV.Text = "Dương tính";
        //else
        //    LabelHIV.Text = e.Markers.HIV;

        LabelHCV.Text = e.Markers.HCV_Ab;
        //if (e.Markers.HCV_Ab == TR.na.Name)
        //    LabelHCV.Text = TR.na.Name;
        //else if (e.Markers.HCV_Ab == TR.neg.Name)
        //    LabelHCV.Text = "Âm tính";
        //else if (e.Markers.HCV_Ab == TR.pos.Name)
        //    LabelHCV.Text = "Dương tính";
        //else
        //    LabelHCV.Text = e.Markers.HCV_Ab;

        LabelHBsAg.Text = e.Markers.HBs_Ag;
        //if (e.Markers.HBs_Ag == TR.na.Name)
        //    LabelHBsAg.Text = "Không có";
        //else if (e.Markers.HBs_Ag == TR.neg.Name)
        //    LabelHBsAg.Text = "Âm tính";
        //else if (e.Markers.HBs_Ag == TR.pos.Name)
        //    LabelHBsAg.Text = "Dương tính";
        //else
        //    LabelHBsAg.Text = e.Markers.HBs_Ag;

        LabelMalaria.Text = e.Markers.Malaria;
        //if (e.Markers.Malaria == TR.na.Name)
        //    LabelMalaria.Text = "Không có";
        //else if (e.Markers.Malaria == TR.neg.Name)
        //    LabelMalaria.Text = "Âm tính";
        //else if (e.Markers.Malaria == TR.pos.Name)
        //    LabelMalaria.Text = "Dương tính";
        //else
        //    LabelMalaria.Text = e.Markers.Malaria;

        LabelSyphilis.Text = e.Markers.Syphilis;
        //if (e.Markers.Syphilis == TR.na.Name)
        //    LabelSyphilis.Text = "Không có";
        //else if (e.Markers.Syphilis == TR.neg.Name)
        //    LabelSyphilis.Text = "Âm tính";
        //else if (e.Markers.Syphilis == TR.pos.Name)
        //    LabelSyphilis.Text = "Dương tính";
        //else
        //    LabelSyphilis.Text = e.Markers.Syphilis;

        LabelABO_Rh.Text = BloodGroupBLL.GetDescription(e.BloodGroup);
    }
Ejemplo n.º 5
0
    public string GetResult(string type, string result)
    {
        string str = "";

        if (type == "BloodGroup")
        {
            str = BloodGroupBLL.GetDescription(result);
        }

        if (type == "Markers")
        {
            if (InfectiousMarker.IsValidate(result))
            {
                InfectiousMarker maker = new InfectiousMarker();
                maker.Code = result;
                str        = maker.Description;
            }
            else
            {
                str = "";
            }
        }

        return(str);
    }
Ejemplo n.º 6
0
    protected void LinqDataSourceSum_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    {
        RedBloodDataContext db = new RedBloodDataContext();

        var v = db.PackOrders.Where(r => r.OrderID.Value == OrderID &&
                                    !r.ReturnID.HasValue).ToList()
                .GroupBy(r => r.Pack.ProductCode)
                .Select(r => new
        {
            ProductCode      = r.Key,
            Sum              = r.Count(),
            BloodGroupSumary = r.GroupBy(r1 => r1.Pack.Donation.BloodGroup).Select(r1 => new
            {
                BloodGroupDesc = BloodGroupBLL.GetDescription(r1.Key),
                Total          = r1.Count(),
                VolumeSumary   = r1.GroupBy(r2 => r2.Pack.Volume).Select(r2 => new
                {
                    Volume = r2.Key.HasValue ? r2.Key.Value.ToString() : "_",
                    Total  = r2.Count()
                }).OrderBy(r2 => r2.Volume)
            }).OrderBy(r1 => r1.BloodGroupDesc),
        });

        e.Result = v;
    }
Ejemplo n.º 7
0
 protected void LinqDataSourcePack_Selecting(object sender, LinqDataSourceSelectEventArgs e)
 {
     if (CampaignDetail1.CampaignID > 0)
     {
         e.Result =
             DonationBLL.GetUnLock(CampaignDetail1.CampaignID)
             .Select(r => new
         {
             r.DIN,
             r.Status,
             r.People.Name,
             CollectedDate = r.CollectedDate.ToStringVN_Hour(),
             r.BloodGroup,
             r.BloodGroupDesc,
             ABOLog = r.DonationTestLogs.Where(r1 => r1.Type == DonationTestLog.TypeX.BloodGroup)
                      .Select(r1 => new
             {
                 BloodGroupDesc = BloodGroupBLL.GetDescription(r1.Result),
                 Date           = r1.Date.ToStringVN_Hour()
             })
         });
     }
     else
     {
         e.Cancel = true;
     }
 }
Ejemplo n.º 8
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);
    }
Ejemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string strOrderID = Request["OrderID"];

            if (!string.IsNullOrEmpty(strOrderID))
            {
                order = OrderBLL.Get(strOrderID.ToInt());

                if (order.Type == Order.TypeX.ForOrg)
                {
                    LabelTitle1.Text = "BIÊN BẢN BÀN GIAO";

                    LoadOrder();

                    RedBloodDataContext db = new RedBloodDataContext();


                    var v1 = db.PackOrders.Where(r => r.OrderID.Value == order.ID &&
                                                 !r.ReturnID.HasValue).ToList();

                    var v = v1.GroupBy(r => r.Pack.ProductCode)
                            .Select(r => new
                    {
                        ProductCode      = r.Key,
                        Sum              = r.Count(),
                        BloodGroupSumary = r.GroupBy(r1 => r1.Pack.Donation.BloodGroup).Select(r1 => new
                        {
                            BloodGroupDesc = BloodGroupBLL.GetDescription(r1.Key),
                            Total          = r1.Count(),
                            VolumeSumary   = r1.GroupBy(r2 => r2.Pack.Volume).Select(r2 => new
                            {
                                Volume = r2.Key.HasValue ? r2.Key.Value.ToString() : "_",
                                Total  = r2.Count(),
                                //DINList = string.Join(",", r2.Select(r3 => r3.Pack.DIN).ToArray()),
                                DINList = r2.Select(r3 => new { DIN = r3.Pack.DIN }).OrderBy(r4 => r4.DIN),
                            }).OrderBy(r2 => r2.Volume)
                        }).OrderBy(r1 => r1.BloodGroupDesc),
                    });

                    GridViewSum.DataSource = v;
                    GridViewSum.DataBind();

                    LableCount.Text = v1.Count().ToStringRemoveZero();

                    //var v2 = db.PackOrders.Where(r => r.OrderID.Value == order.ID
                    //    && !r.ReturnID.HasValue).ToList().OrderBy(r => r.Pack.DIN);
                    //GridViewPack.DataSource = v2;
                    //GridViewPack.DataBind();
                }
            }
        }
    }
Ejemplo n.º 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string code    = "";
        string addText = "";
        int    count   = 0;

        try
        {
            code = Request["code"];
        }
        catch (Exception)
        {
        }

        try
        {
            count = Request["count"].ToInt();
        }
        catch (Exception)
        {
        }

        try
        {
            addText = Request["addText"];
        }
        catch (Exception)
        {
        }

        PrintSettingBLL.Reload();
        RedBloodDataContext db = new RedBloodDataContext();
        string desc            = BloodGroupBLL.GetDescription(code);

        for (int i = 0; i < count; i++)
        {
            Panel p = new Panel();
            p.Style.Add("position", "relative");
            p.Style.Add("page-break-after", "always");
            p.Style.Apply(PrintSettingBLL.BloodGroupLabel.PaperSize);
            p.Style.Add("border", "1px solid white");
            divCon.Controls.Add(p);

            AddDINLabelControl(code, desc + addText, PrintSettingBLL.BloodGroupLabel.Label1, p);
            AddDINLabelControl(code, desc + addText, PrintSettingBLL.BloodGroupLabel.Label2, p);
            AddDINLabelControl(code, desc + addText, PrintSettingBLL.BloodGroupLabel.Label3, p);
        }
    }
Ejemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string strParamID = Request["ReturnID"];

            if (!string.IsNullOrEmpty(strParamID))
            {
                returnObj = ReturnBLL.Get(strParamID.ToInt());

                if (returnObj != null)
                {
                    LabelTitle1.Text = "BIÊN BẢN THU HỒI";

                    LoadReturn();

                    RedBloodDataContext db = new RedBloodDataContext();

                    var v1 = db.PackOrders.Where(r => r.ReturnID.Value == returnObj.ID)
                             .Select(r => r.Pack)
                             .ToList();

                    var v = v1.GroupBy(r => r.ProductCode)
                            .Select(r => new
                    {
                        ProductCode      = r.Key,
                        Sum              = r.Count(),
                        BloodGroupSumary = r.GroupBy(r1 => r1.Donation.BloodGroup).Select(r1 => new
                        {
                            BloodGroupDesc = BloodGroupBLL.GetDescription(r1.Key),
                            Total          = r1.Count(),
                            VolumeSumary   = r1.GroupBy(r2 => r2.Volume).Select(r2 => new
                            {
                                Volume  = r2.Key.HasValue ? r2.Key.Value.ToString() : "_",
                                Total   = r2.Count(),
                                DINList = r2.Select(r3 => new { DIN = r3.DIN }).OrderBy(r4 => r4.DIN),
                            }).OrderBy(r2 => r2.Volume)
                        }).OrderBy(r1 => r1.BloodGroupDesc),
                    });

                    GridViewSum.DataSource = v;
                    GridViewSum.DataBind();

                    LableCount.Text = v1.Count().ToStringRemoveZero();
                }
            }
        }
    }
Ejemplo n.º 12
0
        public void LoadDIN()
        {
            Donation e = DonationBLL.Get(DIN);

            Clear();
            if (e != null)
            {
                lblName.Text = e.People.Name;

                imgDIN.ImageUrl = BarcodeBLL.Url4DIN(e.DIN, "00");

                lblDINDate.Text = e.CollectedDate.ToStringVN();


                if (e.Pack != null)
                {
                    imgProduct.ImageUrl   = BarcodeBLL.Url4Product(e.Pack.ProductCode);
                    lblProductDesc.Text   = ProductBLL.GetDesc(e.Pack.ProductCode);
                    btnRemovePack.Visible = e.CanRemoveOriginalPack;

                    lblDate.Text = e.Pack.Date.ToStringVN_Hour();

                    txtVolume.Text = e.Pack.Volume.ToString();

                    if (!string.IsNullOrEmpty(e.BloodGroup))
                    {
                        ImageBloodGroup.ImageUrl = BarcodeBLL.Url4BloodGroup(e.BloodGroup);
                        lblBloodGroup.Text       = BloodGroupBLL.GetDescription(e.BloodGroup);
                    }
                }
                else
                {
                    btnRemovePack.Visible = false;
                }

                txtCollector.Text = e.Collector;

                txtNote.Text = e.Note;

                //btnSave.Enabled = DonationBLL.CanUpdateTestResult(e);
            }
        }
Ejemplo n.º 13
0
    void LoadData()
    {
        DateTime?dtFrom = txtDateFrom.Text.ToDatetimeFromVNFormat();
        DateTime?dtTo   = txtDateTo.Text.ToDatetimeFromVNFormat();

        if (dtFrom.HasValue)
        {
            DateTime hourFrom;
            if (DateTime.TryParse(txtHourFrom.Text, out hourFrom))
            {
                dtFrom = dtFrom.Value.AddHours(hourFrom.Hour).AddMinutes(hourFrom.Minute);
            }
        }

        if (dtTo.HasValue)
        {
            DateTime hourTo;
            if (DateTime.TryParse(txtHourTo.Text, out hourTo))
            {
                dtTo = dtTo.Value.AddHours(hourTo.Hour).AddMinutes(hourTo.Minute);
            }
        }

        RedBloodDataContext db = new RedBloodDataContext();

        //var packs = db.Packs.Where(r => r.Date.Value >= dtFrom && r.Date.Value <= dtTo
        //   && r.Donation.OrgPackID != r.ID).OrderBy(r => r.Date);

        var v = db.Deletes.Where(r => r.Date.Value >= dtFrom && r.Date.Value <= dtTo)
                .OrderBy(r => r.Date)
                .ToList()
                .Select(r => new
        {
            r.ID,
            Date = r.Date.ToStringVN_Hour(),
            r.Note,
            r.Actor,
            r.Packs
        });



        GridView1.DataSource = v;
        GridView1.DataBind();

        var s = v.SelectMany(r => r.Packs).ToList();

        var v1 = s.ToList().GroupBy(r => r.ProductCode)
                 .Select(r => new
        {
            ProductCode      = r.Key,
            ProductDesc      = ProductBLL.GetDesc(r.Key),
            Sum              = r.Count(),
            BloodGroupSumary = r.GroupBy(r1 => r1.Donation.BloodGroup).Select(r1 => new
            {
                BloodGroupDesc = BloodGroupBLL.GetDescription(r1.Key),
                Total          = r1.Count(),
                VolumeSumary   = r1.GroupBy(r2 => r2.Volume).Select(r2 => new
                {
                    Volume  = r2.Key.HasValue ? r2.Key.Value.ToString() : "_",
                    Total   = r2.Count(),
                    DINList = r2.Select(r3 => new { DIN = r3.DIN }).OrderBy(r4 => r4.DIN),
                }).OrderBy(r2 => r2.Volume)
            }).OrderBy(r1 => r1.BloodGroupDesc),
        });

        GridViewSum.DataSource = v1;
        GridViewSum.DataBind();
    }
Ejemplo n.º 14
0
    void LoadData()
    {
        DateTime?dtFrom = txtDateFrom.Text.ToDatetimeFromVNFormat();
        DateTime?dtTo   = txtDateTo.Text.ToDatetimeFromVNFormat();

        if (dtFrom.HasValue)
        {
            DateTime hourFrom;
            if (DateTime.TryParse(txtHourFrom.Text, out hourFrom))
            {
                dtFrom = dtFrom.Value.AddHours(hourFrom.Hour).AddMinutes(hourFrom.Minute);
            }
        }

        if (dtTo.HasValue)
        {
            DateTime hourTo;
            if (DateTime.TryParse(txtHourTo.Text, out hourTo))
            {
                dtTo = dtTo.Value.AddHours(hourTo.Hour).AddMinutes(hourTo.Minute);
            }
        }

        RedBloodDataContext db = new RedBloodDataContext();

        var packs = db.Packs.Where(r => r.Date.Value >= dtFrom && r.Date.Value <= dtTo &&
                                   r.Donation.OrgPackID != r.ID).OrderBy(r => r.ProductCode).ThenBy(r => r.Date);

        var v = packs.ToList().GroupBy(r => r.ProductCode)
                .Select(r => new
        {
            ProductCode      = r.Key,
            ProductDesc      = ProductBLL.GetDesc(r.Key),
            Sum              = r.Count(),
            PrintUrl         = "~/Production/FinalLabelPrint.aspx?PackList=" + string.Join(",", r.Where(r1 => r1.Donation.TestResultStatus == Donation.TestResultStatusX.Negative).Select(r1 => r1.ID.ToString())),
            PrintCount       = r.Where(r1 => r1.Donation.TestResultStatus == Donation.TestResultStatusX.Negative).Count(),
            BloodGroupSumary = r.GroupBy(r1 => r1.Donation.BloodGroup).Select(r1 => new
            {
                BloodGroupDesc = BloodGroupBLL.GetDescription(r1.Key),
                Total          = r1.Count(),
                VolumeSumary   = r1.GroupBy(r2 => r2.Volume).Select(r2 => new
                {
                    Volume  = r2.Key.HasValue ? r2.Key.Value.ToString() : "_",
                    Total   = r2.Count(),
                    DINList = r2.Select(r3 => new { DIN = r3.DIN }).OrderBy(r4 => r4.DIN),
                }).OrderBy(r2 => r2.Volume)
            }).OrderBy(r1 => r1.BloodGroupDesc),
        });

        GridViewSum.DataSource = v;
        GridViewSum.DataBind();

        GridView1.DataSource = packs.ToList().Select(r => new
        {
            r.ID,
            Date = r.Date.ToStringVN_Hour(),
            r.DIN,
            r.ProductCode,
            Description = ProductBLL.GetDesc(r.ProductCode),
            r.Note,
        });
        GridView1.DataBind();

        btnSelectedPack.Visible = packs.Count() > 0;
    }
Ejemplo n.º 15
0
        void LoadData()
        {
            Org org = null;

            try
            {
                org = OrgBLL.GetByName(txtOrg.Text.Trim());
            }
            catch (Exception)
            {
                org = null;
            }



            DateTime?dtFrom = txtDateFrom.Text.ToDatetimeFromVNFormat();
            DateTime?dtTo   = txtDateTo.Text.ToDatetimeFromVNFormat();

            if (dtFrom.HasValue)
            {
                DateTime hourFrom;
                if (DateTime.TryParse(txtHourFrom.Text, out hourFrom))
                {
                    dtFrom = dtFrom.Value.AddHours(hourFrom.Hour).AddMinutes(hourFrom.Minute);
                }
            }

            if (dtTo.HasValue)
            {
                DateTime hourTo;
                if (DateTime.TryParse(txtHourTo.Text, out hourTo))
                {
                    dtTo = dtTo.Value.AddHours(hourTo.Hour).AddMinutes(hourTo.Minute);
                }
            }

            RedBloodDataContext db = new RedBloodDataContext();

            var v = db.Orders.Where(r => r.Date.Value >= dtFrom && r.Date.Value <= dtTo)
                    .ToList()
                    .Where(r =>
                           (org == null || (r.OrgID == org.ID))
                           )
                    //.OrderBy(r => r.Date)
                    //.ToList()
                    //.Select(r => new
                    //{
                    //    r.ID,
                    //    r.Name,
                    //    Date = r.Date.ToStringVN_Hour(),
                    //    r.Actor,
                    //    r.Type,
                    //    For = r.Type == Order.TypeX.ForCR ? r.Org.Name : r.People.Name,
                    //})
                    .SelectMany(r => r.PackOrders.Select(r1 => r1.Pack))
                    .ToList()
                    .GroupBy(r => new { r.ProductCode })
                    .Select(r => new
            {
                ProductCode      = r.Key.ProductCode,
                ProductDesc      = ProductBLL.GetDesc(r.Key.ProductCode),
                Total            = r.Count(),
                BloodGroupSumary = r.GroupBy(r1 => r1.Donation.BloodGroup).Select(r1 => new
                {
                    BloodGroupDesc = BloodGroupBLL.GetDescription(r1.Key),
                    Total          = r1.Count(),
                    VolumeSumary   = r1.GroupBy(r2 => r2.Volume).Select(r2 => new
                    {
                        Volume = r2.Key.HasValue ? r2.Key.Value.ToString() : "_",
                        Total  = r2.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.Sum(r3 => r3.Count)
                //}).OrderBy(r1 => r1.Volume)
            })
                    .OrderBy(r => r.ProductDesc);

            GridView1.DataSource = v;
            GridView1.DataBind();
        }