public Destino_TO GetByCode(Destino_TO pTO) { try { return(new Destino_DAO().GetByCode(pTO)); } catch (Exception) { throw; } }
internal List <Destino_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_destino "; List <Destino_TO> collection = new List <Destino_TO>(); try { command = new SqlCommand(sql, connection); reader = command.ExecuteReader(); while (reader.Read()) { Destino_TO DestinoTO = new Destino_TO(); DestinoTO.des_codigo = Convert.ToInt32(reader["des_codigo"]); DestinoTO.des_nome = Convert.ToString(reader["des_nome"]); DestinoTO.TipoDestinoTO = new TipoDestino_TO(); DestinoTO.TipoDestinoTO.tde_codigo = Convert.ToInt32(reader["tde_codigo"]); DestinoTO.CidadeTO = new Cidade_TO(); DestinoTO.CidadeTO.cid_codigo = Convert.ToInt32(reader["cid_codigo"]); collection.Add(DestinoTO); } } catch (Exception) { throw; } finally { reader.Close(); command.Dispose(); connection.Close(); connection.Dispose(); } return(collection); }
internal bool Save(Destino_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_destino" + " ( des_codigo " + ", des_nome " + ", tde_codigo " + ", cid_codigo) " + "VALUES " + "( @des_codigo " + " , @des_nome " + " , @tde_codigo " + " , @cid_codigo ) "; try { command = new SqlCommand(sql, connection); command.Parameters.AddWithValue("@des_codigo", pTO.des_codigo); command.Parameters.AddWithValue("@des_nome", pTO.des_nome); command.Parameters.AddWithValue("@tde_codigo", pTO.TipoDestinoTO.tde_codigo); command.Parameters.AddWithValue("@cid_codigo", pTO.CidadeTO.cid_codigo); command.ExecuteNonQuery(); retorno = true; } catch (Exception) { throw; } finally { command.Dispose(); connection.Close(); connection.Dispose(); } return(retorno); }
public bool Delete(Destino_TO pTO) { bool retorno = false; try { retorno = new Destino_DAO().Delete(pTO); } catch (Exception) { throw; } return(retorno); }
public List <Destino_TO> SearchAll(Destino_TO pTO) { string condicao = ""; try { // implementa a condição de procura condicao += ""; return(new Destino_DAO().SearchAll(condicao)); } catch (Exception) { throw; } }
internal Destino_TO GetByCode(Destino_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_destino "; try { command = new SqlCommand(sql, connection); reader = command.ExecuteReader(); if (reader.Read()) { pTO.des_codigo = Convert.ToInt32(reader["des_codigo"]); pTO.des_nome = Convert.ToString(reader["des_nome"]); pTO.TipoDestinoTO = new TipoDestino_TO(); pTO.TipoDestinoTO.tde_codigo = Convert.ToInt32(reader["tde_codigo"]); pTO.CidadeTO = new Cidade_TO(); pTO.CidadeTO.cid_codigo = Convert.ToInt32(reader["cid_codigo"]); } } catch (Exception) { throw; } finally { reader.Close(); command.Dispose(); connection.Close(); connection.Dispose(); } return(pTO); }
public bool Save(bool pOpcao, Destino_TO pTO) { bool retorno = false; try { if (pOpcao) { retorno = new Destino_DAO().Save(pTO); } else { retorno = new Destino_DAO().Update(pTO); } } catch (Exception) { throw; } return(retorno); }
internal bool Delete(Destino_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_destino" + "WHERE ... "; try { command = new SqlCommand(sql, connection); command.ExecuteNonQuery(); retorno = true; } catch (Exception) { throw; } finally { command.Dispose(); connection.Close(); connection.Dispose(); } return(retorno); }