public override bool execute( ) { if (base.execute() == false) { return(false); } Registry("execute fetch_dadosLoja "); /// USER [ execute ] // ## Copia para saida output_cont_dl.set_st_loja(loj.get_st_loja()); output_cont_dl.set_nu_CNPJ(loj.get_nu_CNPJ()); output_cont_dl.set_st_nome(loj.get_st_nome()); output_cont_dl.set_st_social(loj.get_st_social()); output_cont_dl.set_st_endereco(loj.get_st_endereco()); output_cont_dl.set_st_enderecoInst(loj.get_st_enderecoInst()); output_cont_dl.set_nu_inscEst(loj.get_nu_inscEst()); output_cont_dl.set_st_cidade(loj.get_st_cidade()); output_cont_dl.set_st_estado(loj.get_st_estado()); output_cont_dl.set_nu_CEP(loj.get_nu_CEP()); output_cont_dl.set_nu_telefone(loj.get_nu_telefone()); output_cont_dl.set_nu_fax(loj.get_nu_fax()); output_cont_dl.set_st_contato(loj.get_st_contato()); output_cont_dl.set_vr_mensalidade(loj.get_vr_mensalidade()); output_cont_dl.set_nu_contaDeb(loj.get_nu_contaDeb()); output_cont_dl.set_st_obs(loj.get_st_obs()); output_cont_dl.set_nu_pctValor(loj.get_nu_pctValor()); output_cont_dl.set_vr_transacao(loj.get_vr_transacao()); output_cont_dl.set_vr_minimo(loj.get_vr_minimo()); output_cont_dl.set_nu_franquia(loj.get_nu_franquia()); output_cont_dl.set_nu_periodoFat(loj.get_nu_periodoFat()); output_cont_dl.set_nu_diavenc(loj.get_nu_diavenc()); output_cont_dl.set_nu_bancoFat(loj.get_nu_bancoFat()); output_cont_dl.set_tg_tipoCobranca(loj.get_tg_tipoCobranca()); output_cont_dl.set_tg_blocked(loj.get_tg_blocked()); output_cont_dl.set_tg_cancel(loj.get_tg_cancel()); output_cont_dl.set_tg_isento(loj.get_tg_isentoFat()); output_cont_dl.set_st_senhaWeb(loj.get_st_senha()); LINK_LojaEmpresa loj_emp = new LINK_LojaEmpresa(this); T_Empresa emp = new T_Empresa(this); string convs = ""; if (loj_emp.select_fk_loja(loj.get_identity())) { while (loj_emp.fetch()) { emp.selectIdentity(loj_emp.get_fk_empresa()); convs += emp.get_st_empresa().TrimStart('0') + ","; } } output_cont_dl.set_st_convenios(convs.TrimEnd(',')); /// USER [ execute ] END Registry("execute done fetch_dadosLoja "); return(true); }
public override bool authenticate( ) { if (base.authenticate() == false) { return(false); } Registry("authenticate fetch_dadosFaturamento "); /// USER [ authenticate ] T_Faturamento fat = new T_Faturamento(this); T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this); T_Empresa emp = new T_Empresa(this); T_Loja loj = new T_Loja(this); money mon = new money(); string ident = ""; if (input_tg_empresa == Context.TRUE) { if (!emp.select_rows_empresa(input_st_codigo.PadLeft(6, '0'))) { PublishError("Empresa não existente"); return(false); } if (!emp.fetch()) { return(false); } output_st_msg += emp.get_st_social() + "@"; output_st_msg += emp.get_st_fantasia() + "@"; output_st_msg += emp.get_nu_CNPJ() + "@"; output_st_msg += emp.get_nu_telefone() + "@"; output_st_msg += "@Faturamento pendente: @@"; fat.SetReversedFetch(); if (!fat.select_rows_emp(emp.get_identity())) { PublishError("Nenhum faturamento encontrado"); return(false); } ident = emp.get_st_fantasia(); } else { if (!loj.select_rows_loja(input_st_codigo)) { PublishError("Loja não existente"); return(false); } if (!loj.fetch()) { return(false); } output_st_msg += loj.get_st_nome() + "@"; output_st_msg += loj.get_st_social() + "@"; output_st_msg += loj.get_nu_CNPJ() + "@"; output_st_msg += loj.get_nu_telefone(); //fat.SetReversedFetch(); if (!fat.select_rows_loj(loj.get_identity())) { PublishError("Nenhum faturamento encontrado"); return(false); } } bool Found = false; long tot_cob = 0; while (fat.fetch()) { if (fat.get_tg_situacao() == TipoSitFat.Pendente) { output_st_msg += "@@Faturamento pendente: "; Found = true; } else if (fat.get_tg_situacao() == TipoSitFat.EmCobrança) { output_st_msg += "@@Faturamento em cobrança: "; Found = true; } else { continue; } output_st_msg += var_util.getDDMMYYYY_format(fat.get_dt_vencimento()).Substring(0, 10) + "@"; output_st_msg += "@Total: R$ " + mon.formatToMoney(fat.get_vr_cobranca()) + "@"; tot_cob += fat.get_int_vr_cobranca(); if (!fat_det.select_fk_fat(fat.get_identity())) { PublishNote("Nenhum faturamento encontrado"); } output_st_msg += "@------ Detalhes ------- @"; while (fat_det.fetch()) { switch (fat_det.get_tg_tipoFat()) { case TipoFat.TBM: { output_st_msg += "@Tarifa básica mensal: ".PadRight(33, ' ') + "R$ " + mon.formatToMoney(fat_det.get_vr_cobranca()).PadLeft(7, ' '); break; } case TipoFat.CartaoAtiv: { output_st_msg += "@Tarifa por cartões ativos: ".PadRight(33, ' ') + "R$ " + mon.formatToMoney(fat_det.get_vr_cobranca()).PadLeft(7, ' '); break; } case TipoFat.FixoTrans: { output_st_msg += "@Valor sobre Transações: ".PadRight(33, ' ') + "R$ " + mon.formatToMoney(fat_det.get_vr_cobranca()).PadLeft(7, ' '); break; } case TipoFat.Percent: { output_st_msg += "@Percentual sobre Transações: ".PadRight(33, ' ') + "R$ " + mon.formatToMoney(fat_det.get_vr_cobranca()).PadLeft(7, ' '); break; } } } if (!fat_det.select_fk_fat(fat.get_identity())) { PublishError("Nenhum faturamento encontrado"); return(false); } while (fat_det.fetch()) { switch (fat_det.get_tg_tipoFat()) { case TipoFat.Extras: { output_st_msg += "@@------ Extras ------- @"; output_st_msg += "@" + fat_det.get_st_extras().PadRight(32, ' ') + "R$ " + mon.formatToMoney(fat_det.get_vr_cobranca()).PadLeft(7, ' '); break; } } } } if (!Found) { output_st_msg += "@ - Nenhum débito pendente ou em cobrança - @"; } else { output_st_msg += "@@@# Valor completo devido: R$ " + new money().setMoneyFormat(tot_cob) + "@"; } output_vr_valor = tot_cob.ToString(); if (input_tg_empresa == Context.TRUE) { fat_det.select_rows_emp(emp.get_identity(), TipoFat.Extras); } else { fat_det.select_rows_loja(loj.get_identity(), TipoFat.Extras); } if (fat_det.RowCount() > 0) { output_st_msg += "@@------ Lançamentos futuros ------- @"; while (fat_det.fetch()) { output_st_msg += "@" + fat_det.get_st_extras().PadRight(32, ' ') + "R$ " + mon.formatToMoney(fat_det.get_vr_cobranca()).PadLeft(7, ' '); } if (Found) { output_st_msg += "@@"; } } /// USER [ authenticate ] END Registry("authenticate done fetch_dadosFaturamento "); return(true); }
public override bool execute( ) { if (base.execute() == false) { return(false); } Registry("execute fetch_rel_listaLojas "); /// USER [ execute ] T_Empresa emp = new T_Empresa(this); if (!emp.select_rows_empresa(input_emp)) { PublishError("Empresa " + input_emp + " não disponível"); return(false); } if (!emp.fetch()) { return(false); } output_nome_emp = emp.get_st_fantasia(); LINK_LojaEmpresa loj_emp = new LINK_LojaEmpresa(this); if (!loj_emp.select_fk_empresa_geral(emp.get_identity())) { PublishError("Nenhuma loja cadastrada"); return(false); } T_Loja loj = new T_Loja(this); T_Terminal term = new T_Terminal(this); StringBuilder sb = new StringBuilder(); while (loj_emp.fetch()) { if (!loj.selectIdentity(loj_emp.get_fk_loja())) { continue; } if (!term.select_fk_loja(loj.get_identity())) { continue; } DataPortable port = new DataPortable(); port.setValue("cod", loj.get_st_loja()); port.setValue("nome", loj.get_st_nome() + " - " + loj.get_st_social()); port.setValue("tel", loj.get_nu_telefone()); port.setValue("cid", loj.get_st_cidade()); port.setValue("est", loj.get_st_estado()); port.setValue("term", term.RowCount().ToString()); port.setValue("cnpj", loj.get_nu_CNPJ()); port.setValue("drep", loj_emp.get_nu_dias_repasse()); port.setValue("prep", loj_emp.get_tx_admin().PadLeft(4, '0').Insert(2, ",") + " %"); sb.Append(MemorySave(ref port)); sb.Append(","); } string list_ids = sb.ToString().TrimEnd(','); DataPortable dp = new DataPortable(); dp.setValue("ids", list_ids); // ## obtem indice geral output_id = MemorySave(ref dp); /// USER [ execute ] END Registry("execute done fetch_rel_listaLojas "); return(true); }
public override bool execute( ) { if (base.execute() == false) { return(false); } Registry("execute fetch_consultaLoja "); /// USER [ execute ] T_Terminal term = new T_Terminal(this); // ## Obtem filtros da entrada string nome = input_cont_dcl.get_st_nome().ToUpper(), cidade = input_cont_dcl.get_st_cidade(), estado = input_cont_dcl.get_st_estado(), codigo = input_cont_dcl.get_st_loja(); long min_qtd = 0; if (input_cont_dcl.get_nu_qtd_term().Length > 0) { min_qtd = Convert.ToInt32(input_cont_dcl.get_nu_qtd_term()); } long memory = Convert.ToInt64(new InstallData().maxPacket) / 360; Hashtable hshLojas = new Hashtable(); #region - lojas para um determinado administrador - if (user.get_tg_nivel() == TipoUsuario.Administrador) { if (!emp.select_rows_empresa(user.get_st_empresa())) { PublishError("CNPJ de empresa inválido"); return(false); } if (!emp.fetch()) { return(false); } LINK_LojaEmpresa lnk = new LINK_LojaEmpresa(this); if (lnk.select_fk_empresa_geral(emp.get_identity())) { while (lnk.fetch()) { hshLojas [lnk.get_fk_loja()] = "*"; } } } #endregion bool bNome = false; if (nome.Length > 0) { bNome = true; } bool bCod = false; if (codigo.Length > 0) { bCod = true; } ArrayList lstSortLojas = new ArrayList(); Hashtable hshSortLojas = new Hashtable(); LINK_LojaEmpresa loj_emp_conv = new LINK_LojaEmpresa(this); T_Empresa emp_comp = new T_Empresa(this); // ## Loop diferente para ambos os tipos de consulta // ## em um só bloco for (;;) { if (IsEmpresa) { // ## Busca do relacionamento loja e empresa if (!loj_emp.fetch()) { break; } // ## Se loja não existir, sair if (!loj.selectIdentity(loj_emp.get_fk_loja())) { return(false); } } else { // ## busca proximo registro do select all if (!loj.fetch()) { break; } if (hshLojas.Count > 0) { // ## filtro lojas no caso de admin if (hshLojas [loj.get_identity()] == null) { continue; } } } // ## Verifica qtd de terminais term.select_fk_loja(loj.get_identity()); if (bCod) { if (loj.get_st_loja() != codigo) { continue; } } if (bNome) { if (!loj.get_st_nome().ToUpper().Contains(nome)) { if (!loj.get_st_social().ToUpper().Contains(nome)) { continue; } } } if (min_qtd > 0) { if (term.GetCount() < min_qtd) { continue; } } if (cidade.Length > 0) { if (!loj.get_st_cidade().Contains(cidade)) { continue; } } if (estado.Length > 0) { if (!loj.get_st_estado().Contains(estado)) { continue; } } // ## Copia dados para memória DadosLoja dl = new DadosLoja(); string id_loja = loj.get_st_nome().Trim() + " - " + loj.get_st_social().Trim(); lstSortLojas.Add(id_loja); dl.set_st_loja(loj.get_st_loja()); dl.set_st_nome(id_loja); dl.set_st_cidade(loj.get_st_cidade()); dl.set_st_estado(loj.get_st_estado()); dl.set_st_endereco("Tel: " + loj.get_nu_telefone() + " End: " + loj.get_st_endereco()); dl.set_nu_diasRep(loj_emp.get_nu_dias_repasse()); string tx = loj_emp.get_tx_admin().PadLeft(3, '0'); dl.set_nu_pctRep(tx.Insert(tx.Length - 2, ",") + "%"); string st_terms = " ("; int terms = 0; while (term.fetch()) { if (term.get_fk_loja() == Context.NOT_SET) { continue; } terms++; st_terms += term.get_nu_terminal().TrimStart('0') + ", "; } st_terms = terms.ToString() + st_terms.Trim().TrimEnd(',') + ")"; dl.set_st_obs(st_terms); dl.set_nu_CNPJ(loj.get_nu_CNPJ()); string convs = ""; if (loj_emp_conv.select_fk_loja(loj.get_identity())) { while (loj_emp_conv.fetch()) { emp_comp.selectIdentity(loj_emp_conv.get_fk_empresa()); convs += emp_comp.get_st_empresa().TrimStart('0') + ","; } } dl.set_st_convenios(convs.TrimEnd(',')); hshSortLojas [id_loja] = dl; } lstSortLojas.Sort(); StringBuilder sb = new StringBuilder(); for (int t = 0; t < lstSortLojas.Count; ++t) { DadosLoja dl = hshSortLojas [lstSortLojas [t]] as DadosLoja; DataPortable tmp = dl as DataPortable; // ## obtem indexador sb.Append(MemorySave(ref tmp)); sb.Append(","); } string list_ids = sb.ToString().TrimEnd(','); if (list_ids == "") { PublishNote("Nenhum resultado foi encontrado"); return(true); } DataPortable dp = new DataPortable(); dp.setValue("ids", list_ids); // ## Obtem indexador geral output_st_csv_id = MemorySave(ref dp); /// USER [ execute ] END Registry("execute done fetch_consultaLoja "); return(true); }