Exemplo n.º 1
0
 public static long? AddPerson(Person person)
 {
     string _query = string.Format("INSERT INTO Person (FirstName, LastName, AddressID, DateOfBirth, PersonType, Email, Password) " +
         "VALUES('{0}', '{1}', {2}, '{3}', '{4}', '{5}', '{6}')",
         person.FirstName, person.LastName,
         person.Address.AddressID, person.DateOfBirth,
         person.PersonType, person.Email, person.Password);
     return CaseStudyDB.ExecuteNonQuery(_query);
 }
Exemplo n.º 2
0
        public static Person GetPersonFromReader(SqlCeDataReader reader)
        {
            if (reader != null)
            {
                Person person = new Person();
                person.PersonID = (long)reader["PersonID"];
                person.FirstName = reader["FirstName"].ToString();
                person.LastName = reader["LastName"].ToString();
                person.SetAddress(AddressDB.GetAddressFromReader(reader));
                person.DateOfBirth = DateTime.Parse(reader["DateOfBirth"].ToString());
                Person.PersonTypes personType;
                Enum.TryParse<Person.PersonTypes>(reader["PersonType"].ToString(), out personType);
                person.PersonType = personType;
                person.Email = reader["Email"].ToString();
                person.Password = reader["Password"].ToString();

                return person;
            }
            return null;
        }
Exemplo n.º 3
0
 public static void SetUser(Person person)
 {
     _currentUser = person;
 }
Exemplo n.º 4
0
 public static void Logout()
 {
     _currentUser = null;
 }
Exemplo n.º 5
0
        internal static void UpdatePerson(Person person)
        {
            string _query = string.Format("UPDATE Person " +
            "SET FirstName='{0}', LastName='{1}', AddressID={2}, DateOfBirth='{3}'," +
            " PersonType='{4}', Email='{5}', Password='******' WHERE PersonID = {7}",
            person.FirstName, person.LastName, person.Address.AddressID,
            person.DateOfBirth, person.PersonType, person.Email, person.Password, person.PersonID);

            CaseStudyDB.ExecuteNonQuery(_query);
        }