Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DateTime dtNow      = DateTime.Now;
            string   todaysDate = dtNow.ToString("MM/dd/yyyy");
            txtEntryDate.Text = todaysDate;
            clnDate.Visible   = false;

            //Load HRS & MINS in the Bike & Swimming dropdown lists
            for (int i = 0; i <= 24; i++)
            {
                ddlHrsBike.Items.Add(i.ToString());
                ddlHrsSwim.Items.Add(i.ToString());
            }
            for (int i = 0; i <= 59; i++)
            {
                ddlMinsBike.Items.Add(i.ToString());
                ddlMinsSwim.Items.Add(i.ToString());
            }

            //determine user who is currently logged in
            lblCurrUser.Text = Page.User.Identity.Name;

            DailyWorkout thisDaysWorkout = new DailyWorkout();
            //retrieve this users Workout for todays date if one exists then places it on the screen
            thisDaysWorkout = WorkoutDB.RetrieveScreenFields(dtNow, Page.User.Identity.Name);
            PopulateScreenFields(thisDaysWorkout);

            // Write thisDaysWorkout to Session State
            Session["sessThisDaysWorkout"] = thisDaysWorkout;
            lblLoggedInUser.Text           = Page.User.Identity.Name;
        }
    }
Пример #2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            if (Session["sessThisDaysWorkout"] != null)
            {
                thisDaysWorkout = (DailyWorkout)Session["sessThisDaysWorkout"];
            }

            thisDaysWorkout.TrainingDate = Convert.ToDateTime(txtEntryDate.Text);
            thisDaysWorkout.WorkoutType  = ddlWorkoutTypes.SelectedValue;

            thisDaysWorkout.TotalMilesRun   = txtTotalMilesRun.Text;
            thisDaysWorkout.QualityMilesRun = txtQualityMilesRun.Text;

            int tempBikeMins =
                (Convert.ToInt32(ddlMinsBike.SelectedValue))
                +
                (Convert.ToInt32(ddlHrsBike.SelectedValue) * 60);
            thisDaysWorkout.BikeMins = Convert.ToString(tempBikeMins);

            int tempSwimMins =
                (Convert.ToInt32(ddlMinsSwim.SelectedValue))
                +
                (Convert.ToInt32(ddlHrsSwim.SelectedValue) * 60);
            thisDaysWorkout.SwimMins = Convert.ToString(tempSwimMins);

            thisDaysWorkout.OverallWorkoutDescription = txtWorkoutDesc.Text;

            if (thisDaysWorkout.insertOrUpdateFlag == "Update")
            {
                WorkoutObjectDB.UpdateWorkoutDay(thisDaysWorkout);
            }
            //SqlDataSource3.Update();
            else
            {
                WorkoutObjectDB.InsertWorkoutDay(thisDaysWorkout);
            }
            //SqlDataSource2.Insert();
            //SqlDataSource3.Insert();

            lblTrainingInfoUpdate.Text = "Training database was successfully updated for " + txtEntryDate.Text;
            //thisDaysWorkout = new DailyWorkout();

            Session.Remove("sessThisDaysWorkout");
            // Write thisDaysWorkout to Session State
            thisDaysWorkout = WorkoutDB.RetrieveScreenFields(Convert.ToDateTime(txtEntryDate.Text), Page.User.Identity.Name);

            PopulateScreenFields(thisDaysWorkout);
            // Write thisDaysWorkout to Session State
            Session["sessThisDaysWorkout"] = thisDaysWorkout;
        }
    }
Пример #3
0
    protected void clnDate_SelectionChanged(object sender, EventArgs e)
    {
        txtEntryDate.Text    = clnDate.SelectedDate.ToShortDateString();
        clnDate.Visible      = false;
        ibtnCalendar.Visible = true;

        thisDaysWorkout = WorkoutDB.RetrieveScreenFields(clnDate.SelectedDate, Page.User.Identity.Name);
        PopulateScreenFields(thisDaysWorkout);
        Session.Remove("sessThisDaysWorkout");
        // Write thisDaysWorkout to Session State
        Session["sessThisDaysWorkout"] = thisDaysWorkout;
    }