public Pais_TO GetByCode(Pais_TO pTO) { try { return(new Pais_DAO().GetByCode(pTO)); } catch (Exception) { throw; } }
public bool Delete(Pais_TO pTO) { bool retorno = false; try { retorno = new Pais_DAO().Delete(pTO); } catch (Exception) { throw; } return(retorno); }
public List <Pais_TO> SearchAll(Pais_TO pTO) { string condicao = ""; try { // implementa a condição de procura condicao += ""; return(new Pais_DAO().SearchAll(condicao)); } catch (Exception) { throw; } }
internal List <Pais_TO> SearchAll(string pCondicao) { SqlConnection connection = null; try { connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString); connection.Open(); } catch (Exception) { throw; } SqlCommand command = null; SqlDataReader reader = null; string sql = " SELECT * FROM vcrm_pais "; List <Pais_TO> collection = new List <Pais_TO>(); try { command = new SqlCommand(sql, connection); reader = command.ExecuteReader(); while (reader.Read()) { Pais_TO PaisTO = new Pais_TO(); PaisTO.pai_codigo = Convert.ToInt32(reader["pai_codigo"]); PaisTO.pai_nome = Convert.ToString(reader["pai_nome"]); PaisTO.pai_continente = Convert.ToString(reader["pai_continente"]); collection.Add(PaisTO); } } catch (Exception) { throw; } finally { reader.Close(); command.Dispose(); connection.Close(); connection.Dispose(); } return(collection); }
internal bool Save(Pais_TO pTO) { SqlConnection connection = null; try { connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString); connection.Open(); } catch (Exception) { throw; } SqlCommand command = null; bool retorno = false; string sql = "INSERT INTO vcrm_pais" + " ( pai_codigo " + ", pai_nome " + ", pai_continente) " + "VALUES " + "( @pai_codigo " + " , @pai_nome " + " , @pai_continente ) "; try { command = new SqlCommand(sql, connection); command.Parameters.AddWithValue("@pai_codigo", pTO.pai_codigo); command.Parameters.AddWithValue("@pai_nome", pTO.pai_nome); command.Parameters.AddWithValue("@pai_continente", pTO.pai_continente); command.ExecuteNonQuery(); retorno = true; } catch (Exception) { throw; } finally { command.Dispose(); connection.Close(); connection.Dispose(); } return(retorno); }
internal Pais_TO GetByCode(Pais_TO pTO) { SqlConnection connection = null; try { connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString); connection.Open(); } catch (Exception) { throw; } SqlCommand command = null; SqlDataReader reader = null; string sql = " SELECT * FROM vcrm_pais "; try { command = new SqlCommand(sql, connection); reader = command.ExecuteReader(); if (reader.Read()) { pTO.pai_codigo = Convert.ToInt32(reader["pai_codigo"]); pTO.pai_nome = Convert.ToString(reader["pai_nome"]); pTO.pai_continente = Convert.ToString(reader["pai_continente"]); } } catch (Exception) { throw; } finally { reader.Close(); command.Dispose(); connection.Close(); connection.Dispose(); } return(pTO); }
public bool Save(bool pOpcao, Pais_TO pTO) { bool retorno = false; try { if (pOpcao) { retorno = new Pais_DAO().Save(pTO); } else { retorno = new Pais_DAO().Update(pTO); } } catch (Exception) { throw; } return(retorno); }
internal bool Delete(Pais_TO pTO) { SqlConnection connection = null; try { connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString); connection.Open(); } catch (Exception) { throw; } SqlCommand command = null; bool retorno = false; string sql = "DELETE FROM vcrm_pais" + "WHERE ... "; try { command = new SqlCommand(sql, connection); command.ExecuteNonQuery(); retorno = true; } catch (Exception) { throw; } finally { command.Dispose(); connection.Close(); connection.Dispose(); } return(retorno); }