Ejemplo n.º 1
0
 public void SetOrgID(string value)
 {
     value = value.Trim();
     if (String.IsNullOrEmpty(value))
     {
         OrgID = null;
     }
     else
     {
         Org g = OrgBLL.GetByName(value);
         if (g == null)
         {
             throw new Exception("Nhập sai tên đơn vị.");
         }
         else
         {
             OrgID = g.ID;
         }
     }
 }
Ejemplo n.º 2
0
        private bool LoadFromGUI(Campaign p)
        {
            bool isDone = true;

            try
            {
                p.Name = txtName.Text.Trim();
                divErrName.Attributes["class"] = "hidden";
            }
            catch (Exception ex)
            {
                divErrName.InnerText           = ex.Message;
                divErrName.Attributes["class"] = "err";
                isDone = false;
            }

            p.Est = txtEst.Text.ToIntNullable();


            try
            {
                p.Date = txtDate.Text.ToDatetimeFromVNFormat();
                divErrDate.Attributes["class"] = "hidden";
            }
            catch (Exception ex)
            {
                divErrDate.Attributes["class"] = "err";
                divErrDate.InnerText           = ex.Message;
                isDone = false;
            }

            //if (ddlSource.SelectedValue.ToInt() == 0)
            //    p.SourceID = null;
            //else
            //    p.SourceID = ddlSource.SelectedValue.ToInt();

            try
            {
                p.SourceID = ddlSource.SelectedValue.ToInt();
                divErrSrc.Attributes["class"] = "hidden";
            }
            catch (Exception ex)
            {
                divErrSrc.Attributes["class"] = "err";
                divErrSrc.InnerText           = ex.Message;
                isDone = false;
            }

            if (chkInfiCam.Checked)
            {
                p.Type = Campaign.TypeX.Long_run;
            }
            else
            {
                p.Type = Campaign.TypeX.Short_run;
            }

            try
            {
                //p.CoopOrg = OrgBLL.GetByName(txtCoopOrgName.Text.Trim());
                p.CoopOrgID = OrgBLL.GetByName(txtCoopOrgName.Text.Trim()).ID;
                divErrCoopOrgName.Attributes["class"] = "hidden";
            }
            catch (Exception ex)
            {
                divErrCoopOrgName.Attributes["class"] = "err";
                divErrCoopOrgName.InnerText           = ex.Message;
                isDone = false;
            }

            try
            {
                //p.HostOrg = OrgBLL.GetByName(txtHostOrgName.Text.Trim());
                p.HostOrgID = OrgBLL.GetByName(txtHostOrgName.Text.Trim()).ID;
                divErrHostOrgName.Attributes["class"] = "hidden";
            }
            catch (Exception ex)
            {
                divErrHostOrgName.Attributes["class"] = "err";
                divErrHostOrgName.InnerText           = ex.Message;
                isDone = false;
            }

            p.ContactName  = txtContactName.Text;
            p.ContactPhone = txtContactPhone.Text;
            p.ContactTitle = txtContactTitle.Text;

            p.Note = txtNote.Text;

            return(isDone);
        }
Ejemplo n.º 3
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();
        }