private void dgvFilaDeServicos_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex.Equals(4))
     {
         //MessageBox.Show(((ServicoPendente)dgvFilaDeServicos.Rows[e.RowIndex].DataBoundItem).xmlRecibo);
         try
         {
             FrmVisualizaXML oFrmXML = new FrmVisualizaXML(
                 ((ServicoPendente)dgvFilaDeServicos.Rows[e.RowIndex].DataBoundItem).xmlRecibo);
             oFrmXML.ShowDialog();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     if (e.ColumnIndex.Equals(5))
     {
         //MessageBox.Show(((ServicoPendente)dgvFilaDeServicos.Rows[e.RowIndex].DataBoundItem).xmlRecibo);
         try
         {
             FrmVisualizaXML oFrmXML = new FrmVisualizaXML(
                 ((ServicoPendente)dgvFilaDeServicos.Rows[e.RowIndex].DataBoundItem).xmlRetConsulta);
             oFrmXML.ShowDialog();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Example #2
0
 private void dgvNotaInutilizada_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex.Equals(3))
     {
         //MessageBox.Show(((NotaInutilizada)dgvNotaInutilizada.Rows[e.RowIndex].DataBoundItem).XMLPedido);
         try
         {
             FrmVisualizaXML oFrmXML = new FrmVisualizaXML(
                 ((NotaInutilizada)dgvNotaInutilizada.Rows[e.RowIndex].DataBoundItem).XMLPedido);
             oFrmXML.ShowDialog();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else if (e.ColumnIndex.Equals(4))
     {
         //MessageBox.Show(((NotaInutilizada)dgvNotaInutilizada.Rows[e.RowIndex].DataBoundItem).XMLResposta);
         try
         {
             FrmVisualizaXML oFrmXML = new FrmVisualizaXML(
                 ((NotaInutilizada)dgvNotaInutilizada.Rows[e.RowIndex].DataBoundItem).XMLResposta);
             oFrmXML.ShowDialog();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Example #3
0
 private void dgvNotaFiscal_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex.Equals(5))
     {
         //MessageBox.Show(((NotaFiscal)dgvNotaFiscal.Rows[e.RowIndex].DataBoundItem).xmlNota);
         try
         {
             FrmVisualizaXML oFrmXML = new FrmVisualizaXML(
                 ((NotaFiscal)dgvNotaFiscal.Rows[e.RowIndex].DataBoundItem).xmlNota);
             oFrmXML.Show();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else if (e.ColumnIndex.Equals(6))
     {
         //MessageBox.Show(((NotaFiscal)dgvNotaFiscal.Rows[e.RowIndex].DataBoundItem).xmlProcessoFinal);
         try
         {
             FrmVisualizaXML oFrmXML = new FrmVisualizaXML(
                 ((NotaFiscal)dgvNotaFiscal.Rows[e.RowIndex].DataBoundItem).xmlProcesso);
             oFrmXML.Show();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
        void oFrmChave_DoOnOkClick(object sender, EventArgs e)
        {
            //consulta status do servidor
            ClientEnvironment manager = null;

            try
            {
                manager = Conexao.CreateManager(Program.ConAux);
                FuncaoAutomacao oFuncao = new FuncaoAutomacao(Program.empresaSelecionada, manager, Program.enviarInformacoesSobreErros);

                if (!oFuncao.ConsultaProcNFe(oFrmChave.TextResposta.Text))
                {
                    throw new Exception("Erro não mapeado. Verificar o LOG do sistema.");
                }
                else
                {
                    //arquivo de retorno estara em oParam.pastaRecibo + ChaveNFe + "-sit.xml",
                    ITRetConsSitNFe oRetConsSitNFe =
                        (ITRetConsSitNFe)XMLUtils.CarregaXML_HD(Program.GetParametro(Program.empresaSelecionada, manager).pastaRecibo + oFrmChave.TextResposta.Text + "-sit.xml",
                                                                oFuncao.oParam.versao,
                                                                "TRetConsSitNFe");

                    oFrmChave.Close();
                    oFrmChave.Dispose();

                    FrmVisualizaXML oFrmXML = new FrmVisualizaXML(XMLUtils.GetXML(oRetConsSitNFe, oFuncao.oParam.versao));
                    oFrmXML.ShowDialog();

                    oRetConsSitNFe = null;
                    oFuncao        = null;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Conexao.DisposeManager(manager);
            }
        }
        private void dgvEventos_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex.Equals(2))
            {
                try
                {
                    FrmVisualizaXML oFrmXML = new FrmVisualizaXML(
                        ((Evento)dgvEventos.Rows[e.RowIndex].DataBoundItem).XMLPedido);
                    oFrmXML.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (e.ColumnIndex.Equals(3))
            {
                try
                {
                    FrmVisualizaXML oFrmXML = new FrmVisualizaXML(
                        ((Evento)dgvEventos.Rows[e.RowIndex].DataBoundItem).XMLResposta);
                    oFrmXML.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if (e.ColumnIndex.Equals(4))
            {
                try
                {
                    oEvento = (Evento)dgvEventos.Rows[e.RowIndex].DataBoundItem;

                    if (oEvento.codigoSituacao != TipoSituacaoEvento.FinalizadoAprovado135 &&
                        oEvento.codigoSituacao != TipoSituacaoEvento.FinalizadoAprovado136 &&
                        oEvento.codigoSituacao != TipoSituacaoEvento.FinalizadoAprovado155)
                    {
                        throw new Exception("Evento não aprovado");
                    }


                    //solicitar usuario local para save
                    sfdProcNFeCCe.Filter = "Arquivo XML|*.xml";
                    sfdProcNFeCCe.Title  = "Salvar arquivo";

                    string sufixo = "";
                    if (oEvento.tpEvento == TEventoInfEventoTpEvento.CartaCorrecao)
                    {
                        sufixo = "_v1.00-procCCe.xml";
                    }
                    else if (oEvento.tpEvento == TEventoInfEventoTpEvento.Cancelamento)
                    {
                        sufixo = "_v1.00-procEventoCancNFe.xml";
                    }
                    else
                    {
                        sufixo = ".xml";
                    }

                    sfdProcNFeCCe.FileName = ((ITEvento)XMLUtils.CarregaXML_STR(oEvento.XMLPedido,
                                                                                oNFe.versao,
                                                                                "TEvento")).infEvento.Id + sufixo;

                    sfdProcNFeCCe.ShowDialog();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    oEvento = null;
                }
            }
            else if (e.ColumnIndex.Equals(5))
            {
                //gerar arquivo para danfe.exe
                #region imprimir evento

                ClientEnvironment manager = null;
                Parametro         oParam  = null;

                try
                {
                    manager = Conexao.CreateManager(Program.ConAux);
                    oParam  = Program.GetParametro(Program.empresaSelecionada, manager);
                    oEvento = (Evento)dgvEventos.Rows[e.RowIndex].DataBoundItem;

                    if (oEvento.codigoSituacao != TipoSituacaoEvento.FinalizadoAprovado135 &&
                        oEvento.codigoSituacao != TipoSituacaoEvento.FinalizadoAprovado136 &&
                        oEvento.codigoSituacao != TipoSituacaoEvento.FinalizadoAprovado155)
                    {
                        throw new Exception("Evento não aprovado");
                    }

                    //tratar envio de xml para destinatário.
                    string sufixo = "";
                    if (oEvento.tpEvento == TEventoInfEventoTpEvento.CartaCorrecao)
                    {
                        sufixo = "_v1.00-procCCe.xml";
                    }
                    else if (oEvento.tpEvento == TEventoInfEventoTpEvento.Cancelamento)
                    {
                        sufixo = "_v1.00-procEventoCancNFe.xml";
                    }
                    else
                    {
                        sufixo = ".xml";
                    }

                    String nomeArquivo = ((ITEvento)XMLUtils.CarregaXML_STR(oEvento.XMLPedido,
                                                                            oNFe.versao,
                                                                            "TEvento")).infEvento.Id + sufixo;

                    ITNFe oNFeXML = (ITNFe)
                                    XMLUtils.CarregaXML_STR(oNFe.xmlNota,
                                                            oNFe.versao,
                                                            "TNFe");

                    //salvar TXT com dados complementares
                    if (File.Exists(oParam.pastaImpressao + nomeArquivo.Replace(".xml", ".txt")))
                    {
                        File.Delete(oParam.pastaImpressao + nomeArquivo.Replace(".xml", ".txt"));
                    }

                    //gerar arquivo TXT com o email do destinatário
                    using (StreamWriter oSW = File.CreateText(oParam.pastaImpressao + nomeArquivo.Replace(".xml", ".txt")))
                    {
                        //dados destinatarios
                        oSW.WriteLine(oNFeXML.infNFe.dest.xNome);
                        oSW.WriteLine(oNFeXML.infNFe.dest.enderDest.xLgr + ", " + oNFeXML.infNFe.dest.enderDest.nro);
                        oSW.WriteLine(oNFeXML.infNFe.dest.enderDest.xBairro);
                        oSW.WriteLine(oNFeXML.infNFe.dest.enderDest.CEP);
                        oSW.WriteLine(oNFeXML.infNFe.dest.enderDest.xMun);
                        oSW.WriteLine(oNFeXML.infNFe.dest.enderDest.fone);
                        oSW.WriteLine(oNFeXML.infNFe.dest.enderDest.UF);
                        oSW.WriteLine(oNFeXML.infNFe.dest.IE);

                        //dados emitente
                        oSW.WriteLine(oNFeXML.infNFe.emit.xNome);
                        oSW.WriteLine(oNFeXML.infNFe.emit.enderEmit.xLgr + ", " + oNFeXML.infNFe.emit.enderEmit.nro);
                        oSW.WriteLine(oNFeXML.infNFe.emit.enderEmit.xBairro);
                        oSW.WriteLine(oNFeXML.infNFe.emit.enderEmit.CEP);
                        oSW.WriteLine(oNFeXML.infNFe.emit.enderEmit.xMun);
                        oSW.WriteLine(oNFeXML.infNFe.emit.enderEmit.fone);
                        oSW.WriteLine(oNFeXML.infNFe.emit.enderEmit.UF);
                        oSW.WriteLine(oNFeXML.infNFe.emit.IE);

                        oSW.WriteLine(oNFeXML.infNFe.ide.nNF);
                        oSW.WriteLine(oNFeXML.infNFe.ide.serie);
                        oSW.WriteLine(oNFeXML.infNFe.ide.dEmi);

                        oSW.Close();
                    }
                    GC.Collect();

                    NFeUtils.GeraArquivoProcEventoNFe(oEvento, oParam.pastaImpressao + nomeArquivo, oNFe.versao);

                    MessageBox.Show("Arquivo enviado para servidor de impressão.");

                    oNFeXML = null;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    oEvento = null;
                    Conexao.DisposeManager(manager);
                    oParam = null;
                }
                #endregion
            }
        }