protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         member = (Member)SessionController.Get(Constants.SESSION_MEMBER);
         //refresh calendar control
         cdrReadingDate.DataBind();
     }
 }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (!IsValid)
                return;
            if (chkDisclaimerYes.Checked != true)
            {
                ClientScript.RegisterStartupScript(typeof(string), "AgreeTerms", string.Format("alert('{0}');", "You have to agree to the terms & conditions"), true);
                return;
            }
                //set member properties and submit to server
            Member member = new Member();
            member.FirstName = txtFirstName.Text.Trim();
            member.LastName = txtLastName.Text.Trim();
            member.UserName = txtUserName.Text.Trim();
            member.Password = txtPassword.Text.Trim();
            member.Email = txtEmail.Text.Trim();
            member.Nationality = new Country();
            member.Nationality.ID = int.Parse(ddlNationality.SelectedValue);
            member.IsMaleGender = rblGender.SelectedValue == "1";
            member.BirthDate = cdrBirthDate.SelectedDate;
            member.MobilePhone = txtMobilePhone.Text.Trim();
            member.HomePhone = txtHomePhone.Text.Trim();
            member.Address = txtAddress.Text.Trim();
            member.ZipCode = txtZipCode.Text.Trim();
            member.State = int.Parse(ddlState.SelectedValue);
            member.NotifyByEmail = chkNotificationByEmail.Checked;
            member.NotifyBySMS = chkNotificationBySMS.Checked;

            try
            {
                string membershipNumber; bool isWaitlisted;
                int memberID = dataLayer.RegisterMember(member);
            }
            catch (FaultException<ApplicationFault> fault)
            {
                switch (fault.Detail.Code.ToString())
                {
                    case "1":
                        ClientScript.RegisterStartupScript(typeof(string), "RegisterMemberFail_1", string.Format("addColoredMessage('{0}', '{1}', 'Red');", vdsSummary.ClientID, string.Format(GetLocalResourceObject("Registration.UsernameExist").ToString())), true);
                        break;
                    case "2":
                        ClientScript.RegisterStartupScript(typeof(string), "RegisterMemberFail_2", string.Format("addColoredMessage('{0}', '{1}', 'Red');", vdsSummary.ClientID, string.Format(GetLocalResourceObject("Registration.EmailExist").ToString())), true);
                        break;
                    default:
                        ClientScript.RegisterStartupScript(typeof(string), "RegisterMemberFail_NA", string.Format("addColoredMessage('{0}', '{1}', 'Red');", vdsSummary.ClientID, string.Format(GetLocalResourceObject("Registration.UnhandledError").ToString())), true);
                        break;
                }

                return;
            }

            ClientScript.RegisterStartupScript(typeof(string), "RegisterMemberSuccess", string.Format("alert('{0}'); window.location.href='default.aspx';", "Member Registered Successfully"), true);
        }
예제 #3
0
        public Member AuthenticateMember(string userName, string password)
        {
            ExecutionUnit unit = new ExecutionUnit("AuthenticateMember");

            unit.AddParameter("@UserName", SqlDbType.VarChar, ParameterDirection.Input, userName);
            unit.AddParameter("@Password", SqlDbType.VarChar, ParameterDirection.Input, password);

            using (IDataReader reader = DatabaseAccessEngine.ExecuteDataReader(unit))
            {
                Member member = null;
                while (reader.Read())
                {
                    member = new Member();
                    member.ID = DatabaseAccessEngine.GetInt32(reader, "ID");
                    member.Status = DatabaseAccessEngine.GetBoolean(reader, "Status");
                    member.Password = DatabaseAccessEngine.GetString(reader, "Password");
                    member.UserName = DatabaseAccessEngine.GetString(reader, "Username");
                    member.FirstName = DatabaseAccessEngine.GetString(reader, "FirstName");
                    member.LastName = DatabaseAccessEngine.GetString(reader, "LastName");
                    member.BirthDate = DatabaseAccessEngine.GetDateTime(reader, "BirthDate");
                    member.Age = DatabaseAccessEngine.GetInt32(reader, "Age");
                    member.IsChild = member.Age <= Constants.ADULT_AGE;
                    member.PhotoFilePath = DatabaseAccessEngine.GetString(reader, "PhotoFilePath");
                    member.Email = DatabaseAccessEngine.GetString(reader, "Email");
                    member.IsMaleGender = DatabaseAccessEngine.GetBoolean(reader, "Gender");
                    member.NotifyBySMS = DatabaseAccessEngine.GetBoolean(reader, "NotifyBySMS");
                    member.NotifyByEmail = DatabaseAccessEngine.GetBoolean(reader, "NotifyByEmail");
                    member.MobilePhone = DatabaseAccessEngine.GetString(reader, "MobilePhone");
                    member.HomePhone = DatabaseAccessEngine.GetString(reader, "HomePhone");
                    member.State = DatabaseAccessEngine.GetInt32(reader, "State");
                    member.ZipCode = DatabaseAccessEngine.GetString(reader, "ZipCode");
                    member.Address = DatabaseAccessEngine.GetString(reader, "Address");
                    member.ActivityLevel = DatabaseAccessEngine.GetString(reader, "ActivityLevel");
                    member.ExerciseIntensityLevel = DatabaseAccessEngine.GetString(reader, "ExerciseIntensityLevel");
                    member.RegistrationDate = DatabaseAccessEngine.GetDateTime(reader, "RegistrationDate");

                    member.Nationality = new Country();
                    member.Nationality.ID = DatabaseAccessEngine.GetInt32(reader, "NationalityCountryID");
                    member.Nationality.Name = DatabaseAccessEngine.GetString(reader, "NationalityCountryName");
                    member.Nationality.FlagFilePath = DatabaseAccessEngine.GetString(reader, "NationalityCountryFlagFilePath");

                    break;
                }
                if (member == null)
                    return null;

                return member;
            }
        }
예제 #4
0
        public int RegisterMember(Member member)
        {
            ////calculate fitness value parameters
            //decimal bmi, bodyFat;
            //Helper.CalculateFitnessParameters(fitnessValue.Weight, fitnessValue.Height, (int)((TimeSpan)DateTime.Now.Subtract(member.BirthDate)).TotalDays / 365, member.IsMaleGender, out bmi, out bodyFat);
            //fitnessValue.BMI = bmi; fitnessValue.BodyFat = bodyFat;

            //prepare execution unit parameters and invoke stored procedure
            ExecutionUnit unit = new ExecutionUnit("RegisterMember");
            unit.AddParameter("@UserName", SqlDbType.VarChar, ParameterDirection.Input, member.UserName);
            unit.AddParameter("@Password", SqlDbType.VarChar, ParameterDirection.Input, member.Password);
            unit.AddParameter("@FirstName", SqlDbType.NVarChar, ParameterDirection.Input, member.FirstName);
            unit.AddParameter("@LastName", SqlDbType.NVarChar, ParameterDirection.Input, member.LastName);
            unit.AddParameter("@BirthDate", SqlDbType.DateTime, ParameterDirection.Input, member.BirthDate);
            unit.AddParameter("@Email", SqlDbType.VarChar, ParameterDirection.Input, member.Email);
            unit.AddParameter("@Nationality", SqlDbType.Int, ParameterDirection.Input, member.Nationality.ID);
            unit.AddParameter("@Gender", SqlDbType.Bit, ParameterDirection.Input, member.IsMaleGender ? 1 : 0);
            unit.AddParameter("@Status", SqlDbType.Bit, ParameterDirection.Input, 1);

            unit.AddParameter("@NotifyBySMS", SqlDbType.Bit, ParameterDirection.Input, member.NotifyBySMS ? 1 : 0);
            unit.AddParameter("@NotifyByEmail", SqlDbType.Bit, ParameterDirection.Input, member.NotifyByEmail ? 1 : 0);

            unit.AddParameter("@MobilePhone", SqlDbType.VarChar, ParameterDirection.Input, member.MobilePhone);
            unit.AddParameter("@HomePhone", SqlDbType.VarChar, ParameterDirection.Input, member.HomePhone);

            unit.AddParameter("@State", SqlDbType.VarChar, ParameterDirection.Input, member.State);
            unit.AddParameter("@ZipCode", SqlDbType.VarChar, ParameterDirection.Input, member.ZipCode);
            unit.AddParameter("@Address", SqlDbType.VarChar, ParameterDirection.Input, member.Address);
            unit.AddParameter("@RegistrationDate", SqlDbType.DateTime, ParameterDirection.Input, DateTime.Now);

            IDbDataParameter memberIDParam = unit.AddParameter("@MemberID", SqlDbType.Int, ParameterDirection.Output, null);
            IDbDataParameter errorCodeParam = unit.AddParameter("@ErrorCode", SqlDbType.Int, ParameterDirection.Output, null);

            DatabaseAccessEngine.ExecuteNonQuery(unit);

            //check if any unique check failed
            int errorCode = Convert.ToInt32(errorCodeParam.Value);
            if (errorCode != 0)
            {
                ApplicationFault fault = new ApplicationFault(errorCode);
                throw new FaultException<ApplicationFault>(fault, "Duplicate Member");
            }

            member.ID = Convert.ToInt32(memberIDParam.Value);

            //return generated member id
            return member.ID;
        }