public static int ObterCodigoDoMunicipio(string NomeMunicipio, string Estado) { string sql = string.Empty; if (Estado.Length == 2) { sql = "select t.Codigo from Municipios t " + "inner join estados e " + "on e.codigo = t.codigoestado " + "where t.nome = @municipio and e.sigla = @estado"; } else { sql = "select t.Codigo from Municipios t " + "inner join estados e " + "on e.codigo = t.codigoestado " + "where t.nome = @municipio and e.nome = @estado"; } try { var banco = new BancosDeDados(EBancoDeDados.localidades); return(banco.Conexao.QueryFirst <int>(sql, new { municipio = NomeMunicipio, estado = Estado })); } catch (System.Exception ex) { throw new Exception(ex.Message); } }
public static string ObterCodigoDoEstado(string p_SiglaOuNome) { var saida = "Código não encontrado, verifique o nome!"; var cmd = new SpartacusMin.Database.Command(); if (p_SiglaOuNome.Length == 2) //Se tiver 2 caracteres é uma sigla { cmd.v_text = "select t.codigo from ESTADOS t where t.sigla = #parametro#"; p_SiglaOuNome = p_SiglaOuNome.ToUpper(); } else { cmd.v_text = "select t.codigo from ESTADOS t where t.Nome = #parametro#"; } cmd.AddParameter("parametro", SpartacusMin.Database.Type.STRING); cmd.SetValue("parametro", p_SiglaOuNome); var tabelaResultado = BancosDeDados.ObterTabelaDoBanco(cmd.GetUpdatedText()); if (tabelaResultado.Rows.Count != 0) { saida = tabelaResultado.Rows[0]["Codigo"].ToString(); } return(saida); }
public static SByte ObterCodigoDoEstado(string SiglaOuNome) { string sql = string.Empty; if (SiglaOuNome.Length == 2) //Se tiver 2 caracteres é uma sigla { sql = "select t.codigo from ESTADOS t where t.sigla = @parametro"; SiglaOuNome = SiglaOuNome.ToUpper(); } else { sql = "select t.codigo from ESTADOS t where t.Nome = @parametro"; } try { var banco = new BancosDeDados(EBancoDeDados.localidades); return(banco.Conexao.QueryFirst <SByte>(sql, new { parametro = SiglaOuNome })); } catch (System.Exception e) { throw new Exception($"Não foi possível efetuar a busca: {e.Message}"); } }
public Estado(string SiglaOuNome) { string sql = string.Empty; if (SiglaOuNome.Length == 2) //Se tiver 2 caracteres é uma sigla { sql = "select * from ESTADOS t where t.sigla = @parametro"; SiglaOuNome = SiglaOuNome.ToUpper(); } else { sql = "select * from ESTADOS t where t.Nome = @parametro"; } try { var banco = new BancosDeDados(EBancoDeDados.localidades); var estadoTemp = banco.Conexao.QueryFirst <Estado>(sql, new { parametro = SiglaOuNome }); this.Codigo = estadoTemp.Codigo; this.Nome = estadoTemp.Nome; this.Sigla = estadoTemp.Sigla; } catch (System.Exception ex) { throw new Exception(ex.Message); } }
public static IEnumerable <Municipio> ObterListaDeMunicipio(string Estado) { string sql = string.Empty; if (Estado.Length == 2) { sql = @"select m.* from Municipios m inner join Estados e on e.codigo = m.codigoestado where e.sigla = @parametro"; } else { sql = @"select m.* from Municipios m inner join Estados e on e.codigo = m.codigoestado where e.nome = @parametro"; } try { var banco = new BancosDeDados(EBancoDeDados.localidades); return(banco.Conexao.Query <Municipio>(sql, new { parametro = Estado.RemoverAcentos() })); } catch (System.Exception ex) { throw new Exception(ex.Message); } }
public Municipio(string NomeMunicipio, string Estado) { Municipio municipioTemp; string sql = string.Empty; if (Estado.Length == 2) { sql = "select m.* from estados e " + "inner join municipios m " + "on m.codigoestado = e.codigo " + "where m.nome = @municipio and e.sigla = @estado"; } else { sql = "select m.* from estados e " + "inner join municipios m " + "on m.codigoestado = e.codigo " + "where m.nome = @municipio and e.nome = @estado"; } try { var banco = new BancosDeDados(EBancoDeDados.localidades); municipioTemp = banco.Conexao.QueryFirst <Municipio>(sql, new { municipio = NomeMunicipio, estado = Estado }); } catch (System.Exception ex) { throw new Exception(ex.Message); } this.Codigo = municipioTemp.Codigo; this.CodigoEstado = municipioTemp.CodigoEstado; this.Nome = municipioTemp.Nome; }
private static int BuscarCodigoNoBanco(string query) { var saida = 0; DataTable tabelaResultado; tabelaResultado = BancosDeDados.ObterTabelaDoBanco(query); if (tabelaResultado.Rows.Count != 0) { saida = Convert.ToInt32(tabelaResultado.Rows[0]["Codigo"].ToString()); } return(saida); }
public static int ObterCodigoDoMunicipio(string NomeMunicipio, int CodigoEstado) { var sql = "select t.Codigo from Municipios t where t.nome = @municipio and t.CodigoEstado = @estado"; try { var banco = new BancosDeDados(EBancoDeDados.localidades); return(banco.Conexao.QueryFirst <int>(sql, new { municipio = NomeMunicipio, estado = CodigoEstado })); } catch (System.Exception ex) { throw new Exception(ex.Message); } }
public static string ObterNomeDoEstado(SByte Codigo) { var sql = "select t.nome from ESTADOS t where t.codigo = @codigo"; try { var banco = new BancosDeDados(EBancoDeDados.localidades); return(banco.Conexao.QueryFirst <string>(sql, new { codigo = Codigo })); } catch (System.Exception ex) { throw new Exception(ex.Message); } }
public static IEnumerable <Municipio> ObterListaDeMunicipio(UF SiglaEstado) { var sql = "select t.* from Municipios t where t.CodigoEstado = @codigo"; try { var banco = new BancosDeDados(EBancoDeDados.localidades); return(banco.Conexao.Query <Municipio>(sql, new { codigo = (byte)SiglaEstado })); } catch (System.Exception ex) { throw new Exception(ex.Message); } }
public static IEnumerable <Estado> ObterListaDeEstados() { var sql = "select t.* from ESTADOS t order by t.Nome"; try { var banco = new BancosDeDados(EBancoDeDados.localidades); return(banco.Conexao.Query <Estado>(sql)); } catch (System.Exception ex) { throw new Exception(ex.Message); } }
public static IEnumerable <Municipio> ObterListaDeMunicipio() { var sql = "select t.* from Municipios t"; try { var banco = new BancosDeDados(EBancoDeDados.localidades); return(banco.Conexao.Query <Municipio>(sql)); } catch (System.Exception ex) { throw new Exception(ex.Message); } }
public static string ObterSiglaDoEstado(string Nome) { var sql = "select t.Sigla from ESTADOS t where t.Nome = @nome"; try { var banco = new BancosDeDados(EBancoDeDados.localidades); return(banco.Conexao.QueryFirst <string>(sql, new { nome = Nome })); } catch (System.Exception e) { throw new Exception($"Não foi possível efetuar a busca: {e.Message}"); } }
public static string ObterNomeDoEstado(string Sigla) { var sql = "select t.nome from ESTADOS t where t.sigla = @sigla"; try { var banco = new BancosDeDados(EBancoDeDados.localidades); return(banco.Conexao.QueryFirst <string>(sql, new { sigla = Sigla })); } catch (System.Exception ex) { throw new Exception(ex.Message); } }
private static DataTable ObterTabelaDoBanco(string p_Query) { DataTable tabelaSaida = new DataTable(); Spartacus.Database.Generic database; try { database = new Spartacus.Database.Sqlite(BancosDeDados.ObterCaminhoBancoLugares()); tabelaSaida = database.Query(p_Query, "Resultado"); } catch (Spartacus.Database.Exception ex) { throw new Exception(ex.v_message); } return(tabelaSaida); }
public static string ObterSiglaDoEstado(int p_Codigo) { var Saida = "Estado não encontrado, verifique o codigo"; var cmd = new SpartacusMin.Database.Command(); cmd.v_text = "select t.Sigla from ESTADOS t where t.codigo = #codigo#"; cmd.AddParameter("codigo", SpartacusMin.Database.Type.INTEGER); cmd.SetValue("codigo", p_Codigo.ToString()); var tabelaResultado = BancosDeDados.ObterTabelaDoBanco(cmd.GetUpdatedText()); if (tabelaResultado.Rows.Count != 0) { Saida = tabelaResultado.Rows[0]["Sigla"].ToString(); } return(Saida); }
public static string ObterNomeDoEstado(string p_Sigla) { String Saida = "Estado não encontrado, verifique a sigla"; var cmd = new SpartacusMin.Database.Command(); cmd.v_text = "select t.nome from ESTADOS t where t.sigla = #sigla#"; cmd.AddParameter("sigla", SpartacusMin.Database.Type.STRING); cmd.SetValue("sigla", p_Sigla.ToUpper()); var tabelaResultado = BancosDeDados.ObterTabelaDoBanco(cmd.GetUpdatedText()); if (tabelaResultado.Rows.Count != 0) { Saida = tabelaResultado.Rows[0]["Nome"].ToString(); } return(Saida); }
private static List <Estado> ObterListaDoBanco(string p_Query) { Spartacus.Database.Generic database; List <Estado> ListaDeEstados = new List <Estado>(); try { database = new Spartacus.Database.Sqlite(BancosDeDados.ObterCaminhoBancoLugares()); ListaDeEstados = database.QueryList <Estado>(p_Query); } catch (Spartacus.Database.Exception ex) { throw new Exception(ex.v_message); } return(ListaDeEstados); }
public Estado(sbyte codigo) { var sql = "select * from estados where codigo = codigo"; try { var banco = new BancosDeDados(EBancoDeDados.localidades); var estadoTemp = banco.Conexao.QueryFirst <Estado>(sql, new { codigo = codigo }); this.Codigo = estadoTemp.Codigo; this.Nome = estadoTemp.Nome; this.Sigla = estadoTemp.Sigla; } catch (System.Exception ex) { throw new Exception(ex.Message); } }
public static string ObterNomeDoMunicipio(uint CodigoMunicipio) { var saida = String.Empty; var cmd = new SpartacusMin.Database.Command(); DataTable tabelaResultado; cmd.v_text = "select t.nome from Municipios t where t.codigo = #codigo#"; cmd.AddParameter("codigo", SpartacusMin.Database.Type.INTEGER); cmd.SetValue("codigo", CodigoMunicipio.ToString()); tabelaResultado = BancosDeDados.ObterTabelaDoBanco(cmd.GetUpdatedText()); if (tabelaResultado.Rows.Count != 0) { saida = tabelaResultado.Rows[0]["nome"].ToString(); } return(saida); }
public Municipio(uint CodigoMunicipio) { Municipio municipioTemp; var sql = "Select * from Municipios m where m.Codigo = @codigo"; try { var banco = new BancosDeDados(EBancoDeDados.localidades); municipioTemp = banco.Conexao.QueryFirst <Municipio>(sql, new { codigo = CodigoMunicipio }); } catch (System.Exception ex) { throw new Exception(ex.Message); } this.Codigo = municipioTemp.Codigo; this.CodigoEstado = municipioTemp.CodigoEstado; this.Nome = municipioTemp.Nome; }
public Municipio(string NomeMunicipio, UF SiglaEstado) { Municipio municipioTemp; var sql = "select m.* from estados e " + "inner join municipios m " + "on m.codigoestado = e.codigo " + "where m.nome = @nome and e.codigo = @codigo"; try { var banco = new BancosDeDados(EBancoDeDados.localidades); municipioTemp = banco.Conexao.QueryFirst <Municipio>(sql, new { nome = NomeMunicipio, codigo = (byte)SiglaEstado }); } catch (System.Exception ex) { throw new Exception(ex.Message); } this.Codigo = municipioTemp.Codigo; this.CodigoEstado = municipioTemp.CodigoEstado; this.Nome = municipioTemp.Nome; }
public EstadoRepositorio() { _bancoDeDados = new BancosDeDados(); }
public MunicipioRepositorio() { _bancoDeDados = new BancosDeDados(); }