private void frmEF_Cadastro_de_Declarante_Novo_Load(object sender, EventArgs e) { try { DefaultToolTipController tootip = new DefaultToolTipController(); tootip.DefaultController.AutoPopDelay = 10000; Listas(); modDeclaranteAux = rep.ListarDeclarante(); if (modDeclaranteAux.CHAVE != 0) { txtCnpj.Text = modDeclaranteAux.CNPJDECLARANTE; txtGiin.Text = modDeclaranteAux.GIIN; txtNome.Text = modDeclaranteAux.NOME; txtEndereco.Text = modDeclaranteAux.ENDERECOLIVRE; txtCodigoMunicipio.Text = modDeclaranteAux.MUNICIPIO; cboUf.EditValue = modDeclaranteAux.UF; cboPais.EditValue = modDeclaranteAux.PAIS; cboPais.EditValue = modDeclaranteAux.PAISRESIDENCIA; } ListarCamposObrigatorios(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public String GravaDeclarante(EF_DECLARANTE modDeclarante) { String retorno = String.Empty; using (SQLiteConnection conn = new SQLiteConnection(conexaoSqlLite())) { conn.Open(); if (modDeclarante.CHAVE == 0) { comandoSql = @"INSERT INTO CEF300(INDRETIFICACAO ,TPAMB ,APLICEMI ,VERAPLIC ,GIIN ,NRRECIBO ,CNPJDECLARANTE ,NOME ,ENDERECOLIVRE ,MUNICIPIO ,UF ,PAIS ,PAISRESIDENCIA) VALUES(" + modDeclarante.INDRETIFICACAO + "," + modDeclarante.TPAMB + "," + modDeclarante.APLICEMI + ",'" + modDeclarante.VERAPLIC + "'" + ",'" + modDeclarante.GIIN + "'" + ",'" + modDeclarante.NRRECIBO + "'" + ",'" + modDeclarante.CNPJDECLARANTE + "'" + ",'" + modDeclarante.NOME + "'" + ",'" + modDeclarante.ENDERECOLIVRE + "'" + ",'" + modDeclarante.MUNICIPIO + "'" + ",'" + modDeclarante.UF + "'" + ",'" + modDeclarante.PAIS + "'" + ",'" + modDeclarante.PAISRESIDENCIA + "'" + ")"; } else { comandoSql = @"UPDATE CEF300 SET INDRETIFICACAO = "+ modDeclarante.INDRETIFICACAO + ",TPAMB = "+ modDeclarante.TPAMB + ",APLICEMI = "+ modDeclarante.APLICEMI + ",VERAPLIC = '"+ modDeclarante.VERAPLIC + "'"+ ",GIIN = '" + modDeclarante.GIIN + "'" + ",NRRECIBO = '" + modDeclarante.NRRECIBO + "'" + ",CNPJDECLARANTE = '" + modDeclarante.CNPJDECLARANTE + "'" + ",NOME = '" + modDeclarante.NOME + "'" + ",ENDERECOLIVRE = '" + modDeclarante.ENDERECOLIVRE + "'" + ",MUNICIPIO = '" + modDeclarante.MUNICIPIO + "'" + ",UF = '" + modDeclarante.UF + "'" + ",PAIS = '" + modDeclarante.PAIS + "'" + ",PAISRESIDENCIA = '" + modDeclarante.PAISRESIDENCIA + "' " + " WHERE CHAVE = "+modDeclarante.CHAVE; } SQLiteCommand ler = new SQLiteCommand(comandoSql, conn); ler.ExecuteNonQuery(); conn.Close(); } return retorno; }
public EF_DECLARANTE ListarDeclarante() { EF_DECLARANTE retorno = new EF_DECLARANTE(); using (SQLiteConnection conn = new SQLiteConnection(conexaoSqlLite())) { conn.Open(); comandoSql = @"SELECT CHAVE ,INDRETIFICACAO ,TPAMB ,APLICEMI ,VERAPLIC ,GIIN ,NRRECIBO ,CNPJDECLARANTE ,NOME ,ENDERECOLIVRE ,MUNICIPIO ,UF ,PAIS ,PAISRESIDENCIA ,ID_EVENTO FROM CEF300"; SQLiteCommand ler = new SQLiteCommand(comandoSql, conn); SQLiteDataReader dr = ler.ExecuteReader(); if (dr.HasRows) { dr.Read(); retorno.CHAVE = Convert.ToInt32(dr["CHAVE"].ToString()); retorno.GIIN = dr["GIIN"].ToString(); retorno.NRRECIBO = dr["NRRECIBO"].ToString(); retorno.CNPJDECLARANTE = dr["CNPJDECLARANTE"].ToString(); retorno.NOME = dr["NOME"].ToString(); retorno.ENDERECOLIVRE = dr["ENDERECOLIVRE"].ToString(); retorno.MUNICIPIO = dr["MUNICIPIO"].ToString(); retorno.UF = dr["UF"].ToString(); retorno.PAIS = dr["PAIS"].ToString(); retorno.PAISRESIDENCIA = dr["PAISRESIDENCIA"].ToString(); retorno.ID_EVENTO = dr["ID_EVENTO"].ToString(); } else { retorno.CHAVE = 0; } dr.Close(); conn.Close(); } return retorno; }