コード例 #1
0
        public void Gerar_Dados_NFe(IList <int> ilNotas_Fiscais)
        {
            CompSoft.Tools.frmWait f = new CompSoft.Tools.frmWait("Aguarde, carregado dados para exportação.");

            //-- Adicionar todos as NF selecionados em clausula IN do SQL
            sNotasFiscais = this.Criar_IN_NF(ilNotas_Fiscais);

            //-- Encontra as empresas que estão na NF.
            this.Empresas_NF();

            //-- Buscar todas as NF´s
            this.Gera_Dados_Capa_NFPaulista();

            //-- Buscar todos os Itens das NF´s
            this.Gera_Dados_Itens_NFPaulista();

            f.Close();
            f.Dispose();

            //-- Cria NF-Paulista
            if (nfp.Criar_NFPaulista())
            {
                MsgBox.Show("Nota Fiscal Paulista gerada e enviada com sucesso."
                            , "Envio com sucesso"
                            , System.Windows.Forms.MessageBoxButtons.OK
                            , System.Windows.Forms.MessageBoxIcon.Information);
            }
            else
            {
                MsgBox.Show("Erro ao gerar ou enviar Nota Fiscal Paulista, consulte o log de envio para verificar os possiveis problemas."
                            , "Atenção"
                            , System.Windows.Forms.MessageBoxButtons.OK
                            , System.Windows.Forms.MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        private void cmdGerarParcelas_Click(object sender, EventArgs e)
        {
            CompSoft.Tools.frmWait f = new CompSoft.Tools.frmWait("Aguarde, o sistema está gerando as parcelas", true, int.Parse(this.txtQtdeParcelas.Text), 0);

            //-- Gera parcelamento.
            for (int i = 1; i <= int.Parse(this.txtQtdeParcelas.Text); i++)
            {
                //-- Novo item
                this.agParcelas.Novo_Item();

                //-- Trata os dados para incluir no DB
                this.grdParcelas.CurrentRow["Parcela"]       = i.ToString();
                this.grdParcelas.CurrentRow["Data_Cadastro"] = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                this.grdParcelas.CurrentRow["Data_Emissao"]  = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                this.grdParcelas.CurrentRow["Parcela_paga"]  = false;

                //-- Verifica o tipo de parcelamento.
                if (this.opgParcelamento_DiaFixo.Checked)
                {
                    DateTime dt = Convert.ToDateTime(this.txtPrimeiraDataVencimento.EditValue).AddMonths(i - 1);
                    this.grdParcelas.CurrentRow["Data_Vencimento"] = dt;
                }

                if (this.optParcelamento_EmDias.Checked)
                {
                    int iSomaDias = 0;

                    iSomaDias = int.Parse(this.txtParcelamentoQtde.Text) * (i - 1);

                    DateTime dt = Convert.ToDateTime(this.txtPrimeiraDataVencimento.EditValue).AddDays(iSomaDias);
                    this.grdParcelas.CurrentRow["Data_Vencimento"] = dt;
                }

                //-- Faz o calculo dos valores das parcelas
                if (i != int.Parse(this.txtQtdeParcelas.Text))
                {
                    this.grdParcelas.CurrentRow["Valor_Original"] = Convert.ToString(decimal.Round(Convert.ToDecimal(this.txtValorOriginal.Text) / Convert.ToInt32(this.txtQtdeParcelas.Text), 2));
                    this.grdParcelas.CurrentRow["Valor_Pagar"]    = Convert.ToString(decimal.Round(Convert.ToDecimal(this.txtValorPagar.Text) / Convert.ToInt32(this.txtQtdeParcelas.Text), 2));
                }
                else
                {
                    if (i == 1)
                    {
                        this.grdParcelas.CurrentRow["Valor_Original"] = Convert.ToString(decimal.Round(Convert.ToDecimal(this.txtValorOriginal.Text) / Convert.ToInt32(this.txtQtdeParcelas.Text)));
                        this.grdParcelas.CurrentRow["Valor_Pagar"]    = Convert.ToString(decimal.Round(Convert.ToDecimal(this.txtValorPagar.Text) / Convert.ToInt32(this.txtQtdeParcelas.Text)));
                    }
                    else
                    {
                        decimal dSubTotal = Convert.ToDecimal(this.DataSetLocal.Tables["Contas_pagar_parcela"].Compute("sum(Valor_Pagar)", ""));

                        this.grdParcelas.CurrentRow["Valor_Original"] = Convert.ToString(Convert.ToDecimal(this.txtValorOriginal.Text) - dSubTotal);
                        this.grdParcelas.CurrentRow["Valor_Pagar"]    = Convert.ToString(Convert.ToDecimal(this.txtValorPagar.Text) - dSubTotal);
                    }
                }

                f.Atual_Progresso = i;
            }

            f.Close();
        }
コード例 #3
0
        private void cmdBaixarEstoque_Click(object sender, EventArgs e)
        {
            DataRow[] fRow_doc = ((DataTable)this.grdItens.BindingSource.DataSource).Select("Sel = 1");

            if (fRow_doc.Length == 0)
            {
                MsgBox.Show("Selecione documentos para baixar o estoque."
                            , "Atenção"
                            , MessageBoxButtons.OK
                            , MessageBoxIcon.Information);
            }
            else
            {
                string sMensagem = string.Empty;
                if (fRow_doc.Length == 1)
                {
                    sMensagem = "Será baixado 1 documento, você confirma?";
                }
                else
                {
                    sMensagem = string.Format("Serão baixados {0} documentos, você confirma?", fRow_doc.Length);
                }

                DialogResult dr = MsgBox.Show(sMensagem
                                              , "Atenção"
                                              , MessageBoxButtons.YesNo
                                              , MessageBoxIcon.Question);

                if (dr == DialogResult.Yes)
                {
                    CompSoft.Tools.frmWait f = new CompSoft.Tools.frmWait("Aguarde, baixando itens do estoque...", CompSoft.Tools.frmWait.Tipo_Imagem.Atencao);

                    ERP.Class.clsControleEstoque ce = new ERP.Class.clsControleEstoque();
                    foreach (DataRow row_doc in fRow_doc)
                    {
                        string sSQL = "select Produto, Quantidade from notas_fiscais_itens where nota_fiscal = {0} ";
                        sSQL = string.Format(sSQL, row_doc["Nota_Fiscal"]);
                        DataRow[] fRow_Itens = SQL.Select(sSQL, "", false).Select();

                        //-- Loop com todos os itens da nota.
                        foreach (DataRow row_itens in fRow_Itens)
                        {
                            //-- Movimenta estoque
                            ce.Inclusao_Item_Nota_Fiscal(Convert.ToInt32(row_doc["Empresa"])
                                                         , Convert.ToInt32(row_itens["Produto"])
                                                         , Convert.ToInt32(row_itens["Quantidade"]));
                        }

                        //-- Marca a nota fiscal como baixada para verificação no cancelamento para retornar itens para o estoque.
                        ce.Marca_Nota_Fiscal_Baixada(Convert.ToInt32(row_doc["Nota_Fiscal"]));
                    }

                    ((DataTable)this.grdItens.BindingSource.DataSource).Clear();
                    this.cmdBaixarEstoque.Visible = false;

                    f.Close();
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Envia nota fiscal atravéz do WebService
        /// </summary>
        /// <param name="ilNotas_Fiscais">IList<Dados_Arquivos_NFe> com todas as notas para exportação.</param>
        /// <param name="sFolder">string com a Path completa para envio da NF-e.</param>
        public void Enviar_NFe(IList <CompSoft.NFe.Dados_Arquivo_NFe> ilNotas_Fiscais, string sFolder)
        {
            CompSoft.Tools.frmWait f = new CompSoft.Tools.frmWait("Aguarde, buscando informações no banco de dados.");
            f.Show();

            //-- Busca dados para geração da NF-e
            ERP.NFe.GerarDadosNFe dados_NFe = new ERP.NFe.GerarDadosNFe();
            dados_NFe.Gerar_Dados_NFe(ilNotas_Fiscais);

            f.Mensagem = "Aguarde, gerando arquivos XML da NF-e.";

            //-- Gera NF-e em uma pasta especifica para envio ao cliente.
            ERP.NFe.XML_NFe nfe = new ERP.NFe.XML_NFe(sFolder, dados_NFe.DataSet_NFe, ilNotas_Fiscais);
            nfe.Gerar_XML_NFe();

            f.Progresso        = true;
            f.Maximo_Progresso = ilNotas_Fiscais.Count;
            f.Mensagem         = "Aguarde, o sistema está assinando, transfêrindo e imprimindo o DANFE das notas fiscais autorizadas.";

            //-- Instancia classe de tratamento do WebService NF-e
            //-- Verifica se o WebService está ativo.
            NFeWebService wb_Nfe = new NFeWebService();

            if (wb_Nfe.Status_WebService(ilNotas_Fiscais[0]))
            {
                //-- Assina o XML.
                foreach (Dados_Arquivo_NFe daNFe in ilNotas_Fiscais)
                {
                    //-- Assina NF-e
                    CompSoft.NFe.AssinaXML assinar = new CompSoft.NFe.AssinaXML();
                    assinar.AssinarArquivoXML(daNFe.Arquivo_XML, "infNFe", this.Retorna_SerialNumber(daNFe.Empresa));

                    //-- Envia o Lote da NF-e.
                    this.SalvaXML_DB(daNFe, false);
                    XmlDocument doc       = wb_Nfe.Enviar_LoteNFe(daNFe);
                    int         iAguardar = this.Trata_Arquivo_Retorno_NFe(doc, daNFe); //-- Faz o tratamento dos dados e envia para o banco de dados.

                    //-- Aguarda 3 vezes o tempo necessário para garentir a recepção do retorno dos dados.
                    System.Threading.Thread.Sleep(5000);

                    //-- Captura o resultado de processamento.
                    this.Resultado_Processamento_NFe(daNFe);

                    //-- avança um na barra de progresso.
                    f.Atual_Progresso++;
                }
            }
            else
            {
                MsgBox.Show("O WebService está fora do ar, tente novamente mais tarde."
                            , "Atenção"
                            , System.Windows.Forms.MessageBoxButtons.OK
                            , System.Windows.Forms.MessageBoxIcon.Error);
            }

            f.Close();
            f.Dispose();
        }
コード例 #5
0
        private void f0047_FormClosing(object sender, FormClosingEventArgs e)
        {
            CompSoft.Tools.frmWait f = new CompSoft.Tools.frmWait("Aguarde, atualizando ambiente.");
            Funcoes func;

            func.AlimentaPropriedades_Sist();
            f.Close();
            f.Dispose();
        }
コード例 #6
0
        public void Cancelar_NFe(IList <Dados_Arquivo_NFe> ilNotas)
        {
            CompSoft.Tools.frmWait f = new CompSoft.Tools.frmWait("Aguarde, cancelando NF-e no SEFAZ.", true, ilNotas.Count);

            foreach (Dados_Arquivo_NFe daNFe in ilNotas)
            {
                //-- Busca informações no WebService
                CompSoft.NFe.TrataWebService.NFeWebService wb_NFe = new CompSoft.NFe.TrataWebService.NFeWebService();
                XmlDocument doc = wb_NFe.Cancelar_NFe(daNFe);

                StringBuilder sb = new StringBuilder(300);

                //-- Verifica se a mensagem é de confirmação do cancelamento da NF-e
                if (Convert.ToInt32(doc.GetElementsByTagName("cStat")[0].InnerText) == 101)
                {
                    sb.Append("update notas_fiscais_lotes set ");
                    sb.AppendFormat("     codigo_mensagem_retorno_nfe = {0}", doc.GetElementsByTagName("cStat")[0].InnerText);
                    sb.AppendFormat("   , protocolo_cancelamento_nfe = '{0}'", doc.GetElementsByTagName("nProt")[0].InnerText);
                    sb.AppendFormat("   , data_cancelamento_Nfe = '{0}'", doc.GetElementsByTagName("dhRecbto")[0].InnerText.Replace("T", " ").Replace("-", "").Substring(0, 17));
                    sb.AppendFormat("   where nota_fiscal_lote = {0}", daNFe.Cod_Nota_Fiscal_Lote);
                    SQL.ExecuteNonQuery(sb.ToString());

                    sb.Clear();
                    sb.AppendFormat("update notas_fiscais set cancelada = 1 where nota_fiscal = {0}", daNFe.Nota_Fiscal);
                    SQL.ExecuteNonQuery(sb.ToString());

                    ERP.NFe.Enviar_XML_Email envMail_Nfe;
                    envMail_Nfe.Cancelar_NF(daNFe, doc.GetElementsByTagName("nProt")[0].InnerText);
                }
                else
                {
                    int iStatusExiste = Convert.ToInt32(SQL.ExecuteScalar(string.Format("SELECT COUNT(*) FROM MENSAGENS_RETORNO_NFE WHERE CODIGO_MENSAGEM_RETORNO = {0}", doc.GetElementsByTagName("cStat")[1].InnerText)));

                    if (iStatusExiste == 0)
                    {
                        string sQuery = string.Format(@"insert MENSAGENS_RETORNO_NFE values({0}, '{1}')"
                                                      , doc.GetElementsByTagName("cStat")[1].InnerText
                                                      , doc.GetElementsByTagName("xMotivo")[1].InnerText.Replace("'", " "));

                        SQL.ExecuteNonQuery(sQuery);
                    }

                    sb.Append("update notas_fiscais_lotes set ");
                    sb.AppendFormat("     codigo_mensagem_retorno_nfe = {0}", doc.GetElementsByTagName("cStat")[1].InnerText);
                    sb.AppendFormat("   where nota_fiscal_lote = {0}", daNFe.Cod_Nota_Fiscal_Lote);
                    SQL.ExecuteNonQuery(sb.ToString());
                }

                f.Atual_Progresso++;
            }

            f.Close();
            f.Dispose();
        }
コード例 #7
0
        private void cmdEnviarArquivo_Click(object sender, EventArgs e)
        {
            CompSoft.Tools.frmWait f = new CompSoft.Tools.frmWait("Aguarde, enviando arquivo a Secretária da Fazenda.\r\nEste processo poderá demorar alguns minutos.", CompSoft.Tools.frmWait.Tipo_Imagem.Atencao);
            f.Show();

            ERP.NFPaulista.NFP_TrataWS nfp = new ERP.NFPaulista.NFP_TrataWS();

            System.IO.FileInfo fi = new System.IO.FileInfo(txtArquivo.Text);
            int iEmpresa          = Convert.ToInt32(fi.Name.Substring(0, 3));

            IList <int> iLote = new List <int>();

            iLote.Add(Convert.ToInt32(txtLote.Text));
            nfp.Enviar_Arquivos(iEmpresa, iLote);

            Atualizar_Query_Atual();

            f.Close();
        }
コード例 #8
0
        /// <summary>
        /// Gera arquivos da NF-e
        /// </summary>
        private void Gerar_NFe()
        {
            CompSoft.Tools.frmWait f = new CompSoft.Tools.frmWait("Aguarde, separando notas fiscais para transferência da NF-e.", CompSoft.Tools.frmWait.Tipo_Imagem.Informacao);
            f.Show();

            IList <CompSoft.NFe.Dados_Arquivo_NFe> ilNotas_Fiscais = new List <CompSoft.NFe.Dados_Arquivo_NFe>();

            DataRow[] fRow = ((DataTable)this.grdNotasFiscais.BindingSource.DataSource).Select("Sel = 1");
            foreach (DataRow row in fRow)
            {
                ilNotas_Fiscais.Add(new CompSoft.NFe.Dados_Arquivo_NFe(Convert.ToInt32(row["Nota_Fiscal"])));
            }

            f.Close();

            //-- Envia a NF-e
            ERP.NFe.NFe nfe = new ERP.NFe.NFe();
            nfe.Enviar_NFe(ilNotas_Fiscais, this.txtPasta.Text);
        }
コード例 #9
0
        private void Localizar_Registros()
        {
            CompSoft.Tools.frmWait f = new CompSoft.Tools.frmWait("Aguarde, pesquisando dados...");

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("select ");
            sb.AppendLine("  0 as 'sel'");
            sb.AppendLine("  , case pe.gera_nf");
            sb.AppendLine("   when 1 then 'Nota Fiscal'");
            sb.AppendLine("   else 'Cupom'");
            sb.AppendLine("    end as 'Tipo_Documento'");
            sb.AppendLine("  , e.Razao_Social as 'Razao_Social_Cendente'");
            sb.AppendLine("  , cl.Razao_Social as 'Razao_Social_Cliente'");
            sb.AppendLine("  , nf.Numero_Nota");
            sb.AppendLine("  , nf.Data_Emissao");
            sb.AppendLine("  , nfd.Numero_Parcela");
            sb.AppendLine("  , nfd.Valor_Duplicata");
            sb.AppendLine("  , nfd.Data_Vencimento");
            sb.AppendLine("  , nfd.Nota_Fiscal_Duplicata");
            sb.AppendLine("  , coalesce(b.Boleto_Impresso, 0) as 'Boleto_Impresso'");
            sb.AppendLine("  , coalesce(b.ArquivoRemessao_Enviado, 0) as 'ArquivoRemessao_Enviado'");
            sb.AppendLine(" from notas_fiscais nf");
            sb.AppendLine("  inner join notas_fiscais_duplicatas nfd on nf.nota_fiscal = nfd.nota_fiscal");
            sb.AppendLine("  inner join clientes cl on cl.cliente = nf.cliente");
            sb.AppendLine("  inner join empresas e on e.empresa = nf.empresa");
            sb.AppendLine("  inner join pedidos pe on pe.pedido = nf.pedido");
            sb.AppendLine("  inner join contas_correntes cc on cc.empresa = e.empresa");
            sb.AppendLine("  left outer join Boletos_gerados b on b.Nota_Fiscal_Duplicata = nfd.Nota_Fiscal_Duplicata");
            sb.AppendLine(" where nf.Cancelada = 0 and (coalesce(b.Boleto_Impresso, 0) = 0 or coalesce(b.ArquivoRemessao_Enviado, 0) = 0)");
            if (this.chkAtivarEmpresa.Checked && this.cboEmpresa.SelectedIndex >= 0)
            {
                sb.AppendFormat("     AND e.empresa = {0}\r\n", this.cboEmpresa.SelectedValue);
            }

            if (this.chkAtivarDataEmissao.Checked)
            {
                sb.AppendFormat("       AND nfd.data_vencimento between '{0}' and '{1}'\r\n"
                                , this.prdDataEmissao.Data_Inicial_SQL
                                , this.prdDataEmissao.Data_Termino_SQL);
            }

            if (!string.IsNullOrEmpty(this.txtNumeroNF.Text))
            {
                sb.AppendFormat("     AND nf.numero_nota = {0}\r\n", this.txtNumeroNF.Text);
            }

            if (!string.IsNullOrEmpty(this.txtNumeroPedido.Text))
            {
                sb.AppendFormat("     AND pe.pedido = {0}\r\n", this.txtNumeroPedido.Text);
            }

            DataTable dt = SQL.Select(sb.ToString(), "x", false);

            dt.Columns["sel"].ReadOnly = false;

            if (this.grdNotasFiscais.DataSource != null)
            {
                this.grdNotasFiscais.BindingSource.DataSource = dt;
            }
            else
            {
                BindingSource bs = new BindingSource(dt, null);
                this.grdNotasFiscais.DataSource = bs;
            }

            f.Close();
            f.Dispose();
        }
コード例 #10
0
        public bool Criar_NFPaulista()
        {
            bool bRetorno = false;

            CompSoft.Tools.frmWait f = new CompSoft.Tools.frmWait("Aguarde, gerando e enviando arquivo da Nota Fiscal Paulista.\r\nEste processo poderá levar alguns minutos.", CompSoft.Tools.frmWait.Tipo_Imagem.Atencao);

            foreach (DataRow row_Empresa in ds.Tables["Empresas"].Select())
            {
                int iQtdeNF     = 0;
                int iQtdeMaxNF  = 300;
                int iNumArquivo = 1;

                string    sFilter  = string.Format("Empresa = {0}", row_Empresa["empresa"]);
                DataRow[] fRow_NFs = ds.Tables["Notas_Fiscais"].Select(sFilter);
                foreach (DataRow row_NF in fRow_NFs)
                {
                    if (iQtdeNF == iQtdeMaxNF && iQtdeNF != fRow_NFs.Length)
                    {
                        //-- Gera rodape do arquivo
                        this.Rodape_Arquivo();

                        //-- gera o cabecalho do arquivo.
                        this.Cabecalho_Arquivo(row_Empresa, iNumArquivo);

                        //-- Salva arquivo em disco.
                        this.Salvar_Arquivo(row_Empresa, iNumArquivo);

                        iNumArquivo++;
                        iQtdeNF = 0;
                    }

                    //-- Gera notas fiscais
                    this.Gera_Capa_NF(row_NF, iNumArquivo);

                    //-- Verifica se o registro de NF é cancelamento caso seja não cria itens desnecessários nest situação.
                    if (!bNF_Cancelamento)
                    {
                        //-- Gera itens da nota fiscal
                        this.Gera_Itens_NF(Convert.ToInt32(row_NF["nota_fiscal"]));

                        //-- Gera totais da NF
                        this.Gera_Totais_NF(row_NF);

                        //-- Gera dados frete da NF.
                        this.Gera_Dados_Frete(row_NF);
                    }

                    //-- Acrecenta um no contador de NF assim será mais fácil controlar a impressão da NF.
                    iQtdeNF++;
                }

                //-- Final das NF fecha o Arquivo e salva em disco.
                if (iQtdeNF >= fRow_NFs.Length)
                {
                    //-- Gera rodape do arquivo
                    this.Rodape_Arquivo();

                    //-- gera o cabecalho do arquivo.
                    this.Cabecalho_Arquivo(row_Empresa, iNumArquivo);

                    //-- Salva arquivo em disco.
                    this.Salvar_Arquivo(row_Empresa, iNumArquivo);
                }

                //-- processo para envio de dados.
                NFPaulista.NFP_TrataWS ed = new NFPaulista.NFP_TrataWS();
                bRetorno = ed.Enviar_Arquivos(Convert.ToInt32(row_Empresa["Empresa"]), ilLotes);

                ilLotes.Clear();
            }

            f.Close();

            return(bRetorno);
        }
コード例 #11
0
        private void cmdGerarParcelas_Click(object sender, EventArgs e)
        {
            string sErro = string.Empty;

            if (this.txtPrimeiraDataVencimento.EditValue == null)
            {
                sErro += "Informe a primeira data para vencimento.\n";
            }

            if (string.IsNullOrEmpty(this.txtQtdeParcelas.Text))
            {
                sErro += "Informe a quantidade de parcelas do titulo.\n";
            }

            if (this.optParcelamento_EmDias.Checked)
            {
                if (string.IsNullOrEmpty(this.txtParcelamentoQtde.Text))
                {
                    sErro += "A quantidade de dias para parcelamento tem que ser informada.\n";
                }
            }

            if (string.IsNullOrEmpty(sErro))
            {
                CompSoft.Tools.frmWait f = new CompSoft.Tools.frmWait("Aguarde, o sistema está gerando as parcelas", true, int.Parse(this.txtQtdeParcelas.Text), 0);

                //-- Gera parcelamento.
                for (int i = 1; i <= int.Parse(this.txtQtdeParcelas.Text); i++)
                {
                    //-- Novo item
                    this.agParcelas.Novo_Item();

                    //-- Trata os dados para incluir no DB
                    this.grdParcelas.CurrentRow["Parcela"]       = i.ToString();
                    this.grdParcelas.CurrentRow["Data_Cadastro"] = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    this.grdParcelas.CurrentRow["Data_Emissao"]  = Convert.ToDateTime(DateTime.Now.ToShortDateString());
                    this.grdParcelas.CurrentRow["Parcela_Paga"]  = false;
                    this.grdParcelas.CurrentRow["Protesto"]      = false;

                    //-- Verifica o tipo de parcelamento.
                    if (this.opgParcelamento_DiaFixo.Checked)
                    {
                        DateTime dt = Convert.ToDateTime(this.txtPrimeiraDataVencimento.EditValue).AddMonths(i - 1);
                        this.grdParcelas.CurrentRow["Data_Vencimento"] = dt;
                    }

                    if (this.optParcelamento_EmDias.Checked)
                    {
                        int iSomaDias = 0;

                        iSomaDias = int.Parse(this.txtParcelamentoQtde.Text) * (i - 1);

                        DateTime dt = Convert.ToDateTime(this.txtPrimeiraDataVencimento.EditValue).AddDays(iSomaDias);
                        this.grdParcelas.CurrentRow["Data_Vencimento"] = dt;
                    }

                    //-- Faz o calculo dos valores das parcelas
                    if (i != int.Parse(this.txtQtdeParcelas.Text))
                    {
                        this.grdParcelas.CurrentRow["Valor_Original"] = Convert.ToString(decimal.Round(Convert.ToDecimal(this.txtValorOriginal.Text) / Convert.ToInt32(this.txtQtdeParcelas.Text), 2));
                        this.grdParcelas.CurrentRow["Valor_Receber"]  = Convert.ToString(decimal.Round(Convert.ToDecimal(this.txtValorPagar.Text) / Convert.ToInt32(this.txtQtdeParcelas.Text), 2));
                    }
                    else
                    {
                        if (i == 1)
                        {
                            this.grdParcelas.CurrentRow["Valor_Original"] = Convert.ToString(decimal.Round(Convert.ToDecimal(this.txtValorOriginal.Text) / Convert.ToInt32(this.txtQtdeParcelas.Text)));
                            this.grdParcelas.CurrentRow["Valor_Receber"]  = Convert.ToString(decimal.Round(Convert.ToDecimal(this.txtValorPagar.Text) / Convert.ToInt32(this.txtQtdeParcelas.Text)));
                        }
                        else
                        {
                            decimal dSubTotal = Convert.ToDecimal(this.DataSetLocal.Tables["Contas_Receber_parcela"].Compute("sum(Valor_Receber)", ""));

                            this.grdParcelas.CurrentRow["Valor_Original"] = Convert.ToString(Convert.ToDecimal(this.txtValorOriginal.Text) - dSubTotal);
                            this.grdParcelas.CurrentRow["Valor_Receber"]  = Convert.ToString(Convert.ToDecimal(this.txtValorPagar.Text) - dSubTotal);
                        }
                    }

                    f.Atual_Progresso = i;
                }

                f.Close();
            }
            else
            {
                MsgBox.Show("Erro ao realizar parcelamento automático.\n" + sErro
                            , "Alerta"
                            , MessageBoxButtons.OK
                            , MessageBoxIcon.Asterisk);
            }
        }