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; }
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; }
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; }
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); }
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; }
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; }
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; }