Esempio n. 1
0
 private Address constructAddress()
 {
     Address newAddress = new Address();
     newAddress.Address1 = txtAddress1.Text;
     newAddress.City = txtCity.Text;
     newAddress.County = txtCounty.Text;
     newAddress.PostCode = txtPostcode.Text;
     newAddress.Country = "UK";
     return newAddress;
 }
Esempio n. 2
0
 private Address constructHomeAddress()
 {
     Address newAddress = new Address();
     newAddress.Address1 = txtHomeAddress1.Text;
     newAddress.City = txtHomeTown.Text;
     newAddress.County = txtHomeCounty.Text;
     newAddress.PostCode = txtHomePostCode.Text;
     newAddress.Country = "UK";
     return newAddress;
 }
Esempio n. 3
0
 private Address constructWorkAddress()
 {
     Address newAddress = new Address();
     newAddress.Address1 = txtWorkAddress1.Text;
     newAddress.City = txtWorkTown.Text;
     newAddress.County = txtWorkCounty.Text;
     newAddress.PostCode = txtWorkPostCode.Text;
     newAddress.Country = "UK";
     return newAddress;
 }
Esempio n. 4
0
        public void insertAddress(Address addressToAdd)
        {
            MySqlConnection connection = OpenConnection();
            if (connection == null)
                return;

            MySqlCommand insertCommand = new MySqlCommand(null, connection);
            insertCommand.CommandText = @"INSERT INTO address VALUES (@address1, @city, @county, @postcode, @country);";

            insertCommand.Parameters.AddWithValue("@address1", addressToAdd.Address1);
            insertCommand.Parameters.AddWithValue("@city", addressToAdd.City);
            insertCommand.Parameters.AddWithValue("@county", addressToAdd.County);
            insertCommand.Parameters.AddWithValue("@postcode", addressToAdd.PostCode);
            insertCommand.Parameters.AddWithValue("@country", "UK");

            Console.WriteLine("Executing: [ " + insertCommand.CommandText + "].");
            insertCommand.Prepare();
            insertCommand.ExecuteNonQuery();

            CloseConnection(connection);
        }
Esempio n. 5
0
        private Address selectAddress(String address1)
        {
            MySqlConnection connection = OpenConnection();
            if (connection == null)
                return null;

            MySqlCommand selectCommand = new MySqlCommand(null, connection);
            selectCommand.CommandText = "SELECT * FROM address WHERE Address_1 = @address1;";
            selectCommand.Parameters.AddWithValue("@address1", address1);

            selectCommand.Prepare();
            MySqlDataReader addressReader = selectCommand.ExecuteReader();

            Address newAddress = new Address();
            while (addressReader.Read())
            {
                newAddress = constructAddress(addressReader);
            }

            CloseConnection(connection);

            return newAddress;
        }
Esempio n. 6
0
 private Address constructMultipleAddress(MySqlDataReader addressReader, String prefix)
 {
     Address newAddress = new Address();
     newAddress.Address1 = addressReader.GetString(prefix + "1");
     newAddress.City = addressReader.GetString(prefix + "City");
     newAddress.County = addressReader.GetString(prefix + "County");
     newAddress.PostCode = addressReader.GetString(prefix + "PostCode");
     newAddress.Country = "UK";
     return newAddress;
 }
Esempio n. 7
0
 private Address constructAddress(MySqlDataReader addressReader)
 {
     Address newAddress = new Address();
     newAddress.Address1 = addressReader.GetString("Address_1");
     newAddress.City = addressReader.GetString("City");
     newAddress.County = addressReader.GetString("County");
     newAddress.PostCode = addressReader.GetString("PostCode");
     newAddress.Country = SafeGetString(addressReader, "Country");
     return newAddress;
 }