Пример #1
0
    protected void gridUsuario_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Abrir")
        {
            int iIDUsuario = Convert.ToInt32(gridUsuario.DataKeys[int.Parse((string)e.CommandArgument)]["Cód. Usuário"].ToString());

            usuario    Usuario  = new usuario();
            usuarioCTL CUsuario = new usuarioCTL();

            Usuario = CUsuario.RetornarUsuario(iIDUsuario);

            hddId.Value   = Usuario.IDUsuario.ToString();
            txtNome.Text  = Usuario.Nome;
            txtLogin.Text = Usuario.Login;
            txtSenha.Attributes.Add("value", Usuario.Senha);
            radAtivo.SelectedValue  = Convert.ToInt32(Usuario.Ativo).ToString();
            radPerfil.SelectedValue = Usuario.IDPerfil.ToString();

            //Desmarca todas as campanhas
            foreach (ListItem listItem in chkCampanha.Items)
            {
                listItem.Selected = false;
            }

            //Carregar campanhas do usuários
            DataTable dataTable = CUsuario.RetornarCampanhasUsuario(Usuario.IDUsuario);
            foreach (DataRow dataRow in dataTable.Rows)
            {
                foreach (ListItem listItem in chkCampanha.Items)
                {
                    if (dataRow["IDCampanha"].ToString() == listItem.Value)
                    {
                        listItem.Selected = true;
                    }
                }
            }
            txtNome.Focus();
        }
    }
Пример #2
0
    protected void gridUsuario_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == System.Web.UI.WebControls.DataControlRowType.DataRow)
        {
            if (e.Row.RowState == DataControlRowState.Alternate)
            {
                e.Row.Attributes.Add("onmouseover", "this.className='grid_row_selecionado'");
                e.Row.Attributes.Add("onmouseout", "this.className='grid_alternative_row'");
            }
            else
            {
                e.Row.Attributes.Add("onmouseover", "this.className='grid_row_selecionado'");
                e.Row.Attributes.Add("onmouseout", "this.className='grid'");
            }

            //Obs: Não existia a linha: e.Row.Cells[3].Text == "Supervisor" - foi adicionado para listar as campanhas do Supervisor
            if (e.Row.Cells[3].Text == "Operador" || e.Row.Cells[3].Text == "BackOffice" || e.Row.Cells[3].Text == "Supervisor")
            {
                int    iIDUsuario = Convert.ToInt32(gridUsuario.DataKeys[e.Row.RowIndex].Values[0].ToString());
                string sCampanha  = "";

                usuarioCTL CUsuario  = new usuarioCTL();
                DataTable  dataTable = CUsuario.RetornarCampanhasUsuario(iIDUsuario);

                foreach (DataRow dataRow in dataTable.Rows)
                {
                    sCampanha += sCampanha != "" ? "; " + dataRow["Campanha"].ToString() : dataRow["Campanha"].ToString();
                }
                e.Row.Cells[3].Text = sCampanha == "" ? "-" : sCampanha;
            }
            else
            {
                e.Row.Cells[3].Text = "-";
            }
        }
    }
Пример #3
0
        private void dgUsuario_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                txtIDUsuario.Text = dgUsuario.Rows[e.RowIndex].Cells[0].Value.ToString();
                txtNome.Text      = dgUsuario.Rows[e.RowIndex].Cells[1].Value.ToString();
                txtLogin.Text     = dgUsuario.Rows[e.RowIndex].Cells[2].Value.ToString();

                //Robson
                if (dgUsuario.Rows[e.RowIndex].Cells[3].Value.ToString() == "Operador")
                {
                    radOperador.Checked = true;
                }
                else if (dgUsuario.Rows[e.RowIndex].Cells[3].Value.ToString() == "Supervisor")
                {
                    radSupervisor.Checked = true;
                }
                else if (dgUsuario.Rows[e.RowIndex].Cells[3].Value.ToString() == "BackOffice")
                {
                    radBackoffice.Checked = true;
                }

                //Campanha
                usuarioCTL CUsuario = new usuarioCTL();
                if (dgUsuario.Rows[e.RowIndex].Cells[4].Value.ToString() != "")
                {
                    DataTable dataTable = CUsuario.RetornarCampanhasUsuario(Convert.ToInt32(dgUsuario.Rows[e.RowIndex].Cells[0].Value.ToString()));
                    //chlCampanha.DataSource = dataTable;

                    //Desmarca todas as Campanhas
                    for (int i = 0; i < this.chlCampanha.Items.Count; ++i)
                    {
                        this.chlCampanha.SetItemChecked(i, false);
                    }

                    for (int i = 0; i < this.chlCampanha.Items.Count; ++i)
                    {
                        foreach (DataRow dataRow in dataTable.Rows)
                        {
                            if (chlCampanha.Items[i].ToString() == dataRow["Campanha"].ToString())
                            {
                                this.chlCampanha.SetItemChecked(i, true);
                            }
                        }
                    }
                }

                //Ativo
                if (dgUsuario.Rows[e.RowIndex].Cells[5].Value.ToString() == "Sim")
                {
                    radSim.Checked = true;
                    radNao.Checked = false;
                }
                else
                {
                    radSim.Checked = false;
                    radNao.Checked = true;
                }

                txtSenha.Text = CUsuario.RetornarSenha(Convert.ToInt32(dgUsuario.Rows[e.RowIndex].Cells[0].Value.ToString()));
            }
        }