private void tabCCe_SelectedIndexChanged(object sender, EventArgs e) { try { if (tabCCe.SelectedIndex == 1) { if (bsGrid.Count > 0) { if ((bsGrid.DataSource as List <belPesquisaCCe>).Where(c => c.bSeleciona).Count() > 0) { List <belPesquisaCCe> objLfiltro = ((bsGrid.DataSource as List <belPesquisaCCe>).Where(c => c.bSeleciona).ToList()); belGeraCCe objdaoGeraCCeVisual = new belGeraCCe(objLfiltro); bsEvento.DataSource = objdaoGeraCCeVisual.objEnvEvento.evento; if (bsEvento.Count > 0 || objdaoGeraCCeVisual.objEnvEvento != null) { if (Acesso.NM_RAMO != Acesso.BancoDados.TRANSPORTE) { PopulaTabVisualizacao(bsEvento.Current as belEvento); } else { PopulaTabVisualizacao(objdaoGeraCCeVisual.objEvCCeCTe); } if (bsEvento.Count == 1) { btnFirst.Enabled = false; btnPrevious.Enabled = false; btnNext.Enabled = false; btnLast.Enabled = false; } else { btnFirst.Enabled = true; btnPrevious.Enabled = true; btnNext.Enabled = true; btnLast.Enabled = true; } } } else { LimpaTabVisualizacao(); } } else { LimpaTabVisualizacao(); } } } catch (Exception ex) { new HLPexception(ex); } }
private void btnEnvio_Click(object sender, EventArgs e) { try { if ((bsGrid.DataSource as List <belPesquisaCCe>) != null) { if ((bsGrid.DataSource as List <belPesquisaCCe>).Where(c => c.bSeleciona).Count() > 0) { if (Acesso.NM_RAMO != Acesso.BancoDados.TRANSPORTE) { belPesquisaCCe objbelPesqEnvio = (bsGrid.DataSource as List <belPesquisaCCe>).FirstOrDefault(c => c.bSeleciona); List <belPesquisaCCe> objListaSelect = (bsGrid.DataSource as List <belPesquisaCCe>).Where(c => c.bSeleciona).ToList(); belGeraCCe objbelGeraCCe = new belGeraCCe(objListaSelect); objbelGeraCCe.GeraXmlEnvio(); string sRetorno = objbelGeraCCe.TransmiteLoteCCe(objbelGeraCCe.sXMLfinal); string sMessage = objbelGeraCCe.AnalisaRetornoEnvio(sRetorno); KryptonMessageBox.Show(sMessage, Mensagens.CHeader, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if ((bsGrid.DataSource as List <belPesquisaCCe>).Where(c => c.bSeleciona).Count() > 1) { KryptonMessageBox.Show("Somente uma carta de correção por vez é aceito!", Mensagens.MSG_Aviso, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { belPesquisaCCe objbelPesqEnvio = (bsGrid.DataSource as List <belPesquisaCCe>).FirstOrDefault(c => c.bSeleciona); List <belPesquisaCCe> objListaSelect = (bsGrid.DataSource as List <belPesquisaCCe>).Where(c => c.bSeleciona).ToList(); belGeraCCe objbelGeraCCe = new belGeraCCe(objListaSelect); HLP.GeraXml.bel.CTe.Evento.TRetEvento ret = objbelGeraCCe.TransmiteLoteCCeCTe(); //Testes //string sPath = Pastas.PROTOCOLOS + "\\" + "35140614920065000160570010000011721000029623" + "_ret-cce.xml"; //HLP.GeraXml.bel.CTe.Evento.TRetEvento retorno = SerializeClassToXml.DeserializeClasse<HLP.GeraXml.bel.CTe.Evento.TRetEvento>(sPath); string sMessage = objbelGeraCCe.AnalisaRetornoEnvioCCeCTe(ret, objbelPesqEnvio.CD_NOTAFIS); KryptonMessageBox.Show(sMessage, Mensagens.CHeader, MessageBoxButtons.OK, MessageBoxIcon.Information); } } PesquisaCartas(); } else { KryptonMessageBox.Show("Não há Cartas de Correções válidas selecionadas!", Mensagens.MSG_Aviso, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { new HLPexception(ex); } }