public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute fetch_listaConveniosLoja ");

            /// USER [ execute ]

            // ## Obtem empresas vinculadas à loja

            LINK_LojaEmpresa loj_emp = new LINK_LojaEmpresa(this);

            if (loj_emp.select_fk_loja(loj.get_identity()))
            {
                T_Empresa emp = new T_Empresa(this);

                while (loj_emp.fetch())
                {
                    // ## Busca empresa

                    if (!emp.selectIdentity(loj_emp.get_fk_empresa()))
                    {
                        return(false);
                    }

                    // ## Copiar dados

                    DadosEmpresa de = new DadosEmpresa();

                    de.set_st_empresa(emp.get_st_empresa());
                    de.set_st_fantasia(emp.get_st_fantasia());
                    de.set_tx_convenio(loj_emp.get_tx_admin());
                    de.set_nu_dias_convenio(loj_emp.get_nu_dias_repasse());
                    de.set_st_ag(loj_emp.get_st_ag());
                    de.set_st_banco(loj_emp.get_st_banco());
                    de.set_st_conta(loj_emp.get_st_conta());

                    output_array_generic_lst.Add(de);
                }
            }

            if (output_array_generic_lst.Count == 0)
            {
                PublishNote("Nenhum convênio disponível");
            }

            /// USER [ execute ] END

            Registry("execute done fetch_listaConveniosLoja ");

            return(true);
        }
Ejemplo n.º 2
0
        public override bool execute( )
        {
            Registry("execute fetch_listawebConveniosLoja ");

            /// USER [ execute ]

            T_Loja loj = new T_Loja(this);

            if (!loj.select_rows_loja(input_st_loja))
            {
                PublishError("Cnpj não disponível");
                return(false);
            }

            if (!loj.fetch())
            {
                return(false);
            }

            if (loj.get_st_senha() != input_st_senha)
            {
                PublishError("Senha inválida");
                return(false);
            }

            LINK_LojaEmpresa lnk = new LINK_LojaEmpresa(this);
            T_Empresa        emp = new T_Empresa(this);

            if (lnk.select_fk_loja(loj.get_identity()))
            {
                while (lnk.fetch())
                {
                    if (!emp.selectIdentity(lnk.get_fk_empresa()))
                    {
                        continue;
                    }

                    DadosEmpresa de = new DadosEmpresa();

                    de.set_st_empresa(emp.get_st_empresa());

                    output_array_generic_lst.Add(de);
                }
            }

            /// USER [ execute ] END

            Registry("execute done fetch_listawebConveniosLoja ");

            return(true);
        }
		public override bool execute ( ) 
		{
			if ( base.execute() == false) return false;
			
			Registry ( "execute fetch_lojistaEmpresas " ); 
		
			/// USER [ execute ]
			
			T_Loja loj = new T_Loja (this);
			
			if ( !loj.select_rows_loja ( input_st_loja ) )
			{
				PublishError ( "Loja não encontrada" );
				return false;
			}
			
			if ( !loj.fetch() )
				return false;
			
			T_Empresa emp = new T_Empresa (this);
			
			LINK_LojaEmpresa loj_emp = new LINK_LojaEmpresa (this);
			
			if ( loj_emp.select_fk_loja ( loj.get_identity() ) )
			{
				while ( loj_emp.fetch() )
				{
					if ( !emp.selectIdentity ( loj_emp.get_fk_empresa() ) )
						return false;
					
					DadosEmpresa de = new DadosEmpresa();
					
					de.set_st_empresa  ( emp.get_st_empresa()  );
					de.set_st_fantasia ( emp.get_st_fantasia() );
					
					output_array_generic_lst.Add ( de );
				}
			}
				
			/// USER [ execute ] END
		
			Registry ( "execute done fetch_lojistaEmpresas " ); 
		
			return true;
		}
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute exec_alteraLoja ");

            /// USER [ execute ]


            // ## Se container estiver preenchido, alterar dados
            // ## cadastrais da loja

            if (input_cont_dl.get_st_nome() != "")
            {
                loj.set_nu_CNPJ(input_cont_dl.get_nu_CNPJ());
                loj.set_st_nome(input_cont_dl.get_st_nome());
                loj.set_st_social(input_cont_dl.get_st_social());
                loj.set_st_endereco(input_cont_dl.get_st_endereco());
                loj.set_st_enderecoInst(input_cont_dl.get_st_enderecoInst());
                loj.set_nu_inscEst(input_cont_dl.get_nu_inscEst());

                loj.set_st_cidade(input_cont_dl.get_st_cidade());
                loj.set_st_estado(input_cont_dl.get_st_estado());
                loj.set_nu_CEP(input_cont_dl.get_nu_CEP());
                loj.set_nu_telefone(input_cont_dl.get_nu_telefone());
                loj.set_nu_fax(input_cont_dl.get_nu_fax());
                loj.set_st_contato(input_cont_dl.get_st_contato());
                loj.set_vr_mensalidade(input_cont_dl.get_vr_mensalidade());
                loj.set_nu_contaDeb(input_cont_dl.get_nu_contaDeb());
                loj.set_st_obs(input_cont_dl.get_st_obs());

                loj.set_vr_mensalidade(input_cont_dl.get_vr_mensalidade());
                loj.set_nu_pctValor(input_cont_dl.get_nu_pctValor());
                loj.set_vr_transacao(input_cont_dl.get_vr_transacao());
                loj.set_vr_minimo(input_cont_dl.get_vr_minimo());
                loj.set_nu_franquia(input_cont_dl.get_nu_franquia());
                loj.set_nu_periodoFat(input_cont_dl.get_nu_periodoFat());
                loj.set_nu_diavenc(input_cont_dl.get_nu_diavenc());
                loj.set_tg_tipoCobranca(input_cont_dl.get_tg_tipoCobranca());
                loj.set_nu_bancoFat(input_cont_dl.get_nu_bancoFat());
                loj.set_tg_isentoFat(input_cont_dl.get_tg_isento());
                loj.set_st_senha(input_cont_dl.get_st_senhaWeb());

                if (!loj.synchronize_T_Loja())
                {
                    return(false);
                }
            }

            // ## Alteração de convênios

            Hashtable hshEmps = new Hashtable();
            ArrayList lstEmps = new ArrayList();

            if (input_st_csv_empresas.Length > 0)
            {
                LINK_LojaEmpresa loj_emp = new LINK_LojaEmpresa(this);

                // ## buscar e limpar todos os registros de convênio

                T_Empresa emp = new T_Empresa(this);

                if (loj_emp.select_fk_loja(loj.get_identity()))
                {
                    while (loj_emp.fetch())
                    {
                        hshEmps [loj_emp.get_fk_empresa()] = "0";

                        lstEmps.Add(loj_emp.get_fk_empresa());

                        if (!loj_emp.delete())
                        {
                            return(false);
                        }
                    }
                }

                ApplicationUtil util_taxa    = new ApplicationUtil();
                ApplicationUtil util_repasse = new ApplicationUtil();
                ApplicationUtil util_banco   = new ApplicationUtil();
                ApplicationUtil util_ag      = new ApplicationUtil();
                ApplicationUtil util_conta   = new ApplicationUtil();

                // ## Indexa as taxas

                util_taxa.indexCSV(input_st_csv_taxas);
                util_repasse.indexCSV(input_st_csv_dias);

                util_banco.indexCSV(input_st_csv_banco);
                util_ag.indexCSV(input_st_csv_ag);
                util_conta.indexCSV(input_st_csv_conta);

                // ## Percorre todas as empresas vinculadas

                for (int t = 0; t < var_util.indexCSV(input_st_csv_empresas); ++t)
                {
                    string empresa = var_util.getCSV(t);

                    if (!emp.select_rows_empresa(empresa))
                    {
                        return(false);
                    }

                    if (!emp.fetch())
                    {
                        return(false);
                    }

                    // ## Cria o relacionamento

                    loj_emp.set_fk_empresa(emp.get_identity());
                    loj_emp.set_fk_loja(loj.get_identity());

                    loj_emp.set_tx_admin(util_taxa.getCSV(t));
                    loj_emp.set_nu_dias_repasse(util_repasse.getCSV(t));
                    loj_emp.set_st_banco(util_banco.getCSV(t));
                    loj_emp.set_st_ag(util_ag.getCSV(t));
                    loj_emp.set_st_conta(util_conta.getCSV(t));

                    if (!loj_emp.create_LINK_LojaEmpresa())
                    {
                        return(false);
                    }

                    if (hshEmps [emp.get_identity()] != null)
                    {
                        hshEmps [emp.get_identity()] = "1";
                    }
                }

                for (int t = 0; t < lstEmps.Count; ++t)
                {
                    string tag = lstEmps[t].ToString();

                    if (hshEmps [tag] != null)
                    {
                        if (hshEmps [tag].ToString() == "0")
                        {
                            // foi removido

                            emp.selectIdentity(tag);

                            LOG_Audit aud = new LOG_Audit(this);

                            aud.set_tg_operacao(TipoOperacao.RemoveConvenio);
                            aud.set_fk_usuario(input_cont_header.get_st_user_id());
                            aud.set_dt_operacao(GetDataBaseTime());
                            aud.set_st_observacao(emp.get_st_fantasia());
                            aud.set_fk_generic(loj.get_identity());

                            if (!aud.create_LOG_Audit())
                            {
                                return(false);
                            }
                        }
                    }
                }

                PublishNote("Convênios atualizados para loja " + input_cont_dl.get_nu_CNPJ());
            }
            else
            {
                PublishNote("Cadastro atualizado para loja " + input_cont_dl.get_nu_CNPJ());
            }

            /// USER [ execute ] END

            Registry("execute done exec_alteraLoja ");

            return(true);
        }
Ejemplo n.º 6
0
        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);
        }