예제 #1
0
        public ErrorCode AddMember(Member member)
        {
            if (string.IsNullOrEmpty(member.EmailAddress))
                return ErrorCode.ErrorWhileMemberRegistrationEmailEmpty;

            if (string.IsNullOrEmpty(member.Password))
                return ErrorCode.ErrorWhileMemberRegistrationPasswordEmpty;

            ErrorCode errorCode= _memberRepository.AddMember(member);
            if (errorCode == ErrorCode.None)
            {
                Save();
            }
            return errorCode;
        }
예제 #2
0
 public void Update(Member member)
 {
     _memberRepository.Update(member);
 }
예제 #3
0
        /// <summary>
        /// updates database with new data
        /// </summary>
        /// <param name="member"></param>
        public static int UpdateMember(Member member)
        {
            using (SqlCeConnection con = DB.GetSqlCeConnection())
            {
                String query = "UPDATE Members " +
                           "SET CardNumber= @cardnumber, LastName= @lastname, " +
                           "FirstName = @firstname, Sex = @Sex, DOB = @dateofbirth, Street = @street, " +
                           "Suburb = @suburb, City = @city, PostalCode = @postalcode, HomePhone = @homephone, " +
                           "CellPhone = @cellphone, Email = @email, Occupation = @occupation, Notes = @notes, " +
                           "Image = @image, PersonalTrainer = @ptrainer "  +
                           "WHERE Id = @id";

                using (SqlCeCommand cmd = new SqlCeCommand(query, con))
                {
                    cmd.Parameters.AddWithValue("@id", member.MemberID);
                    cmd.Parameters.AddWithValue("@cardnumber", member.CardNumber);
                    cmd.Parameters.AddWithValue("@lastname", member.LName);
                    cmd.Parameters.AddWithValue("@firstname", member.FName);
                    cmd.Parameters.AddWithValue("@sex", member.Sex);
                    cmd.Parameters.AddWithValue("@dateofbirth", member.DateOfBirth);
                    cmd.Parameters.AddWithValue("@street", member.Street);
                    cmd.Parameters.AddWithValue("@suburb", member.Suburb);
                    cmd.Parameters.AddWithValue("@city", member.City);
                    cmd.Parameters.AddWithValue("@postalcode", member.PostalCode);
                    cmd.Parameters.AddWithValue("@homephone", member.HomePhone);
                    cmd.Parameters.AddWithValue("@cellphone", member.CellPhone);
                    cmd.Parameters.AddWithValue("@email", member.Email);
                    cmd.Parameters.AddWithValue("@occupation", member.Occupation);
                    cmd.Parameters.AddWithValue("@notes", member.Notes);
                    cmd.Parameters.AddWithValue("@image", member.Image);
                    cmd.Parameters.AddWithValue("@ptrainer", member.PersonalTrainer);

                    int rowsAffected = cmd.ExecuteNonQuery();
                    return rowsAffected;
                }
            }
        }
예제 #4
0
        /// <summary>
        /// returns a member
        /// </summary>
        /// <param name="memberID"></param>
        /// <returns></returns>
        public Member GetMember(int memberID)
        {
            Member member = new Member();

            using (SqlCeConnection con = DB.GetSqlCeConnection())
            {
                String query = " SELECT Members.Id, Members.CardNumber, Members.LastName, Members.FirstName, Members.DOB, Members.Sex, Members.Street, Members.Suburb, " +
                               " Members.City, Members.PostalCode, Members.CellPhone, Members.HomePhone, Members.Email, Members.Occupation, Members.Image, Members.Notes, " +
                               " PersonalTrainer " +
                               "FROM            Members LEFT OUTER JOIN " +
                               "  Trainers ON Members.PersonalTrainer = Trainers.Id "+
                               "WHERE        (Members.Id = @memberid)";

                using (SqlCeCommand cmd = new SqlCeCommand(query, con))
                {
                    cmd.Parameters.AddWithValue("@memberid", memberID);

                    SqlCeDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        member.LoadMember(reader);
                    }

                }
            }
            return member;
        }
예제 #5
0
        /// <summary>
        /// adds a new member
        /// </summary>
        /// <param name="member"></param>
        /// <returns>number of affected rows</returns>
        public static int AddNewMember(Member member)
        {
            using (SqlCeConnection con = DB.GetSqlCeConnection())
            {
                String query = "INSERT INTO Members (CardNumber, LastName, FirstName, Sex, DOB, Street, Suburb, City, PostalCode, HomePhone, CellPhone, Email, Occupation, Notes, Image) " +
                               "VALUES(@cardnumber, @lastname, @firstname, @sex, @dateofbirth, @street, @suburb, @city, @postalcode, @homephone, @cellphone, @email, @occupation, @notes, @image)";

                using (SqlCeCommand cmd = new SqlCeCommand(query, con))
                {
                   // cmd.Parameters.AddWithValue("@id", member.MemberID);
                    cmd.Parameters.AddWithValue("@cardnumber", member.CardNumber);
                    cmd.Parameters.AddWithValue("@lastname", member.LName);
                    cmd.Parameters.AddWithValue("@firstname", member.FName);
                    cmd.Parameters.AddWithValue("@sex", member.Sex);
                    cmd.Parameters.AddWithValue("@dateofbirth", member.DateOfBirth);
                    cmd.Parameters.AddWithValue("@street", member.Street);
                    cmd.Parameters.AddWithValue("@suburb", member.Suburb);
                    cmd.Parameters.AddWithValue("@city", member.City);
                    cmd.Parameters.AddWithValue("@postalcode", member.PostalCode);
                    cmd.Parameters.AddWithValue("@homephone", member.HomePhone);
                    cmd.Parameters.AddWithValue("@cellphone", member.CellPhone);
                    cmd.Parameters.AddWithValue("@email", member.Email);
                    cmd.Parameters.AddWithValue("@occupation", member.Occupation);
                    cmd.Parameters.AddWithValue("@notes", member.Notes);
                    cmd.Parameters.AddWithValue("@image", member.Image);

                    int rowsAffected = cmd.ExecuteNonQuery();
                    return rowsAffected;

                }
            }
        }