public void Populate(NFe.Settings.Empresa empresa, bool novaempresa)
{
this.loading = true;
try
{
uninfeDummy.ClearControls(this, true, false);
this.empresa = empresa;
if (empresa.Servico == TipoAplicativo.Nfse)
{
labelUF.Text = "MunicĂpio";
lbl_udDiasLimpeza.Location = new Point(this.lbl_udTempoConsulta.Location.X, this.lbl_udTempoConsulta.Location.Y);
udDiasLimpeza.Location = new Point(this.udTempoConsulta.Location.X, this.udTempoConsulta.Location.Y);
}
else
{
labelUF.Text = "Unidade Federativa (UF-Estado)";
lbl_udDiasLimpeza.Location = loc_1;
udDiasLimpeza.Location = loc_2;
}
this.lbl_CodMun.Visible =
this.edtCodMun.Visible =
this.edtPadrao.Visible =
this.lbl_Padrao.Visible = (empresa.Servico == TipoAplicativo.Nfse);
cboDiretorioSalvarComo.Visible =
lbl_DiretorioSalvarComo.Visible =
comboBox_tpEmis.Visible =
metroLabel11.Visible =
checkBoxGravarEventosNaPastaEnviadosNFe.Visible =
checkBoxRetornoNFETxt.Visible =
checkBoxGravarEventosDeTerceiros.Visible =
checkBoxGravarEventosCancelamentoNaPastaEnviadosNFe.Visible =
checkBoxCompactaNFe.Visible =
udTempoConsulta.Visible = lbl_udTempoConsulta.Visible =
cbIndSinc.Visible = !(empresa.Servico == TipoAplicativo.Nfse);
/*
if (empresa.Servico == TipoAplicativo.Nfe || empresa.Servico == TipoAplicativo.NFCe || empresa.Servico == TipoAplicativo.Todos)
{
grpQRCode.Visible =
edtIdentificadorCSC.Visible =
edtTokenCSC.Visible = true;
}
else
{
grpQRCode.Visible =
edtIdentificadorCSC.Visible =
edtTokenCSC.Visible = false;
}
*/
if (empresa.Servico == TipoAplicativo.Nfse)
comboBox_UF.DataSource = arrMunicipios;
else
comboBox_UF.DataSource = arrUF;
comboBox_UF.DisplayMember = NFe.Components.NFeStrConstants.Nome;
comboBox_UF.ValueMember = "Codigo";
cnpjCurrent = this.edtCNPJ.Text = empresa.CNPJ;
this.edtNome.Text = empresa.Nome;
if (!string.IsNullOrEmpty(empresa.CNPJ))
this.edtCNPJ.Text = uninfeDummy.FmtCnpjCpf(this.edtCNPJ.Text, true);
comboBox_tpEmis.SelectedValue = this.empresa.tpEmis;
comboBox_Ambiente.SelectedValue = this.empresa.AmbienteCodigo;
comboBox_UF.SelectedValue = this.empresa.UnidadeFederativaCodigo;
cbServico.SelectedValue = (int)this.empresa.Servico;
if (empresa.Servico == TipoAplicativo.Nfse && this.empresa.UnidadeFederativaCodigo == 0)
comboBox_UF.SelectedIndex = 0;
checkBoxRetornoNFETxt.Checked = this.empresa.GravarRetornoTXTNFe;
checkBoxGravarEventosDeTerceiros.Checked = this.empresa.GravarEventosDeTerceiros;
checkBoxGravarEventosNaPastaEnviadosNFe.Checked = this.empresa.GravarEventosNaPastaEnviadosNFe;
checkBoxGravarEventosCancelamentoNaPastaEnviadosNFe.Checked = this.empresa.GravarEventosCancelamentoNaPastaEnviadosNFe;
checkBoxCompactaNFe.Checked = this.empresa.CompactarNfe;
cbIndSinc.Checked = this.empresa.IndSinc;
edtIdentificadorCSC.Text = this.empresa.IndentificadorCSC;
edtTokenCSC.Text = this.empresa.TokenCSC;
cboDiretorioSalvarComo.Text = this.empresa.DiretorioSalvarComo;
udDiasLimpeza.Text = this.empresa.DiasLimpeza.ToString();
udTempoConsulta.Text = this.empresa.TempoConsulta.ToString();
this.txtSenhaWS.Text = this.empresa.SenhaWS;
this.txtUsuarioWS.Text = this.empresa.UsuarioWS;
HabilitaUsuarioSenhaWS(this.empresa.UnidadeFederativaCodigo);
servicoCurrent = this.empresa.Servico;
HabilitaOpcaoCompactar(this.empresa.Servico == TipoAplicativo.Nfe);
this.edtCNPJ.ReadOnly = !string.IsNullOrEmpty(empresa.CNPJ);
this.cbServico.Enabled = !this.edtCNPJ.ReadOnly;
if (this.empresa.Servico != TipoAplicativo.Nfse && !novaempresa)
this.cbServico.Enabled = true;
}
finally
{
this.loading = false;
cbServico_SelectedIndexChanged(null, null);
comboBox_UF_SelectedIndexChanged(null, null);
}
}