示例#1
0
        private void frmImportaEscritorNfe_Load(object sender, EventArgs e)
        {
            try
            {
                belInfNFe       objInfNFe       = new belInfNFe();
                belEscrituracao objEscrituracao = new belEscrituracao(objInfNFe);

                cbxEmpresas.DisplayMember = "Descricao";
                cbxEmpresas.ValueMember   = "Codigo";

                cbxEmpresas.DataSource = objEscrituracao.RetornaEmpresa();
            }
            catch (Exception ex)
            {
                new HLPexception(ex);
            }
        }
示例#2
0
        private void btnImporta_Click(object sender, EventArgs e)
        {
            string sArquivoXML = string.Empty;

            try
            {
                if (txtXml.Text == "")
                {
                    throw new Exception("Pasta dos Arquivos Xml não foi selecionada");
                }

                if (cbxEmpresas.SelectedValue.ToString() == "")
                {
                    throw new Exception("Empresa para Importação não foi selecionada");
                }

                List <string> lsXmls = new List <string>();

                for (int i = 0; i < dgvXmls.RowCount; i++)
                {
                    if (((dgvXmls["Selecionar", i].Value != null) && (dgvXmls["Selecionar", i].Value.ToString().Equals("True"))))
                    {
                        lsXmls.Add((string)dgvXmls["Arquivo", i].Value);
                    }
                }

                if (lsXmls.Count > 0)
                {
                    pgbNF.Step    = 1;
                    pgbNF.Minimum = 0;
                    pgbNF.Maximum = lsXmls.Count;
                    pgbNF.MarqueeAnimationSpeed = lsXmls.Count;
                    pgbNF.Value = 0;

                    for (int i = 0; i < lsXmls.Count; i++)
                    {
                        try
                        {
                            lblStatusScrituracao.Text = "Escriturando " + (i + 1).ToString() + " de " + lsXmls.Count.ToString();
                            pgbNF.PerformStep();
                            statusStrip1.Refresh();
                            this.Refresh();
                            sArquivoXML = lsXmls[i];
                            belImportaXmlNFe xmlEscritor = new belImportaXmlNFe(lsXmls[i]);
                            belInfNFe        objInfNFe   = xmlEscritor.MontaInfNFe();
                            objInfNFe.Empresa = cbxEmpresas.SelectedValue.ToString();
                            belEscrituracao objEscrituracao = new belEscrituracao(objInfNFe);
                        }
                        catch (Exception ex)
                        {
                            new HLPexception(ex);
                        }
                    }
                    KryptonMessageBox.Show(null,
                                           string.Format("Importação efetuada com Sucesso!"),
                                           "Importação de XML",
                                           MessageBoxButtons.OK,
                                           MessageBoxIcon.Information);
                    pgbNF.Value = 0;
                    //toolStripButton2_Click(sender, e);
                    lblarquivosEscriturados.Text = "Escriturado " + lsXmls.Count.ToString() + " registro(s) de " + lsXmls.Count.ToString();
                }
                else
                {
                    KryptonMessageBox.Show(null,
                                           string.Format("Nenhum Xml Foi selecionado!"),
                                           "Importação de XML",
                                           MessageBoxButtons.OK,
                                           MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                if (!String.IsNullOrEmpty(sArquivoXML))
                {
                    KryptonMessageBox.Show(null,
                                           string.Format("Não foi possível importar o Xml. Erro {0}, Lendo o Arquivo {1}",
                                                         ex.Message,
                                                         sArquivoXML),
                                           Mensagens.MSG_Aviso,
                                           MessageBoxButtons.OK,
                                           MessageBoxIcon.Information);
                }
                else
                {
                    new HLPexception(ex);
                }
            }
        }