public void addUser(Models.User user)
        {
            String query = "INSERT INTO `user` (`id`, `email`, `password`, `dateOfBirth`, `address`, `gender`, `name`) VALUES (NULL, '" + user.email + "', '" + user.password + "', '" + user.dateOfBirth + "', '" + user.address + "', '" + user.gender + "', '" + user.name + "')";

            Console.WriteLine(query);

            MySqlConnection databaseConnection = new MySqlConnection(MysqlConnetionString);
            MySqlCommand    comandDatabase     = new MySqlCommand(query, databaseConnection);

            comandDatabase.CommandTimeout = 60;
            try
            {
                databaseConnection.Open();
                MySqlDataReader myReader = comandDatabase.ExecuteReader();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#2
0
        public void userAdd(String email, String password, String name, String address, String dateOfBirth, String gender)

        {
            Console.WriteLine(email);
            if (email == "")
            {
                throw new Exception("email is empty");
            }
            if (password == "")
            {
                throw new Exception("password is empty");
            }
            if (name == "")
            {
                throw new Exception("name is empty");
            }
            if (address == "")
            {
                throw new Exception("address is empty");
            }
            if (dateOfBirth == "")
            {
                throw new Exception("dateOfBirth is empty");
            }
            if (gender == "")
            {
                throw new Exception("gender is empty");
            }

            Models.User           user      = new Models.User(email, password, name, address, dateOfBirth, gender);
            Dal.DatabaseConnector connector = new Dal.DatabaseConnector();

            try
            {
                connector.addUser(user);
            }
            catch (Exception excp)
            {
                throw excp;
            }
        }