protected void btnSave_Click(object sender, EventArgs e)
 {
     MemberPedometerReading reading = new MemberPedometerReading();
     reading.Steps = Convert.ToInt64(txtSteps.Text.Trim());
     reading.AerobicSteps = Convert.ToInt64(txtAerobicSteps.Text.Trim());
     reading.AerobicDuration = Convert.ToDecimal(txtAerobicDuration.Text.Trim());
     reading.Distance = Convert.ToDecimal(txtDistance.Text.Trim());
     reading.Calories = Convert.ToDecimal(txtCalories.Text.Trim());
     reading.FatBurn = Convert.ToDecimal(txtFatBurn.Text.Trim());
     reading.ReadingDate = cdrReadingDate.SelectedDate;
     reading.ModelName = "HJ-120";
     reading.SerialNumber = "HJ1200123472";
     reading.Member = new Member();
     reading.Member.ID = member.ID;
     try
     {
         Int32 totalSteps = (Int32)dataLayer.AddPedometerReading(reading);
     }
     catch (FaultException<ApplicationFault> fault)
     {
     }
     ClientScript.RegisterStartupScript(typeof(string), "AddPedometerDataSuccess", string.Format("alert('{0}'); window.location.href='default.aspx';", "Member Registered Successfully"), true);
 }
Example #2
0
        public Int64 AddPedometerReading(MemberPedometerReading reading)
        {
            //prepare execution unit parameters and invoke stored procedure
            ExecutionUnit unit = new ExecutionUnit("AddPedometerReading");
            unit.AddParameter("@MemberID", SqlDbType.Int, ParameterDirection.Input, reading.Member.ID);
            unit.AddParameter("@ModelName", SqlDbType.VarChar, ParameterDirection.Input, reading.ModelName);
            unit.AddParameter("@SerialNumber", SqlDbType.NVarChar, ParameterDirection.Input, reading.SerialNumber);
            unit.AddParameter("@ReadingDate", SqlDbType.DateTime, ParameterDirection.Input, reading.ReadingDate);
            unit.AddParameter("@Steps", SqlDbType.BigInt, ParameterDirection.Input, reading.Steps);
            unit.AddParameter("@AerobicSteps", SqlDbType.BigInt, ParameterDirection.Input, reading.AerobicSteps);
            unit.AddParameter("@AerobicDuration", SqlDbType.Decimal, ParameterDirection.Input, reading.AerobicDuration);
            unit.AddParameter("@Distance", SqlDbType.Decimal, ParameterDirection.Input, reading.Distance);
            unit.AddParameter("@FatBurn", SqlDbType.Decimal, ParameterDirection.Input, reading.FatBurn);
            unit.AddParameter("@Calories", SqlDbType.Decimal, ParameterDirection.Input, reading.Calories);
              //  unit.AddParameter("@Status", SqlDbType.Bit, ParameterDirection.Input, 1);
            IDbDataParameter totalStepsParam = unit.AddParameter("@TotalSteps", SqlDbType.BigInt, ParameterDirection.Output, null);

            DatabaseAccessEngine.ExecuteNonQuery(unit);

            reading.TotalSteps = Convert.ToInt32(totalStepsParam.Value);

            //return total steps
            return reading.TotalSteps;
        }