Exemplo n.º 1
0
 private void afterBusca()
 {
     bsConsultaDest.DataSource = TCN_ConsultaDest.Buscar(empresa.SelectedItem == null ? string.Empty : empresa.SelectedValue.ToString(),
                                                         string.Empty,
                                                         chaveBusca.Text,
                                                         emitenteBusca.Text,
                                                         dt_ini.Text,
                                                         dt_fin.Text,
                                                         true,
                                                         cbXmlBaixado.Checked ? "S" : cbXmlBaixar.Checked ? "N" : string.Empty,
                                                         cbXmlImportado.Checked ? "S" : cbXmlImportar.Checked ? "N" : string.Empty,
                                                         cbOpConfirmada.Checked ? "S" : cbConfirmarOp.Checked ? "N" : string.Empty,
                                                         null);
 }
Exemplo n.º 2
0
 private void Consultar()
 {
     if (rCfgNfe == null)
     {
         MessageBox.Show("Não existe configuração NFe para a empresa selecionada!", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     if (!string.IsNullOrWhiteSpace(txtChaveAcesso.Text) && txtChaveAcesso.Text.Length < 44)
     {
         MessageBox.Show("Obrigatório informar chave de acesso valida para consultar.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
         txtChaveAcesso.Clear();
         return;
     }
     if (txtChaveAcesso.Text.Trim().Length.Equals(44))
     {
         TList_ConsultaDest lista = TCN_ConsultaDest.Buscar(empresa.SelectedItem == null ? string.Empty : empresa.SelectedValue.ToString(),
                                                            string.Empty,
                                                            txtChaveAcesso.Text,
                                                            string.Empty,
                                                            string.Empty,
                                                            string.Empty,
                                                            true,
                                                            string.Empty,
                                                            string.Empty,
                                                            string.Empty,
                                                            null);
         if (lista.Count > 0)
         {
             MessageBox.Show("Chave de acesso já existe na base Aliance.NET.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
             bsConsultaDest.DataSource = lista;
             return;
         }
     }
     try
     {
         TList_ConsultaDest lConsulta =
             srvNFE.DistribuicaoDFe.TDistribuicaoDFe.DistribuicaoDFe(rCfgNfe,
                                                                     empresa.SelectedItem as TRegistro_CadEmpresa,
                                                                     string.Empty,
                                                                     string.IsNullOrWhiteSpace(txtChaveAcesso.Text) ? txtUltimoNSU.Text : string.Empty,
                                                                     txtChaveAcesso.Text);
         //Gravar consulta no banco
         lConsulta.ForEach(p => TCN_ConsultaDest.Gravar(p, null));
         bsConsultaDest.DataSource = lConsulta.Where(p => !string.IsNullOrEmpty(p.St_nfe)).ToList();
         //Buscar ultimo NSU consultado
         object obj = new TCD_ConsultaDest().BuscarEscalar(
             new Utils.TpBusca[]
         {
             new Utils.TpBusca()
             {
                 vNM_Campo = "a.cd_empresa",
                 vOperador = "=",
                 vVL_Busca = "'" + empresa.SelectedValue.ToString().Trim() + "'"
             }
         }, "max(nsu)");
         if (obj == null ? false : !string.IsNullOrEmpty(obj.ToString()))
         {
             txtUltimoNSU.Text = obj.ToString();
         }
     }
     catch (Exception ex)
     { MessageBox.Show(ex.Message.Trim(), "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); }
 }