public static ModAlerta Obter(int pintId, int pintIdioma) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_L_MODULO_ALERTA_ID"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; objComando.Parameters.Add("@alertaId", SqlDbType.Int).Value = pintId; objComando.Parameters.Add("@idiomaId", SqlDbType.Int).Value = pintIdioma; try { objConexao.Open(); ModAlerta obj = new ModAlerta(); IDataReader idrReader = default(IDataReader); idrReader = objComando.ExecuteReader(); while ((idrReader.Read())) { obj.FromIDataReader(idrReader); } return(obj); } catch (Exception ex) { throw ex; } finally { //Fecha a conexao se aberta if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }
public static List <ModAlerta> Listar(int pintIdIdioma = 0, string pstrNome = "", string pstrEmail = "", DateTime?pdatDataInicio = null, DateTime?pdatDataFim = null) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_L_MODULO_ALERTA"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; ///Parametros if (pintIdIdioma > 0) { objComando.Parameters.Add("@idiomaId", SqlDbType.Int).Value = pintIdIdioma; } if (!String.IsNullOrWhiteSpace(pstrNome)) { objComando.Parameters.Add("@nome", SqlDbType.NVarChar, 128).Value = pstrNome; } if (!String.IsNullOrWhiteSpace(pstrEmail)) { objComando.Parameters.Add("@email", SqlDbType.NVarChar, 128).Value = pstrEmail; } if (pdatDataInicio.HasValue) { objComando.Parameters.Add("@dataCadastroInicio", SqlDbType.Date).Value = pdatDataInicio.Value; } if (pdatDataFim.HasValue) { objComando.Parameters.Add("@dataCadastroFim", SqlDbType.Date).Value = pdatDataFim.Value; } try { //Abre Conexao objConexao.Open(); //Declara variavel de retorno List <ModAlerta> objList = new List <ModAlerta>(); ModAlerta obj = default(ModAlerta); IDataReader idrReader = default(IDataReader); idrReader = objComando.ExecuteReader(); while ((idrReader.Read())) { obj = new ModAlerta(); obj.FromIDataReader(idrReader); objList.Add(obj); } return(objList); } catch (Exception ex) { throw ex; } finally { //Fecha a conexao se aberta if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }