private void PreencheCampos()
        {
            string stringSelect = @"select Nome,Apelido, " +
                                  "Endereco,Bairro,CEP,Cidade,Filiacao_Pai,Filiacao_Mae,Nascimento,Naturalidade,Nacionalidade,Escolaridade," +
                                  "CPF,RG,RG_Orgao,RG_Data_Exped,PIS,NIT, " +
                                  "Titulo,Titulo_Zona,Titulo_Secao,CEI,Estado_Civil,Telefone,email,Sexo,   " +
                                  "CTPS,RGP,RGP_Registro,RGP_emissor,Profissao,Categoria, " +
                                  "AreaAtuacao,Relacao_Trabalho,Embarcacao_Utiliza,Embarcacao_Nome,Embarcacao_Prop,Embarcacao_Tipo, " +
                                  "Embarcacao_Tamanho,Embarcacao_PRopulsao,Embarcacao_capitania,RGP_MPA,Arte_Principal,Arte_Dono,  " +
                                  "Arte_Esepcies,Arte_locais_venda,Arte_comercializado,Trabalho_dias,Trabalho_duracao,Trabalho_producao, " +
                                  "Trabalho_valor_venda,Trabalho_consumido, " +
                                  "Dependentes,Filhos_Escola,Seguro_Defeso,Bolsa_Familia,Tipo_Resid,possui_Agua_Encanada,  " +
                                  "possui_Energia,possui_Telefone,possui_esgoto,possui_computador,pessoas_Resid, pessoas_Menores, " +
                                  "pessoas_aposentados,renda_mensal,outra_atividade,renda_outra,valor_Seguro_desemprego,valor_bolsa_familia, " +
                                  "total_renda_familiar ,tempo_associado,mensalidade_em_dias,valor_mensalidade ,motivo_inadimp, satisfeito,opniao,ID_Colonia, FotoDataURI " +
                                  "from Tbl_Associados where ID_Associado = " + lblIDAssoc.Text;

            OperacaoBanco operacao = new OperacaoBanco();

            System.Data.SqlClient.SqlDataReader rcrdset = operacao.Select(stringSelect);
            while (rcrdset.Read())
            {
                txtNome.Text          = Convert.ToString(rcrdset[0]);
                txtApelido.Text       = Convert.ToString(rcrdset[1]);
                txtEndereco.Text      = Convert.ToString(rcrdset[2]);
                txtBairro.Text        = Convert.ToString(rcrdset[3]);
                txtCEP.Text           = Convert.ToString(rcrdset[4]);
                txtMunicipio.Text     = Convert.ToString(rcrdset[5]);
                txtPai.Text           = Convert.ToString(rcrdset[6]);
                txtMae.Text           = Convert.ToString(rcrdset[7]);
                txtNascimento.Text    = Convert.ToString(rcrdset[8]);
                txtNaturalidade.Text  = Convert.ToString(rcrdset[9]);
                txtNacionalidade.Text = Convert.ToString(rcrdset[10]);
                txtEscolaridade.Text  = Convert.ToString(rcrdset[11]);
                txtCPF.Text           = Convert.ToString(rcrdset[12]);
                txtRG.Text            = Convert.ToString(rcrdset[13]);
                txtEmissor.Text       = Convert.ToString(rcrdset[14]);
                txtEmissao.Text       = Convert.ToString(rcrdset[15]);
                txtPIS.Text           = Convert.ToString(rcrdset[16]);
                txtNIT.Text           = Convert.ToString(rcrdset[17]);
                txtTitulo.Text        = Convert.ToString(rcrdset[18]);
                //txtZOna.Text = Convert.ToString(rcrdset[19]);
                //txtSecao.Text = Convert.ToString(rcrdset[20]);
                txtCEI.Text            = Convert.ToString(rcrdset[21]);
                txtEstCivil.Text       = Convert.ToString(rcrdset[22]);
                txtTelefone.Text       = Convert.ToString(rcrdset[23]);
                txtemail.Text          = Convert.ToString(rcrdset[24]);
                txtsexo.Text           = Convert.ToString(rcrdset[25]);
                txtCTPS.Text           = Convert.ToString(rcrdset[26]);
                txtRGPAtual.Text       = Convert.ToString(rcrdset[27]);
                txtRGPRegistro.Text    = Convert.ToString(rcrdset[28]);
                txtRGPEmissor.Text     = Convert.ToString(rcrdset[29]);
                txtProf.Text           = Convert.ToString(rcrdset[30]);
                txtCat.Text            = Convert.ToString(rcrdset[31]);
                txtAtuacao.Text        = Convert.ToString(rcrdset[32]);
                txtRelacao.Text        = Convert.ToString(rcrdset[33]);
                txtutilizaEmbarca.Text = Convert.ToString(rcrdset[34]);
                txtNomeEmbarca.Text    = Convert.ToString(rcrdset[35]);
                txtPropietario.Text    = Convert.ToString(rcrdset[36]);
                txtTipo.Text           = Convert.ToString(rcrdset[37]);
                txtTamanho.Text        = Convert.ToString(rcrdset[38]);
                txtProp.Text           = Convert.ToString(rcrdset[39]);
                txtCapitania.Text      = Convert.ToString(rcrdset[40]);
                txtRGPMPA.Text         = Convert.ToString(rcrdset[41]);
                txtArtes.Text          = Convert.ToString(rcrdset[42]);
                txtDonoArtes.Text      = Convert.ToString(rcrdset[43]);
                txtPRincipais.Text     = Convert.ToString(rcrdset[44]);
                txtLocais.Text         = Convert.ToString(rcrdset[45]);
                txtComoComerc.Text     = Convert.ToString(rcrdset[46]);
                txtDiasTrab.Text       = Convert.ToString(rcrdset[47]);
                txtDuracao.Text        = Convert.ToString(rcrdset[48]);
                txtProdMedia.Text      = Convert.ToString(rcrdset[49]);
                txtVEndaPRod.Text      = Convert.ToString(rcrdset[50]);
                txtQuantConsumido.Text = Convert.ToString(rcrdset[51]);
                txtDependentes.Text    = Convert.ToString(rcrdset[52]);
                txtfilhosescola.Text   = Convert.ToString(rcrdset[53]);
                txtsegdefeso.Text      = Convert.ToString(rcrdset[54]);
                txtBolsafamilia.Text   = Convert.ToString(rcrdset[55]);
                txtCasaPropia.Text     = Convert.ToString(rcrdset[56]);
                txtAguaEncan.Text      = Convert.ToString(rcrdset[57]);
                txtpossuiEnergia.Text  = Convert.ToString(rcrdset[58]);
                txtpossuiTelefone.Text = Convert.ToString(rcrdset[59]);
                txtpossuiEsgoto.Text   = Convert.ToString(rcrdset[60]);
                txtPossuiCOmput.Text   = Convert.ToString(rcrdset[61]);
                txtQuantPessoas.Text   = Convert.ToString(rcrdset[62]);
                txtQuantMenores.Text   = Convert.ToString(rcrdset[63]);
                txtAposentado.Text     = Convert.ToString(rcrdset[64]);
                txtRendaAtividade.Text = Convert.ToString(rcrdset[65]);
                TxtExerceOutra.Text    = Convert.ToString(rcrdset[66]);
                txtRendaOutra.Text     = Convert.ToString(rcrdset[67]);
                txtVAlorDefeso.Text    = Convert.ToString(rcrdset[68]);
                txtValorBolsaFam.Text  = Convert.ToString(rcrdset[69]);
                txtRendaFamil.Text     = Convert.ToString(rcrdset[70]);
                txtTempoAssoc.Text     = Convert.ToString(rcrdset[71]);
                txtEmdias.Text         = Convert.ToString(rcrdset[72]);
                txtValorMens.Text      = Convert.ToString(rcrdset[73]);
                txtMotivoInadimp.Text  = Convert.ToString(rcrdset[74]);
                txtSatisfeito.Text     = Convert.ToString(rcrdset[75]);
                txtOpniao.Text         = Convert.ToString(rcrdset[76]);

                string ScriptFoto = "<script language=javascript>document.getElementById('results').innerHTML = '<img src=\"" + Convert.ToString(rcrdset[78]) + "\"/>';" +
                                    "document.getElementById('Hidden1').value = \"" + Convert.ToString(rcrdset[78]) + "\"; </script>";

                ClientScript.RegisterStartupScript(this.GetType(), "montafoto", ScriptFoto);
            }
            ConexaoBancoSQL.fecharConexao();
            txtNome.Focus();
        }
        protected void BtSalvar(object sender, EventArgs e)
        {
            string FotoDataUri = Request["fotouri"].ToString();
            string emissao     = DateTime.Now.ToString("dd/MM/yyyy");

            string stringinsert = @"INSERT INTO Tbl_Associados (ID_Colonia,Nome,Apelido,Colonia, " +
                                  "Endereco,Bairro,CEP,Cidade,UF,Filiacao_Pai,Filiacao_Mae,Nascimento,Naturalidade,Nacionalidade,Escolaridade," +
                                  "CPF,RG,RG_Orgao,RG_Data_Exped,PIS,NIT, " +
                                  "Titulo,Titulo_Zona,Titulo_Secao,CEI,Estado_Civil,Telefone,email,Sexo,   " +
                                  "CTPS,RGP,RGP_Registro,RGP_emissor,Profissao,Categoria, " +
                                  "AreaAtuacao,Relacao_Trabalho,Embarcacao_Utiliza,Embarcacao_Nome,Embarcacao_Prop,Embarcacao_Tipo, " +
                                  "Embarcacao_Tamanho,Embarcacao_PRopulsao,Embarcacao_capitania,RGP_MPA,Arte_Principal,Arte_Dono,  " +
                                  "Arte_Esepcies,Arte_locais_venda,Arte_comercializado,Trabalho_dias,Trabalho_duracao,Trabalho_producao, " +
                                  "Trabalho_valor_venda,Trabalho_consumido, " +
                                  "Dependentes,Filhos_Escola,Seguro_Defeso,Bolsa_Familia,Tipo_Resid,possui_Agua_Encanada,  " +
                                  "possui_Energia,possui_Telefone,possui_esgoto,possui_computador,pessoas_Resid, pessoas_Menores, " +
                                  "pessoas_aposentados,renda_mensal,outra_atividade,renda_outra,valor_Seguro_desemprego,valor_bolsa_familia, " +
                                  "total_renda_familiar ,tempo_associado,mensalidade_em_dias,valor_mensalidade ,motivo_inadimp, satisfeito,opniao, CTPS_Serie, FotoDataURI  " +
                                  ") VALUES (" + lblIDCol.Text +
                                  ",'" + txtNome.Text + "', '" + txtApelido.Text + "', '" + lblColonia.Text + "', '" + txtEndereco.Text +
                                  "', '" + txtBairro.Text + "', '" + txtCEP.Text + "', '" + txtMunicipio.Text + "', '" + lblUF.Text + "', '" + txtPai.Text + "', " +
                                  "'" + txtMae.Text + "', '" + txtNascimento.Text + "', '" + txtNaturalidade.Text + "', '" + txtNacionalidade.Text + "', " +
                                  "'" + txtEscolaridade.Text + "', " +
                                  "'" + txtCPF.Text + "', " +
                                  "'" + txtRG.Text + "', " +
                                  "'" + txtEmissor.Text + "', " +
                                  "'" + txtEmissao.Text + "', " +
                                  "'" + txtPIS.Text + "', " +
                                  "'" + txtNIT.Text + "', " +
                                  "'" + txtTitulo.Text + "', " +
                                  "'" + txtZOna.Text + "', " +
                                  "'" + txtSecao.Text + "', " +
                                  "'" + txtCEI.Text + "', " +
                                  "'" + txtEstCivil.Text + "', " +
                                  "'" + txtTelefone.Text + "', " +
                                  "'" + txtemail.Text + "', " +
                                  "'" + txtsexo.Text + "', " +
                                  "'" + txtCTPS.Text + "', " +
                                  "'" + txtRGPAtual.Text + "', " +
                                  "'" + txtRGPRegistro.Text + "', " +
                                  "'" + txtRGPEmissor.Text + "', " +
                                  "'" + txtProf.Text + "', " +
                                  "'" + txtCat.Text + "', " +
                                  "'" + txtAtuacao.Text + "', " +
                                  "'" + txtRelacao.Text + "', " +
                                  "'" + txtutilizaEmbarca.Text + "', " +
                                  "'" + txtNomeEmbarca.Text + "', " +
                                  "'" + txtPropietario.Text + "', " +
                                  "'" + txtTipo.Text + "', " +
                                  "'" + txtTamanho.Text + "', " +
                                  "'" + txtProp.Text + "', " +
                                  "'" + txtCapitania.Text + "', " +
                                  "'" + txtRGPMPA.Text + "', " +
                                  "'" + txtArtes.Text + "', " +
                                  "'" + txtDonoArtes.Text + "', " +
                                  "'" + txtPRincipais.Text + "', " +
                                  "'" + txtLocais.Text + "', " +
                                  "'" + txtComoComerc.Text + "', " +
                                  "'" + txtDiasTrab.Text + "', " +
                                  "'" + txtDuracao.Text + "', " +
                                  "'" + txtProdMedia.Text + "', " +
                                  "'" + txtVEndaPRod.Text + "', " +
                                  "'" + txtQuantConsumido.Text + "', " +
                                  "'" + txtDependentes.Text + "', " +
                                  "'" + txtfilhosescola.Text + "', " +
                                  "'" + txtsegdefeso.Text + "', " +
                                  "'" + txtBolsafamilia.Text + "', " +
                                  "'" + txtCasaPropia.Text + "', " +
                                  "'" + txtAguaEncan.Text + "', " +
                                  "'" + txtpossuiEnergia.Text + "', " +
                                  "'" + txtpossuiTelefone.Text + "', " +
                                  "'" + txtpossuiEsgoto.Text + "', " +
                                  "'" + txtPossuiCOmput.Text + "', " +
                                  "'" + txtQuantPessoas.Text + "', " +
                                  "'" + txtQuantMenores.Text + "', " +
                                  "'" + txtAposentado.Text + "', " +
                                  "'" + txtRendaAtividade.Text + "', " +
                                  "'" + TxtExerceOutra.Text + "', " +
                                  "'" + txtRendaOutra.Text + "', " +
                                  "'" + txtVAlorDefeso.Text + "', " +
                                  "'" + txtValorBolsaFam.Text + "', " +
                                  "'" + txtRendaFamil.Text + "', " +
                                  "'" + txtTempoAssoc.Text + "', " +
                                  "'" + txtEmdias.Text + "', " +
                                  "'" + txtValorMens.Text + "', " +
                                  "'" + txtMotivoInadimp.Text + "', " +
                                  "'" + txtSatisfeito.Text + "', " +
                                  "'" + txtOpniao.Text + "', " +
                                  "'" + emissao + "', " +
                                  "'" + FotoDataUri + "' " +
                                  ")";

            OperacaoBanco operacao = new OperacaoBanco();
            bool          inserir  = operacao.Insert(stringinsert);

            ConexaoBancoSQL.fecharConexao();

            if (inserir == true)
            {
                VerificaID();
            }
            else
            {
                Response.Write("<script>alert('Problemas ao Salvar. Verifique os Dados');</script>");
            }
        }
        public string SalvarRegistro(string param1, string param2, string param3, string param4, string param5, string param6, string param7, string param8, string param9, string param10,
                                     string param11, string param12, string param13, string param14, string param15, string param16, string param17, string param18, string param19, string param20,
                                     string param21, string param22, string param23, string param24, string param25, string param26, string param27, string param28, string param29, string param30,
                                     string param31, string param32, string param33, string param34, string param35, string param36, string param37, string param38, string param39, string param40,
                                     string param41, string param42, string param43, string param44, string param45, string param46, string param47, string param48, string param49, string param50,
                                     string param51, string param52, string param53, string param54, string param55, string param56, string param57, string param58, string param59, string param60,
                                     string param61, string param62, string param63, string param64, string param65, string param66, string param67, string param68, string param69, string param70,
                                     string param71, string param72, string param73, string param74, string param75, string param76, string param77, string param78, string param79, string param80,
                                     string param81, string param82)
        {
            string stringinsert = "insert into Tbl_Associados (Nome,Apelido,Endereco,CEP,Bairro,Cidade ,UF,Filiacao_Pai,Filiacao_Mae,Nascimento, " +
                                  "Naturalidade,Nacionalidade,Escolaridade,CPF,RG,RG_Orgao,RG_Data_Exped,Titulo,PIS,NIT, " +
                                  "CEI,Estado_Civil , Telefone ,email , sexo,CTPS ,RGP ,RGP_Registro ,RGP_emissor, Profissao, " +
                                  "Categoria ,AreaAtuacao , Relacao_Trabalho , Embarcacao_Utiliza , Embarcacao_Nome , Embarcacao_Prop ,Embarcacao_Tipo ,Embarcacao_Tamanho ,Embarcacao_PRopulsao, Embarcacao_capitania," +
                                  "RGP_MPA ,Arte_Principal , Arte_Quant,Arte_Dono ,Arte_Esepcies ,Arte_locais_venda , Arte_comercializado , Trabalho_dias , Trabalho_duracao,Trabalho_producao , " +
                                  "Trabalho_valor_venda ,Trabalho_consumido ,Dependentes , Filhos_Escola , Seguro_Defeso , Bolsa_Familia, Tipo_Resid ,possui_Agua_Encanada , possui_Energia , possui_Telefone ," +
                                  "possui_esgoto ,possui_computador , pessoas_Resid , pessoas_Menores ,pessoas_aposentados , renda_mensal, outra_atividade ,  renda_outra , valor_Seguro_desemprego ,valor_bolsa_familia," +
                                  "total_renda_familiar , tempo_associado ,mensalidade_em_dias ,valor_mensalidade ,motivo_inadimp , satisfeito ,opniao , FotoDataURI ,   " +
                                  "ID_Colonia, Colonia,CTPS_Serie " +
                                  ") values " +
                                  "('" + param1 + "', '" + param2 + "','" + param3 + "','" + param4 + "','" + param5 + "','" + param6 + "','" + param7 + "','" + param8 + "','" + param9 + "','" + param10 +
                                  "','" + param11 + "', '" + param12 + "','" + param13 + "','" + param14 + "','" + param15 + "','" + param16 + "','" + param17 + "','" + param18 + "','" + param19 + "','" + param20 +
                                  "','" + param21 + "', '" + param22 + "','" + param23 + "','" + param24 + "','" + param25 + "','" + param26 + "','" + param27 + "','" + param28 + "','" + param29 + "','" + param30 +
                                  "','" + param31 + "', '" + param32 + "','" + param33 + "','" + param34 + "','" + param35 + "','" + param36 + "','" + param37 + "','" + param38 + "','" + param39 + "','" + param40 +
                                  "','" + param41 + "', '" + param42 + "','" + param43 + "','" + param44 + "','" + param45 + "','" + param46 + "','" + param47 + "','" + param48 + "','" + param49 + "','" + param50 +
                                  "','" + param51 + "', '" + param52 + "','" + param53 + "','" + param54 + "','" + param55 + "','" + param56 + "','" + param57 + "','" + param58 + "','" + param59 + "','" + param60 +
                                  "','" + param61 + "', '" + param62 + "','" + param63 + "','" + param64 + "','" + param65 + "','" + param66 + "','" + param67 + "','" + param68 + "','" + param69 + "','" + param70 +
                                  "','" + param71 + "', '" + param72 + "','" + param73 + "','" + param74 + "','" + param75 + "','" + param76 + "','" + param77 + "','" + param78 + "'," + param79 + ",'" + param80 +
                                  "','" + param81 + "'" +
                                  ")";
            string url = "";

            OperacaoBanco operacao = new OperacaoBanco();
            bool          inserir  = operacao.Insert(stringinsert);

            ConexaoBancoSQL.fecharConexao();

            //verifica ID e vai para pagina de impressao
            string idassociado  = "";
            string stringSelect = @"select ID_Associado from Tbl_Associados" +
                                  " where (ID_Colonia = " + param79 +
                                  " and nome ='" + param1 + "') order by ID_Associado desc";

            OperacaoBanco operacao2 = new OperacaoBanco();

            System.Data.SqlClient.SqlDataReader rcrdset2 = operacao2.Select(stringSelect);
            while (rcrdset2.Read())
            {
                idassociado = Convert.ToString(rcrdset2[0]);
            }
            ConexaoBancoSQL.fecharConexao();

            if (inserir == true)
            {
                url = "../FichaAssociado2.aspx?IDAssoc=" + idassociado;
            }
            else
            {
                url = "../Sorry.aspx";
            }

            return(url);
        }