Beispiel #1
0
partial         void OnValidate(System.Data.Linq.ChangeAction action)
        {
            if (action == System.Data.Linq.ChangeAction.Insert
                || action == System.Data.Linq.ChangeAction.Update)
            {
                RedBloodDataContext db = new RedBloodDataContext();

                int count = (from e in db.TestDefs
                             where object.Equals(e.ParentID, this.ParentID) && e.Name == this.Name.Trim()
                             select e).Count();

                if (count > 0)
                {
                    throw new Exception("Trùng tên");
                }
            }
        }
        private void ListCampaign()
        {
            RedBloodDataContext db = new RedBloodDataContext();
            string url = RedBloodSystem.Url4CollectDetailRpt;
            string url2 = RedBloodSystem.Url4CollectDetailRpt2;

            //var v = from r in db.Donations
            //        where ucDateRange.FromDate <= r.CollectedDate.Value.Date
            //        && r.CollectedDate.Value.Date <= ucDateRange.ToDate
            //        select new
            //        {
            //            ID = r.Campaign.ID,
            //            Name = r.Campaign.Name,
            //            Link = url + "CampaignID=" + r.CampaignID.ToString(),
            //            Name2 = "Báo cáo có tên KTV",
            //            Link2 = url2 + "CampaignID=" + r.CampaignID.ToString(),
            //        }
            //        ;

            //ListView1.DataSource = v.Distinct();

            var v = db.Donations.Where(r => ucDateRange.FromDate <= r.CollectedDate.Value.Date
                    && r.CollectedDate.Value.Date <= ucDateRange.ToDate)
                    .Select(r => r.Campaign)
                    .Distinct()
                    .ToList()
                    .OrderBy(r => r.ID)
                    .Select(r => new
                    {
                        ID = r.ID,
                        Name = r.Name,
                        Link = url + "CampaignID=" + r.ID.ToString(),
                        Name2 = "Báo cáo có tên KTV",
                        Link2 = url2 + "CampaignID=" + r.ID.ToString(),
                        r.Type
                    }).ToList()
                    ;

            ListView1.DataSource = v;

            ListView1.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            PrintSettingBLL.Reload();

            string strPackList = Request["PackList"];
            List<Guid> packIDList = new List<Guid>();
            if (!string.IsNullOrEmpty(strPackList))
            {
                var strArr = strPackList.Split(',');
                foreach (var item in strArr)
                {
                    Guid id;
                    if (Guid.TryParse(item, out id))
                    {
                        packIDList.Add(id);
                    }
                }
            }

            RedBloodDataContext db = new RedBloodDataContext();
            var pL = db.Packs.Where(r => r.Donation.TestResultStatus == Donation.TestResultStatusX.Negative
                && packIDList.Contains(r.ID))
                .OrderBy(r => r.ProductCode)
                .ThenBy(r => r.DIN).ToList();

            foreach (var item in pL)
            {
                Panel p = new Panel();
                p.Style.Add("position", "relative");
                p.Style.Add("page-break-after", "always");
                p.Style.Apply(PrintSettingBLL.FinalLabel.PaperSize);
                p.Style.Add("border", "1px solid white");
                divCon.Controls.Add(p);

                AddControl(item, p);
            }
        }
partial         void OnValidate(System.Data.Linq.ChangeAction action)
        {
            if (action == System.Data.Linq.ChangeAction.Insert
                || action == System.Data.Linq.ChangeAction.Update)
            {
                if (string.IsNullOrEmpty(this.Name) ||
                 string.IsNullOrEmpty(this.Name.Trim()))
                    throw new Exception("Nhập danh mục");

                RedBloodDataContext db = new RedBloodDataContext();

                int count = (from cats in db.SideEffects
                             where cats.ID != this.ID && object.Equals(cats.ParentID, this.ParentID)
                             && cats.Name.Trim() == this.Name.Trim()
                             select cats).Count();

                if (count > 0)
                {
                    throw new Exception("Trùng tên");
                }

                SideEffectBLL.SetFullname(this);
            }
        }
Beispiel #5
0
 protected void LinqDataSourceDINIn_Selecting(object sender, LinqDataSourceSelectEventArgs e)
 {
     RedBloodDataContext db = new RedBloodDataContext();
     var list = db.Donations.Where(r => DINInList.Contains(r.DIN)).ToList();
     list.Reverse();
     e.Result = list;
 }
Beispiel #6
0
 protected void LinqDataSourceProductOut_Selecting(object sender, LinqDataSourceSelectEventArgs e)
 {
     RedBloodDataContext db = new RedBloodDataContext();
     e.Result = db.Products.Where(r => ProductCodeOutList.Contains(r.Code));
 }
 protected void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs e)
 {
     RedBloodDataContext db = new RedBloodDataContext();
 }
        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();
        }
 protected void LinqDataSourceDINIn_Selecting(object sender, LinqDataSourceSelectEventArgs e)
 {
     RedBloodDataContext db = new RedBloodDataContext();
     var list = db.Donations.Where(r => DINInList.Contains(r.DIN)).ToList();
     list.Reverse();
     e.Result = list.Select(r => new
     {
         r.DIN,
         TR = r.TestResultStatus == Donation.TestResultStatusX.Positive ? "DT" : "",
     });
 }
        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 orderList = db.Orders.Where(r => r.Date.Value >= dtFrom && r.Date.Value <= dtTo)
                .ToList()
                .Where(r =>
                    (org == null || (r.OrgID == org.ID))
                );

            var v = orderList
                .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),
                })
                .OrderBy(r => r.ProductDesc);

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

            GridView2.DataSource = orderList.OrderByDescending(r => r.Date).ToList().Select(r => new
            {
                ID = r.ID,
                Date = r.Date.ToStringVN_Hour(),
                OrgName = r.Org != null ? r.Org.Name : "",
                Total = r.PackOrders.Count.ToString(),
                Actor = r.Actor,
                Note = r.Note,
            });
            GridView2.DataBind();
        }
Beispiel #11
0
        protected void LinqDataSourceProductIn_Selecting(object sender, LinqDataSourceSelectEventArgs e)
        {
            RedBloodDataContext db = new RedBloodDataContext();

            string productCode = ProductCodeInList.FirstOrDefault();
            if (string.IsNullOrEmpty(productCode))
            {
                e.Cancel = true;
            }
            else
            {
                string productCodeShort = productCode.Substring(0, productCode.Length - 2);
                e.Result = db.Products.Where(r => r.Code.Contains(productCodeShort)).Select(r => new
                {
                    Code = productCode,
                    r.Description
                });
            }
        }
Beispiel #12
0
        protected void LinqDataSource3_Selecting(object sender, LinqDataSourceSelectEventArgs e)
        {
            RedBloodDataContext db = new RedBloodDataContext();

            e.Result = GetData(null);
        }
        protected void LinqDataSourceSummary_Selecting(object sender, LinqDataSourceSelectEventArgs e)
        {
            if (CampaignDetail1.CampaignID > 0)
            {
                RedBloodDataContext db = new RedBloodDataContext();
                var v = db.Donations
                    .Where(r => r.OrgPackID != null && r.CampaignID == CampaignDetail1.CampaignID)
                    ;

                //TODO: TR.ToList();
                var v1 = new List<TR>((TR[])Enum.GetValues(typeof(TR)))
                    .Select(r => new
                    {
                        TR = r.Description(),
                        HIV = v.Where(r1 => r1.TR_HIV.Value == r).Count(),
                        HCV = v.Where(r1 => r1.TR_HCV_Ab.Value == r).Count(),
                        HBsAg = v.Where(r1 => r1.TR_HBs_Ag.Value == r).Count(),
                        Syphilis = v.Where(r1 => r1.TR_Syphilis.Value == r).Count(),
                        Malaria = v.Where(r1 => r1.TR_Malaria.Value == r).Count(),
                    })
                    .ToList()
                    ;

                e.Result = v1;
            }
            else { e.Cancel = true; }
        }
        protected void LinqDataSourcePack_Selecting(object sender, LinqDataSourceSelectEventArgs e)
        {
            if (CampaignDetail1.CampaignID > 0)
            {
                RedBloodDataContext db = new RedBloodDataContext();

                //var v = db.Donations.Where(r => r.CampaignID == CampaignDetail1.CampaignID)
                //    .Where(r => r.Status == Donation.StatusX.HasPack_UnLock)
                //    .ToList();

                var v = DonationBLL.GetUnLock(CampaignDetail1.CampaignID);

                var FilterHBsAg = ViewState["FilterHBsAg"];
                if (FilterHBsAg != null && !string.IsNullOrEmpty(FilterHBsAg.ToString()))
                {
                    v = v.Where(r => r.TR_HBs_Ag == (TR)FilterHBsAg.ToString().ToInt()).ToList();
                }

                var FilterHCV = ViewState["FilterHCV"];
                if (FilterHCV != null && !string.IsNullOrEmpty(FilterHCV.ToString()))
                {
                    v = v.Where(r => r.TR_HCV_Ab == (TR)FilterHCV.ToString().ToInt()).ToList();
                }

                var FilterHIV = ViewState["FilterHIV"];
                if (FilterHIV != null && !string.IsNullOrEmpty(FilterHIV.ToString()))
                {
                    v = v.Where(r => r.TR_HIV == (TR)FilterHIV.ToString().ToInt()).ToList();
                }

                var FilterSyphilis = ViewState["FilterSyphilis"];
                if (FilterSyphilis != null && !string.IsNullOrEmpty(FilterSyphilis.ToString()))
                {
                    v = v.Where(r => r.TR_Syphilis == (TR)FilterSyphilis.ToString().ToInt()).ToList();
                }

                var FilterMalaria = ViewState["FilterMalaria"];
                if (FilterMalaria != null && !string.IsNullOrEmpty(FilterMalaria.ToString()))
                {
                    v = v.Where(r => r.TR_Malaria == (TR)FilterMalaria.ToString().ToInt()).ToList();
                }

                e.Arguments.TotalRowCount = v.Count();

                var v2 = v.OrderBy(r => r.DIN).Skip(GridView1.PageIndex * GridView1.PageSize)
                    .Take(GridView1.PageSize).ToList();

                var v3 = v2
                    .ToList()
                    .Select(r => new
                    {
                        r.DIN,
                        r.Status,
                        Name = r.People.Name,
                        CollectedDate = r.CollectedDate.ToStringVN_Hour(),
                        r.BloodGroupDesc,
                        r.BloodGroup,
                        HIV = (int)r.TR_HIV,
                        HCV_Ab = (int)r.TR_HCV_Ab,
                        HBs_Ag = (int)r.TR_HBs_Ag,
                        Syphilis = (int)r.TR_Syphilis,
                        Malaria = (int)r.TR_Malaria,
                    }).ToList();

                e.Result = v3;

                PanelAllNeg.Visible = v.Count() > 0;
                lblTotal.Text = v.Count().ToString();

            }
            else { e.Cancel = true; }
        }
        protected void LinqDataSourcePackLock_Selecting(object sender, LinqDataSourceSelectEventArgs e)
        {
            if (CampaignDetail1.CampaignID > 0)
            {
                RedBloodDataContext db = new RedBloodDataContext();

                var v1 = db.Packs.Where(r => r.Donation.CampaignID == CampaignDetail1.CampaignID
                    && r.Status == Pack.StatusX.Delivered).Select(r => r.DIN).ToList().Distinct();

                var v = db.Donations.Where(r => v1.Contains(r.DIN)).ToList()
                    .ToList()
                    .Select(r => new
                    {
                        r.DIN,
                        r.Status,
                        Name = r.People.Name,
                        CollectedDate = r.CollectedDate.ToStringVN_Hour(),
                        r.BloodGroupDesc,
                        HIV = r.TR_HIV.Description(),
                        HCV_Ab = r.TR_HCV_Ab.Description(),
                        HBs_Ag = r.TR_HBs_Ag.Description(),
                        Syphilis = r.TR_Syphilis.Description(),
                        Malaria = r.TR_Malaria.Description(),
                    });

                e.Result = v;
            }
            else { e.Cancel = true; }
        }
        public object GetData(bool? IsNeg)
        {
            RedBloodDataContext db = new RedBloodDataContext();
            db.CommandTimeout = 3600;

            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;
        }
partial         void OnValidate(System.Data.Linq.ChangeAction action)
        {
            if (action == System.Data.Linq.ChangeAction.Insert
                || action == System.Data.Linq.ChangeAction.Update)
            {
                if (string.IsNullOrEmpty(this.Name) ||
                    string.IsNullOrEmpty(this.Name.Trim()))
                    throw new Exception("Nhập họ và tên.");

                if (string.IsNullOrEmpty(this.CMND) ||
                    string.IsNullOrEmpty(this.CMND.Trim()))
                { }
                else
                {
                    if (this.CMND.Length < 9)
                        throw new Exception("Số CMND phải từ 9 số trở lên.");

                    RedBloodDataContext db = new RedBloodDataContext();

                    int count = (from e in db.Peoples
                                 where object.Equals(e.CMND, this.CMND.Trim()) && e.ID != this.ID
                                 select e).Count();

                    if (count > 0)
                    {
                        throw new Exception("Trùng số CMND với người khác. " + this.CMND.Trim());
                    }
                }
            }
        }