예제 #1
0
    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();
            }
        }
    }
    protected void btnEnviar_Click(object sender, EventArgs e)
    {
        try
        {
            ModAlerta objModAlerta = new ModAlerta();
            objModAlerta.Nome                = txtNome.Text;
            objModAlerta.Email               = txtEmail.Text;
            objModAlerta.Empresa             = txtEmpresa.Text;
            objModAlerta.TelefoneDDD         = txtTelefoneDDD.Text;
            objModAlerta.Telefone            = txtTelefone.Text;
            objModAlerta.IdSegmentoEmpresa   = Convert.ToInt32(ddlSegmentoEmpresa.SelectedValue);
            objModAlerta.Estado              = txtEstado.Text;
            objModAlerta.IdPais              = Convert.ToInt32(ddlPais.SelectedValue);
            objModAlerta.ProfissionalMercado = rdlProfissionalMercado.SelectedValue == "1";
            objModAlerta.IdIdiomaMailing     = Convert.ToInt32(rdlIdioma.SelectedValue);
            objModAlerta.ReceberMailing      = rdlMailing.SelectedValue == "1";

            DOModAlerta.Inserir(objModAlerta);

            IniciaTela();

            lblMensagemSucesso.Visible     = true;
            lblMensagemEmailExiste.Visible = false;
            lblMensagemErro.Visible        = false;
        }
        catch (SqlException sqlEx)
        {
            lblMensagemSucesso.Visible     = false;
            lblMensagemEmailExiste.Visible = true;
            lblMensagemErro.Visible        = false;
        }
        catch (Exception ex)
        {
            lblMensagemSucesso.Visible     = false;
            lblMensagemEmailExiste.Visible = false;
            lblMensagemErro.Visible        = true;
        }
    }
예제 #3
0
    private void CarregarObjetos(Utilitarios.TipoTransacao objTipoTransacao)
    {
        switch (objTipoTransacao)
        {
        //Novo Usuario
        case Utilitarios.TipoTransacao.Limpar:
            codigo = 0;

            ddlIdioma.SelectedValue          = "3";
            ddlPais.SelectedValue            = "0";
            ddlSegmentoEmpresa.SelectedValue = "0";
            txtEmail.Text                  = string.Empty;
            txtEmpresa.Text                = string.Empty;
            txtEstado.Text                 = string.Empty;
            txtNome.Text                   = string.Empty;
            txtTelefone.Text               = string.Empty;
            txtTelefoneDDD.Text            = string.Empty;
            chkProfissionalMercado.Checked = false;
            chkReceberMailing.Checked      = false;

            break;

        //Carregar Dados do Usuario
        case Utilitarios.TipoTransacao.Salvar:

            if (gobjModAlerta == null)
            {
                gobjModAlerta = new ModAlerta();
            }

            gobjModAlerta.Id                  = codigo;
            gobjModAlerta.Nome                = txtNome.Text;
            gobjModAlerta.Email               = txtEmail.Text;
            gobjModAlerta.Empresa             = txtEmpresa.Text;
            gobjModAlerta.TelefoneDDD         = txtTelefoneDDD.Text;
            gobjModAlerta.Telefone            = txtTelefone.Text;
            gobjModAlerta.IdSegmentoEmpresa   = Convert.ToInt32(ddlSegmentoEmpresa.SelectedValue);
            gobjModAlerta.Estado              = txtEstado.Text;
            gobjModAlerta.IdPais              = Convert.ToInt32(ddlPais.SelectedValue);
            gobjModAlerta.ProfissionalMercado = chkProfissionalMercado.Checked;
            gobjModAlerta.IdIdiomaMailing     = Convert.ToInt32(ddlIdioma.SelectedValue);
            gobjModAlerta.ReceberMailing      = chkReceberMailing.Checked;

            break;

        //Descarregar Dados do Usuario
        case Utilitarios.TipoTransacao.Carregar:

            txtNome.Text        = gobjModAlerta.Nome;
            txtEmail.Text       = gobjModAlerta.Email;
            txtEmpresa.Text     = gobjModAlerta.Empresa;
            txtTelefone.Text    = gobjModAlerta.Telefone;
            txtTelefoneDDD.Text = gobjModAlerta.TelefoneDDD;
            txtEstado.Text      = gobjModAlerta.Estado;
            if (gobjModAlerta.IdIdiomaMailing > 0)
            {
                ddlIdioma.SelectedValue = gobjModAlerta.IdIdiomaMailing.ToString();
            }
            if (gobjModAlerta.IdPais > 0)
            {
                ddlPais.SelectedValue = gobjModAlerta.IdPais.ToString();
            }
            if (gobjModAlerta.IdSegmentoEmpresa > 0)
            {
                ddlSegmentoEmpresa.SelectedValue = gobjModAlerta.IdSegmentoEmpresa.ToString();
            }
            chkProfissionalMercado.Checked = gobjModAlerta.ProfissionalMercado;
            chkReceberMailing.Checked      = gobjModAlerta.ReceberMailing;

            break;
        }
    }
예제 #4
0
    public static int Atualizar(ModAlerta pobjModAlerta)
    {
        string        strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString;
        SqlConnection objConexao         = new SqlConnection(strConectionString);

        SqlCommand objComando = new SqlCommand("SPE_U_MODULO_ALERTA");

        objComando.Connection  = objConexao;
        objComando.CommandType = CommandType.StoredProcedure;

        //Define parametros da procedure
        objComando.Parameters.Add("@alertaId", SqlDbType.Int).Value            = pobjModAlerta.Id;
        objComando.Parameters.Add("@nome", SqlDbType.NVarChar, 128).Value      = pobjModAlerta.Nome;
        objComando.Parameters.Add("@email", SqlDbType.NVarChar, 128).Value     = pobjModAlerta.Email;
        objComando.Parameters.Add("@profissionalMercado", SqlDbType.Bit).Value = pobjModAlerta.ProfissionalMercado;
        objComando.Parameters.Add("@idiomaMailing", SqlDbType.Int).Value       = pobjModAlerta.IdIdiomaMailing;
        objComando.Parameters.Add("@receberMailing", SqlDbType.Bit).Value      = pobjModAlerta.ReceberMailing;
        if (!String.IsNullOrWhiteSpace(pobjModAlerta.Empresa))
        {
            objComando.Parameters.Add("@empresa", SqlDbType.NVarChar, 128).Value = pobjModAlerta.Empresa;
        }
        if (!String.IsNullOrWhiteSpace(pobjModAlerta.TelefoneDDD))
        {
            objComando.Parameters.Add("@telefoneDDD", SqlDbType.Char, 10).Value = pobjModAlerta.TelefoneDDD;
        }
        if (!String.IsNullOrWhiteSpace(pobjModAlerta.Telefone))
        {
            objComando.Parameters.Add("@telefone", SqlDbType.Char, 15).Value = pobjModAlerta.Telefone;
        }
        if (pobjModAlerta.IdSegmentoEmpresa > 0)
        {
            objComando.Parameters.Add("@segmentoEmpresaId", SqlDbType.Int).Value = pobjModAlerta.IdSegmentoEmpresa;
        }
        if (!String.IsNullOrWhiteSpace(pobjModAlerta.Estado))
        {
            objComando.Parameters.Add("@estado", SqlDbType.NVarChar, 128).Value = pobjModAlerta.Estado;
        }
        if (pobjModAlerta.IdPais > 0)
        {
            objComando.Parameters.Add("@paisId", SqlDbType.Int).Value = pobjModAlerta.IdPais;
        }
        try
        {
            //Abre conexão com o banco de dados
            objConexao.Open();

            //Declara variavel de retorno
            int intRetorno = 0;

            //Executa comando no banco de dados
            intRetorno = objComando.ExecuteNonQuery();

            return(intRetorno);
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            //Fecha a conexao se aberta
            if (objConexao.State != ConnectionState.Closed)
            {
                objConexao.Close();
            }
        }
    }
예제 #5
0
    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();
            }
        }
    }