private string GetAddressId(string pAddress, string pCity, string pState, string pZip, string pCountryId, PostgreSQL_DB pPostgres) { NpgsqlDataReader query; string p_city_id = GetId("select id from tbl_cities where name like '" + pCity.Replace("'", "''") + "'", pPostgres); query = pPostgres.Select("select distinct id " + "from tbl_addresses where address like '" + pAddress.Replace("'", "''") + "' and city_id = " + p_city_id + " and zip like '" + pZip + "' and country_id=" + NVL(pCountryId) + ";"); string pom; while (query.Read()) { pom = query[0].ToString(); query.Dispose(); return("'" + pom + "'"); } query.Dispose(); if (pAddress != "") { string city_id = GetId("select id from tbl_cities where name like '" + pCity.Replace("'", "''") + "'", pPostgres); string pomStateId = GetId("select id from tbl_states where name like '" + pState + "'", pPostgres); pPostgres.Insert("insert into tbl_addresses(state_id, address, city_id, zip) values(" + pomStateId + ",'" + pAddress.Replace("'", "''") + "'," + city_id + ",'" + pZip + "');"); string p_address_id = GetId("select max(id) from tbl_addresses", pPostgres); return(p_address_id); } else { return("null"); } }
private string GetVenueId(string p_venue_name, string p_venue_address, string p_venue_city, string p_venue_stateid, string p_venue_zip, string p_venue_phone, string p_venue_website, PostgreSQL_DB pPostgres) { NpgsqlDataReader query; query = pPostgres.Select("select distinct id " + "from tbl_venues where name like '" + p_venue_name.Replace("'", "''") + "' and website like '%" + WebUtility.UrlDecode(p_venue_website) + "%';"); string pom; while (query.Read()) { pom = query[0].ToString(); query.Dispose(); return("'" + pom + "'"); } query.Dispose(); if (p_venue_name != "") { string p_city_id = GetId("select id from tbl_cities where name like '" + p_venue_city.Replace("'", "''") + "'", pPostgres); pPostgres.Insert("insert into tbl_addresses(state_id, address, city_id, zip) values('" + p_venue_stateid + "','" + p_venue_address + "'," + p_city_id + ",'" + p_venue_zip + "');"); string p_address_id = GetId("select max(id) from tbl_addresses", pPostgres); pPostgres.Insert("insert into tbl_venues(name, website, address_id) values('" + p_venue_name.Replace("'", "''") + "','" + WebUtility.UrlDecode(p_venue_website) + "','" + p_address_id + "');"); string p_venue_id = GetId("select max(id) from tbl_venues", pPostgres); var s = p_venue_phone; var c = new[] { '(', ')', '-', ' ' }; pPostgres.Insert("insert into venue_contact_type(contact_type_id, venue_id, value) values('2','" + p_venue_id + "','" + Remove(s, c) + "');"); return("'" + p_venue_id + "'"); } else { return("null"); } }
private string GetLevel(string pLevel, PostgreSQL_DB pPostgres) { NpgsqlDataReader query; query = pPostgres.Select("select distinct id from tbl_levels where name like '" + pLevel + "';"); string pom; while (query.Read()) { pom = query[0].ToString(); query.Dispose(); return("'" + pom + "'"); } query.Dispose(); return("null"); }
private string GetId(string pParam, PostgreSQL_DB pPostgres) { NpgsqlDataReader query; query = pPostgres.Select("select distinct id " + "from tbl_playlist_workshop_levels where name like '" + pParam + "';"); string pom; while (query.Read()) { pom = query[0].ToString(); query.Dispose(); return(pom); } return(null); }