protected void Page_Load(object sender, System.EventArgs e) { AtletaAnexoEntidade.codigo = decimal.Parse(Request.QueryString[0].ToString()); string tipo = Request.QueryString[1].ToString(); DataTable lTable = AtletaAnexoModelo.AtletaAnexoByte(); foreach (DataRow ors in lTable.Rows) { myfoto = (byte[])ors[0]; } if (tipo == ".JPG") { Response.ContentType = "Image/JPG"; } else if (tipo == ".PNG") { Response.ContentType = "Image/PNG"; } else if (tipo == ".BMP") { Response.ContentType = "Image/BMP"; } else if (tipo == ".PDF") { Response.ContentType = "Application/pdf"; } Response.BinaryWrite(myfoto); }
private void CarregaDadosAtleta(decimal pCodigo) { DataTable lTabela = PessoaModelo.CarregaDadosPessoaAtleta(pCodigo); if (lTabela.Rows.Count > 0) { ImgFoto.ImageUrl = "../administracao/foto.aspx?p=" + pCodigo + ""; hfCodigoPessoa.Value = lTabela.Rows[0]["CODIGO"].ToString(); hfCodigoAtleta.Value = lTabela.Rows[0]["CODIGO_ATLETA"].ToString(); txtNome.Text = lTabela.Rows[0]["NOME"].ToString(); txtNascimento.Text = lTabela.Rows[0]["NASCIMENTO"].ToString(); txtProfissao.Text = lTabela.Rows[0]["PROFISSAO"].ToString(); txtEmail.Text = lTabela.Rows[0]["EMAIL"].ToString(); txtTelefone.Text = lTabela.Rows[0]["TELEFONE"].ToString(); ddlEscolaridade.SelectedValue = lTabela.Rows[0]["ESCOLARIDADE"].ToString(); txtCpf.Text = lTabela.Rows[0]["CPF"].ToString(); txtRg.Text = lTabela.Rows[0]["RG"].ToString(); TxtCelular.Text = lTabela.Rows[0]["CELULAR"].ToString(); txtPlanoSaude.Text = lTabela.Rows[0]["PLANOSAUDE"].ToString(); txtContato.Text = lTabela.Rows[0]["CONTATO"].ToString(); if (hfCodigoAtleta.Value != "") { DataTable lTabelaAtleta = AtletaModelo.CarregaDadosAtleta(decimal.Parse(hfCodigoAtleta.Value)); if (lTabelaAtleta.Rows.Count > 0) { ddlAtletaStatus.SelectedValue = lTabelaAtleta.Rows[0]["ATLETASTATUS"].ToString(); ddlPosicao.SelectedValue = lTabelaAtleta.Rows[0]["POSICAO"].ToString(); NumeracaoIncluir.Visible = false; NumeracaoVisualizar.Visible = true; txtNumeracao.Text = lTabelaAtleta.Rows[0]["NUMERO"].ToString() + "|" + lTabelaAtleta.Rows[0]["CONTADOR"].ToString(); hfNumeracao.Value = lTabelaAtleta.Rows[0]["NUMERO"].ToString(); hfContador.Value = lTabelaAtleta.Rows[0]["CONTADOR"].ToString(); txtAltura.Text = lTabelaAtleta.Rows[0]["ALTURA"].ToString(); txtPeso.Text = lTabelaAtleta.Rows[0]["PESO"].ToString(); txtTamUniforme.Text = lTabelaAtleta.Rows[0]["TAMANHOUNIFORME"].ToString(); } ViewState["VW_ATLETAANEXO"] = AtletaAnexoModelo.AtletaAnexoLista(); gvArquivos.DataSource = ViewState["VW_ATLETAANEXO"]; gvArquivos.DataBind(); } divConsulta.Visible = false; divCadastro.Visible = true; } }
private void IncludeAnexo(decimal pId, string pDesc, string pFormato, byte[] pArquivo) { string pRetorno = ""; AtletaAnexoEntidade.codigo_atleta = pId; AtletaAnexoEntidade.descricao = pDesc; AtletaAnexoEntidade.arquivo = pArquivo; AtletaAnexoEntidade.tipoarquivo = pFormato; pRetorno = AtletaAnexoModelo.Include(); }
protected void gvArquivos_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName != "Page") { int iIndice = (((GridView)sender).PageIndex * ((GridView)sender).PageSize) + int.Parse(e.CommandArgument.ToString()); DataTable lTabela = (DataTable)ViewState["VW_ATLETAANEXO"]; if (e.CommandName == "Visualizar") { string strJScript2 = "window.open('../webarquivo.aspx?p=" + lTabela.Rows[iIndice]["CODIGO"].ToString() + "&m=" + lTabela.Rows[iIndice]["TIPOARQUIVO"].ToString() + "','myWindow','top=0,left=0,width=790,height=500,buttons=yes,scrollbars=yes,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=yes');"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "NomedaJanela", "$(function(){" + strJScript2 + "});", true); } if (e.CommandName == "Editar") { hfCodigoAnexo.Value = lTabela.Rows[iIndice]["CODIGO"].ToString(); txtDescricaoArquivos.Text = lTabela.Rows[iIndice]["DESCRICAO"].ToString(); } if (e.CommandName == "Excluir") { AtletaAnexoEntidade.codigo = decimal.Parse(lTabela.Rows[iIndice]["CODIGO"].ToString()); string pRetorno = AtletaAnexoModelo.Delete(); gvArquivos.DataSource = (DataTable)ViewState["ANEXAARQUIVO"]; gvArquivos.DataBind(); } } } catch (Exception err) { } }
private void Update() { string pRetorno = ""; decimal pRetornoInc = 0; try { PessoaEntidade.codigo = decimal.Parse(hfCodigoPessoa.Value); PessoaEntidade.codigo_tipopessoa = decimal.Parse("2"); PessoaEntidade.nome = txtNome.Text.ToUpper(); PessoaEntidade.nacimento = DateTime.Parse(txtNascimento.Text); if (fuImagem.FileName != "") { PessoaEntidade.foto = fuImagem.FileBytes; } else { PessoaEntidade.codigo = decimal.Parse(hfCodigoPessoa.Value); DataTable lFoto = PessoaModelo.Foto(); foreach (DataRow ors in lFoto.Rows) { PessoaEntidade.foto = (byte[])ors[0]; } } PessoaEntidade.email = txtEmail.Text; PessoaEntidade.cpf = txtCpf.Text; PessoaEntidade.rg = txtRg.Text; PessoaEntidade.profissao = txtProfissao.Text.ToUpper(); PessoaEntidade.escolaridade = ddlEscolaridade.SelectedItem.Text; PessoaEntidade.planosaude = txtPlanoSaude.Text.ToUpper(); PessoaEntidade.contato = txtContato.Text.ToUpper(); PessoaEntidade.telefone = txtTelefone.Text; PessoaEntidade.celular = TxtCelular.Text; pRetorno = PessoaModelo.Update(); if (pRetorno == "") { if (hfCodigoAtleta.Value != "") { AtletaEntidade.codigo = decimal.Parse(hfCodigoAtleta.Value); AtletaEntidade.codigo_posicao = decimal.Parse(ddlPosicao.SelectedValue); AtletaEntidade.codigo_atletastatus = decimal.Parse(ddlAtletaStatus.SelectedValue); AtletaEntidade.altura = txtAltura.Text; AtletaEntidade.peso = txtPeso.Text; AtletaEntidade.apelido = txtApelido.Text; if ((ddlNumeracao.SelectedValue == hfNumeracao.Value) && (int.Parse(hfContador.Value) < 1)) { AtletaEntidade.numeracao = int.Parse(hfNumeracao.Value); } else { AtletaEntidade.numeracao = int.Parse(ddlNumeracao.SelectedValue); UpdateNumeracaoMenos(int.Parse(hfContador.Value), decimal.Parse(hfNumeracao.Value)); UpdateNumeracaoMais(ddlNumeracao.SelectedItem.Text, decimal.Parse(ddlNumeracao.SelectedValue)); } AtletaEntidade.tamanhouniforme = txtTamUniforme.Text; pRetorno = AtletaModelo.Update(); } else { AtletaEntidade.codigo_pessoa = decimal.Parse(hfCodigoPessoa.Value); AtletaEntidade.codigo_posicao = decimal.Parse(ddlPosicao.SelectedValue); AtletaEntidade.codigo_atletastatus = decimal.Parse(ddlAtletaStatus.SelectedValue); AtletaEntidade.altura = txtAltura.Text; AtletaEntidade.peso = txtPeso.Text; AtletaEntidade.apelido = txtApelido.Text; AtletaEntidade.numeracao = int.Parse(ddlNumeracao.SelectedValue); UpdateNumeracaoMais(ddlNumeracao.SelectedItem.Text, decimal.Parse(ddlNumeracao.SelectedValue)); AtletaEntidade.tamanhouniforme = txtTamUniforme.Text; pRetornoInc = AtletaModelo.Include(); } } if (hfCodigoAnexo.Value != "") { AtletaAnexoEntidade.codigo = decimal.Parse(hfCodigoAnexo.Value); AtletaAnexoEntidade.descricao = txtDescricaoArquivos.Text.ToUpper(); pRetorno = AtletaAnexoModelo.Update(); txtDescricaoArquivos.Text = ""; } else { DataTable lTabela = (DataTable)ViewState["ANEXAARQUIVO"]; byte[] arquivo = new byte[0]; if (lTabela != null) { for (int i = 0; i < lTabela.Rows.Count; i++) { arquivo = (byte[])lTabela.Rows[i]["ARQUIVO"]; IncludeAnexo(decimal.Parse(hfCodigoAtleta.Value), lTabela.Rows[i]["DESCRICAO"].ToString(), lTabela.Rows[i]["TIPOARQUIVO"].ToString().ToUpper(), arquivo); } ExcluiAnexo(""); } txtDescricaoArquivos.Text = ""; gvArquivoAdd.DataSource = null; gvArquivoAdd.DataBind(); } Log("PAG: ATLETA, ATUALIZAÇÃO DE REGISTRO: " + hfCodigoPessoa.Value + ", USUARIO: " + Session["SE_USUARIO"].ToString() + ""); exibirMensagem("Ok", "Cadastro atualizado com sucesso", "ok"); divConsulta.Visible = false; divCadastro.Visible = true; ViewState["VW_ATLETAANEXO"] = AtletaAnexoModelo.AtletaAnexoLista(); gvArquivos.DataSource = ViewState["VW_ATLETAANEXO"]; gvArquivos.DataBind(); } catch (Exception err) { exibirMensagem("Erro", err.Message.ToString(), "erro"); } }