protected void GridFiliadoDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string idFiliado = (string)this.GridFiliado.DataKeys[e.Row.RowIndex]["IdFiliado"].ToString();
                Session["IdFiliado"] = idFiliado;

                Regras.Regras         get   = new Regras.Regras();
                Regras.Dto.DtoFiliado dados = get.GetFiliadoPorId(int.Parse(idFiliado));

                if (dados != null)
                {
                    if (dados.StatusFiliado.Equals("A"))
                    {
                        ((ImageButton)e.Row.Cells[8].Controls[0]).ImageUrl      = "~/Imagens/lock.png";
                        ((ImageButton)e.Row.Cells[8].Controls[0]).AlternateText = "Bloquear";
                        ((ImageButton)e.Row.Cells[8].Controls[0]).CommandName   = "Bloquear";
                    }
                    else
                    {
                        ((ImageButton)e.Row.Cells[8].Controls[0]).ImageUrl      = "~/Imagens/Unlock.png";
                        ((ImageButton)e.Row.Cells[8].Controls[0]).AlternateText = "Liberar";
                        ((ImageButton)e.Row.Cells[8].Controls[0]).CommandName   = "Liberar";
                    }
                }
            }
        }
 private void CarregaTela(Regras.Dto.DtoFiliado dados, DtoGraduacaoFiliado graduacao)
 {
     TextId.Text                          = dados.IdFiliado.ToString();
     TextNumeroRegistro.Text              = dados.NumeroRegistro.ToString();
     TextNomeFiliado.Text                 = dados.NomeFiliado.ToUpper();
     TextEndereco.Text                    = dados.EnderecoFiliado;
     DropDownListCidade.SelectedValue     = dados.IdCidade.ToString();
     DropDownListAssociacao.SelectedValue = dados.IdAssociacao.ToString();
     TextCep.Text                         = dados.CepFiliado;
     TextTelefone.Text                    = dados.TelefoneFixo;
     TextTelefoneCelular.Text             = dados.TelefoneCelular;
     TextEmail.Text                       = dados.EmailFiliado;
     TextDtNascimento.Text                = dados.DataNascimento.ToShortDateString();
     TextIdade.Text                       = dados.IdadeFiliado.ToString();
     if (!String.IsNullOrWhiteSpace(dados.SexoFiliado))
     {
         RBtnListSexo.SelectedValue = dados.SexoFiliado;
     }
     TextAltura.Text = dados.Altura.ToString();
     TextPeso.Text   = dados.Peso.ToString();
     TextRG.Text     = dados.RgFiliado;
     TextCPF.Text    = dados.CpfFiliado;
     RBtnListStatus.SelectedValue = dados.StatusFiliado;
     if (graduacao != null)
     {
         DropDownListGraduacao.SelectedValue = graduacao.IdGraduacao.ToString();
         TextDataGraduacao.Text      = graduacao.DataGraduacao.ToShortDateString();
         RBtnGraduacao.SelectedValue = graduacao.Status == true ? "A" : "I";
     }
     else
     {
         DropDownListGraduacao.SelectedValue = "0";
         TextDataGraduacao.Text = string.Empty;
     }
 }
        protected void GridFiliadoDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string idFiliado = (string)this.GridFiliado.DataKeys[e.Row.RowIndex]["IdFiliado"].ToString();
                Session["IdFiliado"] = idFiliado;

                List <Regras.Dto.DtoFiliado> lista = (List <Regras.Dto.DtoFiliado>)Session["Filiados"];
                int id = int.Parse(idFiliado);
                Regras.Dto.DtoFiliado dados = lista.FirstOrDefault(p => p.IdFiliado == id);

                ImageButton button = (ImageButton)e.Row.FindControl("carteirinha");
                if (dados != null)
                {
                    if (!dados.StatusFiliado.Equals("A"))
                    {
                        button.Visible = false;
                    }
                    else
                    {
                        button.CommandArgument = dados.IdFiliado.ToString();
                    }
                }
            }
        }
        public void SalvarClick(object sender, EventArgs e)
        {
            try
            {
                Regras.Dto.DtoFiliado filiado = new Regras.Dto.DtoFiliado();
                if (!String.IsNullOrWhiteSpace(TextId.Text))
                {
                    filiado.IdFiliado = int.Parse(TextId.Text);
                }
                if (!String.IsNullOrWhiteSpace(TextNumeroRegistro.Text))
                {
                    filiado.NumeroRegistro = int.Parse(TextNumeroRegistro.Text);
                }
                filiado.NomeFiliado     = TextNomeFiliado.Text.ToUpper();
                filiado.EnderecoFiliado = TextEndereco.Text.ToUpper();
                filiado.IdCidade        = int.Parse(DropDownListCidade.SelectedValue);
                filiado.CepFiliado      = TextCep.Text;
                filiado.TelefoneFixo    = TextTelefone.Text;
                filiado.TelefoneCelular = TextTelefoneCelular.Text;
                filiado.EmailFiliado    = TextEmail.Text.ToUpper();
                filiado.DataNascimento  = DateTime.Parse(TextDtNascimento.Text);
                filiado.IdadeFiliado    = int.Parse(TextIdade.Text);
                filiado.SexoFiliado     = RBtnListSexo.SelectedValue;
                filiado.IdAssociacao    = int.Parse(DropDownListAssociacao.SelectedValue);
                filiado.StatusFiliado   = RBtnListStatus.SelectedValue;
                if (!String.IsNullOrWhiteSpace(TextAltura.Text))
                {
                    filiado.Altura = decimal.Parse(TextAltura.Text.Replace(".", ","));
                }
                if (!String.IsNullOrWhiteSpace(TextPeso.Text))
                {
                    filiado.Peso = decimal.Parse(TextPeso.Text.Replace(".", ","));
                }
                filiado.RgFiliado  = TextRG.Text;
                filiado.CpfFiliado = TextCPF.Text;
                filiado.imagem     = imagem;

                Regras.Regras set = new Regras.Regras();
                Session["IdFiliado"] = set.SetFiliado(filiado);
                TextId.Text          = Session["IdFiliado"].ToString();
                //Graduação
                SalvarGraduacaoClick(sender, e);

                CarregarFiliado();

                AlertVisibleTrue();
                AlertSucesso();

                MultiView1.ActiveViewIndex = 1;
                imagem = null;
                LimpaTela();
            }
            catch (Exception ex)
            {
                AlertVisibleTrue();
                AlertError(ex.Message);
            }
        }
        public void GridFiliadoCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                string argument = e.CommandArgument.ToString();
                if (argument != "Next" && argument != "Last")
                {
                    if (e.CommandName == "Imprimir")
                    {
                        ImprimirCarteirinha(int.Parse(argument));
                    }
                    else
                    {
                        int    index     = Convert.ToInt32(e.CommandArgument);
                        string idFiliado = GridFiliado.DataKeys[index]["IdFiliado"].ToString();
                        Session["IdFiliadoCommand"] = idFiliado;

                        if (e.CommandName == "Excluir")
                        {
                            Regras.Regras del = new Regras.Regras();
                            del.DelGraduacaoFiliadoPorIdFiliado(idFiliado);
                            del.DelFiliado(idFiliado);
                        }
                        else if (e.CommandName == "Editar")
                        {
                            Regras.Regras              get            = new Regras.Regras();
                            Regras.Dto.DtoFiliado      dados          = get.GetFiliadoPorIdSemGraduacao(int.Parse(idFiliado));
                            List <DtoGraduacaoFiliado> ListaGraduacao = get.GetGraduacaoPorIdFiliado(int.Parse(idFiliado));
                            DtoGraduacaoFiliado        graduacao      = ListaGraduacao.FirstOrDefault(p => p.Status == true);

                            CarregaTela(dados, graduacao);
                            Menu1.Items[MultiView1.ActiveViewIndex = 0].Selected = true;
                        }
                    }

                    AlertVisibleTrue();
                    AlertSucesso();
                    //FailureText.Text = string.Format("Operação realizado com Sucesso.:{0}", e.CommandName.ToString());
                    CarregarFiliado();
                    MultiView1.ActiveViewIndex = 0;
                }
            }
            catch (Exception ex)
            {
                AlertVisibleTrue();
                AlertError(ex.Message);
            }
        }
Exemple #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    string                idFiliado = Request.QueryString["id"];
                    Regras.Regras         get       = new Regras.Regras();
                    Regras.Dto.DtoFiliado filiado   = get.GetFiliadoPorId(int.Parse(idFiliado));

                    if (filiado != null)
                    {
                        if (filiado.imagem != null)
                        {
                            byte[] bytes        = filiado.imagem;
                            string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
                            Image7.ImageUrl = "data:image/png;base64," + base64String;
                            Image7.Width    = 120;
                            Image7.Height   = 154;
                        }
                    }

                    string NRegistro = filiado.NumeroRegistro.ToString();
                    string Nome      = filiado.NomeFiliado.ToString();
                    string Cidade    = filiado.NomeCidade.ToString();
                    string DataNasc  = filiado.DataNascimento.ToShortDateString();
                    string Graduacao = filiado.DescGraducacao.ToString() != null?filiado.DescGraducacao.ToString() : string.Empty;

                    string Associacao = filiado.NomeAssociacao;

                    litNumeroRegistro.Text = string.Format("N°.: {0} ", NRegistro);
                    LitNome.Text           = string.Format("Nome.: {0} ", Nome);
                    LitDtNascimento.Text   = string.Format("Dt Nascimento.: {0} ", DataNasc);
                    //LitCidade.Text = string.Format("Cidade.: {0} ", Cidade);
                    LitGraduacao.Text  = string.Format("Graduação.: {0} ", Graduacao);
                    LitAssociacao.Text = string.Format("Assoc.:{0}", Associacao);
                }
            }
            catch (Exception)
            {
            }
        }