示例#1
0
        protected void gvSubs_SelectedIndexChanged(object sender, EventArgs e)
        {
            lblError.Visible = false;
            GridView row = (GridView)sender;
            int      id  = Convert.ToInt32(row.SelectedRow.Cells[5].Text);

            // get the data then show th panel
            using (ClubDBEntities club = new ClubDBEntities())
            {
                var result = club.getSubDetails(id);
                fvDetails.DataSource = result;
                fvDetails.DataBind();
                SubID = id;
                Where = "it.SubID = " + id;
                EntityDataSource1.Where = Where;
                EntityDataSource1.DataBind();
                gvVisits.DataBind();
                pnlSubDetails.Visible = true;
                pnlVisit.Visible      = false;

                Panel pnlInt = (Panel)fvDetails.FindControl("pnlInt");
                Panel pnlNut = (Panel)fvDetails.FindControl("pnlNut");
                if (result.ElementAt(0).BPressure == null && result.ElementAt(0).BSugar == null)
                {
                    if (pnlInt != null)
                    {
                        pnlInt.Visible = false;
                    }
                }
                else
                {
                    if (pnlInt != null)
                    {
                        pnlInt.Visible = true;
                    }
                }
                if (result.ElementAt(0).Fat == null && result.ElementAt(0).Weight == null && result.ElementAt(0).Hieght == null)
                {
                    if (pnlNut != null)
                    {
                        pnlNut.Visible = false;
                    }
                }
                else
                {
                    if (pnlInt != null)
                    {
                        pnlNut.Visible = true;
                    }
                }
            }
        }
示例#2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            using (ClubDBEntities club = new ClubDBEntities())
            {
                lblError.Visible = false;
                var sub = (from i in club.Subscribtions
                           where i.SubID == SubID
                           select i).First();
                if (sub.LeftDays - 1 < 0)
                {
                    // dont save
                    lblNo.Text       = "انتهت أيام الاشتراك، لا يمكنك اضافة زيارة";
                    pnlVisit.Visible = false;
                    return;
                }
                else
                {
                    sub.LeftDays--;
                    sub.AttDays++;
                    Visit visit = new Visit();
                    visit.ClientID   = CntID;
                    visit.SubID      = SubID;
                    visit.Date       = DateTime.Now.Date;
                    visit.SigninTime = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
                    visit.SizeAfter  = tbAfter.Text;
                    visit.SizeBefore = tbBefore.Text;
                    club.Visits.AddObject(visit);
                    club.SaveChanges();
                    var result = club.getSubDetails(SubID);
                    fvDetails.DataSource = result;
                    fvDetails.DataBind();
                }

                // refresh
                EntityDataSource1.DataBind();
                gvVisits.DataBind();

                pnlVisit.Visible = false;
            }
        }