private void LoadConfig()
{
var cnpj = config.Get("PrestadorCPFCNPJ", string.Empty);
if (!cnpj.IsEmpty())
{
txtCPFCNPJ.Text = cnpj.FormataCPFCNPJ();
}
txtIM.Text = config.Get("PrestadorIM", string.Empty);
txtRazaoSocial.Text = config.Get("PrestadorRazaoSocial", string.Empty);
txtFantasia.Text = config.Get("PrestadorFantasia", string.Empty);
txtFone.Text = config.Get("PrestadorFone", string.Empty);
txtCEP.Text = config.Get("PrestadorCEP", string.Empty);
txtEndereco.Text = config.Get("PrestadorEndereco", string.Empty);
txtNumero.Text = config.Get("PrestadorNumero", string.Empty);
txtComplemento.Text = config.Get("PrestadorComplemento", string.Empty);
txtBairro.Text = config.Get("PrestadorBairro", string.Empty);
txtWebserviceUsuario.Text = config.Get("LoginREST", string.Empty);
txtWebserviceSenha.Text = config.Get("SenhaREST", string.Empty);
var codMunicipio = config.Get("Municipio", 0);
if (codMunicipio > 0)
{
var municipio = ProviderManager.Municipios.SingleOrDefault(x => x.Codigo == codMunicipio);
if (municipio != null)
{
cmbCidades.SetSelectedValue(municipio);
}
}
cmbAmbiente.SelectedItem = config.Get("Ambiente", DFeTipoAmbiente.Homologacao);
txtCertificado.Text = config.Get("Certificado", string.Empty);
txtSenha.Text = config.Get("Senha", string.Empty);
txtNumeroSerie.Text = config.Get("NumeroSerie", string.Empty);
txtSchemas.Text = config.Get("PastaSchemas", string.Empty);
txtArquivoCidades.Text = config.Get("ArquivoCidades", string.Empty);
var salvarNfse = config.Get("SalvarNfse", string.Empty);
if (salvarNfse == "1")
{
chkSalvarArquivos.Checked = true;
}
txtPathXml.Text = config.Get("CaminhoXML", string.Empty);
}
private void SaveConfig()
{
config.Set("PrestadorCPFCNPJ", txtCPFCNPJ.Text.OnlyNumbers());
config.Set("PrestadorIM", txtIM.Text.OnlyNumbers());
config.Set("PrestadorRazaoSocial", txtRazaoSocial.Text);
config.Set("PrestadorFantasia", txtFantasia.Text);
config.Set("PrestadorFone", txtFone.Text);
config.Set("PrestadorCEP", txtCEP.Text);
config.Set("PrestadorEndereco", txtEndereco.Text);
config.Set("PrestadorNumero", txtNumero.Text);
config.Set("PrestadorComplemento", txtComplemento.Text);
config.Set("PrestadorBairro", txtBairro.Text);
config.Set("Municipio", txtCodCidade.Text.OnlyNumbers());
config.Set("Ambiente", cmbAmbiente.GetSelectedValue<DFeTipoAmbiente>());
config.Set("Certificado", txtCertificado.Text);
config.Set("Senha", txtSenha.Text);
config.Set("NumeroSerie", txtNumeroSerie.Text);
config.Set("UsuarioWebservice", txtWebserviceUsuario.Text);
config.Set("SenhaWebservice", txtWebserviceSenha.Text);
config.Set("PastaSchemas", txtSchemas.Text);
config.Set("ArquivoCidades", txtArquivoCidades.Text);
if (chkSalvarArquivos.Checked == true)
{
config.Set("SalvarNfse", "1");
}
else
{
config.Set("SalvarNfse", "0");
}
config.Set("CaminhoXML", txtPathXml.Text);
config.Save();
}