コード例 #1
0
        public static List <Country> CountryList()
        {
            DataBaseAdmin  dataBase   = new DataBaseAdmin();
            List <Country> ListReturn = new List <Country>();
            Country        country;

            try
            {
                dataBase.query("Select PaisCodigo, PaisNombre from Pais");
                dataBase.openConnection();
                dataBase.executeConnection();
                MySqlDataReader reader;
                reader = dataBase.Comando.ExecuteReader();
                while (reader.Read())
                {
                    country      = new Country();
                    country.code = (String)(reader["PaisCodigo"]);
                    country.name = (String)(reader["PaisNombre"]);
                    ListReturn.Add(country);
                }
                return(ListReturn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dataBase.closeConnection();
            }
        }
コード例 #2
0
        public static User SearchUser(String mail, String password)
        {
            User          user = null;
            DataBaseAdmin DB   = new DataBaseAdmin();

            try
            {
                String commandText = "select * from User where mail = @USER and password= @PASSWORD";
                DB.query(commandText);
                DB.Comando.Parameters.Clear();
                DB.Comando.Parameters.AddWithValue("@USER", mail);
                DB.Comando.Parameters.AddWithValue("@PASSWORD", password);
                DB.openConnection();
                DB.executeConnection();
                MySqlDataReader reader;
                reader = DB.Comando.ExecuteReader();
                while (reader.Read())
                {
                    user          = new User();
                    user.mail     = (String)(reader["mail"]);
                    user.password = (String)(reader["password"]);
                    user.id       = Int32.Parse(reader["id"].ToString());
                }
                return(user);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                DB.closeConnection();
            }
        }
コード例 #3
0
        public static List <City> CityList(String country)
        {
            DataBaseAdmin dataBase   = new DataBaseAdmin();
            List <City>   ListReturn = new List <City>();
            City          city;

            try
            {
                dataBase.query("Select CiudadID, CiudadNombre from Ciudad where PaisCodigo='" + country + "'");
                dataBase.openConnection();
                dataBase.executeConnection();
                MySqlDataReader reader;
                reader = dataBase.Comando.ExecuteReader();
                while (reader.Read())
                {
                    city             = new City();
                    city.countryCode = country;
                    city.name        = (String)(reader["CiudadNombre"]);
                    city.id          = int.Parse(reader["CiudadID"].ToString());
                    ListReturn.Add(city);
                }
                return(ListReturn);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dataBase.closeConnection();
            }
        }
コード例 #4
0
        public static bool InsertUser(User user)
        {
            bool          returnValue;
            DataBaseAdmin DB = new DataBaseAdmin();

            try
            {
                String commandText = "insert into User (mail, password) values (@USER, @PASSWORD)";
                DB.query(commandText);
                DB.Comando.Parameters.Clear();
                DB.Comando.Parameters.AddWithValue("@USER", user.mail);
                DB.Comando.Parameters.AddWithValue("@PASSWORD", user.password);
                DB.openConnection();
                DB.executeConnection();
                returnValue = true;
                return(returnValue);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                DB.closeConnection();
            }
        }