Beispiel #1
0
 /// <summary>
 /// Obtem o Proximo id disponível
 /// </summary>
 /// <returns></returns>
 public virtual int ProximoId()
 {
     string sql = $"select isnull(max({Chave})+1,1) from {Tabela}";
     using (SqlConnection cx = ConexaoBD.GetConexao())
     {
         SqlCommand cmd = new SqlCommand(sql, cx);
         return Convert.ToInt32(cmd.ExecuteScalar());
     }
 }
Beispiel #2
0
 /// <summary>
 /// Método para consultar 1 registro
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public PadraoVO Consulta(int id)
 {
     using (SqlConnection cx = ConexaoBD.GetConexao())
     {
         string sql = MontaSQLConsulta();
         SqlParameter[] parametros =
         {
   new SqlParameter("id", id)
 };
         DataTable tabela = Metodos.ExecutaSelect(sql, parametros);
         if (tabela.Rows.Count == 0)
             return null;
         else
         {
             return MontaVO(tabela.Rows[0]);
         }
     }
 }