Exemple #1
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute fetch_termLoja ");

            /// USER [ execute ]

            T_Terminal term = new T_Terminal(this);

            if (!term.select_fk_loja(loj.get_identity()))
            {
                PublishError("Nenhum terminal cadastrado para a loja");
                return(false);
            }

            while (term.fetch())
            {
                DadosTerminal dt = new DadosTerminal();

                dt.set_st_terminal(term.get_nu_terminal());
                dt.set_st_localizacao(term.get_st_localizacao());

                output_array_generic_lst.Add(dt);
            }

            /// USER [ execute ] END

            Registry("execute done fetch_termLoja ");

            return(true);
        }
Exemple #2
0
        public override bool authenticate( )
        {
            if (base.authenticate() == false)
            {
                return(false);
            }

            Registry("authenticate exec_alteraTerminal ");

            /// USER [ authenticate ]

            term = new T_Terminal(this);

            term.ExclusiveAccess();

            // ## Busca terminal pelo nome informado

            if (!term.select_rows_terminal(input_st_terminal))
            {
                PublishError("Terminal " + input_st_terminal + " não encontrado");
                return(false);
            }

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

            /// USER [ authenticate ] END

            Registry("authenticate done exec_alteraTerminal ");

            return(true);
        }
Exemple #3
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute fetch_terminalLoja ");

            /// USER [ execute ]

            while (term.fetch())
            {
                if (term.get_fk_loja() == Context.NOT_SET)
                {
                    continue;
                }

                DadosTerminal dt = new DadosTerminal();

                dt.set_st_terminal(term.get_nu_terminal());
                dt.set_st_localizacao(term.get_st_localizacao());

                output_array_generic_lst.Add(dt);
            }

            /// USER [ execute ] END

            Registry("execute done fetch_terminalLoja ");

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

            Registry("authenticate ins_payFoneLojista ");

            /// USER [ authenticate ]

            input_st_pf_term = input_st_pf_term.PadLeft(8, '0');

            term = new T_Terminal(this);

            if (!term.select_rows_terminal(input_st_pf_term))
            {
                PublishError("Terminal inválido");
                return(false);
            }

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

            /// USER [ authenticate ] END

            Registry("authenticate done ins_payFoneLojista ");

            return(true);
        }
Exemple #5
0
        public override bool authenticate( )
        {
            if (base.authenticate() == false)
            {
                return(false);
            }

            Registry("authenticate ins_terminal ");

            /// USER [ authenticate ]

            term = new T_Terminal(this);

            my_term = Convert.ToInt32(input_st_loja_cnpj);

            while (term.select_rows_terminal(my_term.ToString().PadLeft(8, '0')))
            {
                term.fetch();

                if (term.get_fk_loja() == "0")
                {
                    break;
                }
                else
                {
                    my_term++;
                }
            }

            loj = new T_Loja(this);

            if (!loj.select_rows_loja(input_st_loja_cnpj))
            {
                PublishError("Código de loja não encontrado");
                return(false);
            }

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

            /// USER [ authenticate ] END

            Registry("authenticate done ins_terminal ");

            return(true);
        }
Exemple #6
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute del_Terminal ");

            /// USER [ execute ]

            input_st_terminal = input_st_terminal.PadLeft(8, '0');

            T_Terminal term_upd = new T_Terminal(this);

            while (term.fetch())
            {
                if (term.get_nu_terminal() == input_st_terminal)
                {
                    term_upd.ExclusiveAccess();

                    term_upd.selectIdentity(term.get_identity());

                    term_upd.set_fk_loja(Context.NONE);

                    if (!term_upd.synchronize_T_Terminal())
                    {
                        return(false);
                    }

                    term_upd.ReleaseExclusive();

                    PublishNote("Terminal " + input_st_terminal + " removido com sucesso");
                    return(true);
                }
            }

            /// USER [ execute ] END

            Registry("execute done del_Terminal ");

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

            Registry("execute fetch_nomeLojaTerminal ");

            /// USER [ execute ]

            // ## Obtem terminal

            T_Terminal term = new T_Terminal(this);

            if (!term.select_rows_terminal(input_st_terminal))
            {
                PublishError("Terminal inválido");
                return(false);
            }

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

            // ## Obtem loja

            T_Loja loj = new T_Loja(this);

            if (!loj.selectIdentity(term.get_fk_loja( )))
            {
                return(false);
            }

            output_st_nome_loja = loj.get_st_nome();

            /// USER [ execute ] END

            Registry("execute done fetch_nomeLojaTerminal ");

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

            Registry("authenticate fetch_consultaTransacao ");

            /// USER [ authenticate ]

            l_tr = new LOG_Transacoes(this);

            // ## obtem filtros rápidos

            string cod_empresa = input_cont_dct.get_st_cod_empresa().PadLeft(6, '0');
            string cnpj_loja   = input_cont_dct.get_st_cnpj_loja();
            string cod_loja    = input_cont_dct.get_st_cod_loja();
            string st_terminal = input_cont_dct.get_st_terminal().PadLeft(8, '0').TrimEnd('0');
            string dt_ini      = input_cont_dct.get_dt_ini();
            string dt_fim      = input_cont_dct.get_dt_fim();
            string st_cart     = input_cont_dct.get_st_cartao();
            string st_telefone = input_cont_dct.get_st_telefone();

            #region - resolve todos os links -

            // ## Confere telefone

            if (st_telefone.Length == 10)
            {
                T_PayFone pf = new T_PayFone(this);

                if (!pf.select_rows_telefone(st_telefone))
                {
                    PublishError("Telefone inválido");
                    return(true);
                }
                else
                {
                    if (!pf.fetch())
                    {
                        return(false);
                    }

                    st_cart_id = pf.get_fk_cartao();
                }
            }

            // ##  Confere cartão

            else if (st_cart.Length > 0)
            {
                T_Cartao cart = new T_Cartao(this);

                if (!cart.select_rows_tudo(cod_empresa,                                         // empresa
                                           st_cart.PadLeft(6, '0'),                             // matricula
                                           "01"))                                               // titularidade
                {
                    PublishError("Cartão inválido");
                    return(true);
                }
                else
                {
                    if (!cart.fetch())
                    {
                        return(false);
                    }

                    st_cart_id = cart.get_identity();
                }
            }

            // ## Confere pelo código de empresa

            if (cod_empresa.Length > 0)
            {
                T_Empresa emp = new T_Empresa(this);

                if (cod_empresa == "000000" &&
                    (input_cont_header.get_tg_user_type() == TipoUsuario.SuperUser ||
                     input_cont_header.get_tg_user_type() == TipoUsuario.OperadorConvey))
                {
                    cod_empresa = "";
                }
                else
                {
                    if (!emp.select_rows_empresa(cod_empresa))
                    {
                        PublishError("Código de Empresa inexistente");
                        return(false);
                    }

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

                    fk_empresa = emp.get_identity();
                }
            }

            // ## Confere por cód de loja

            if (cnpj_loja.Length > 0)
            {
                T_Loja loj = new T_Loja(this);

                if (!loj.select_rows_cnpj(cnpj_loja))
                {
                    PublishError("CNPJ de Loja inexistente");
                    return(false);
                }

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

                fk_loja = loj.get_identity();
            }
            else if (cod_loja.Length > 0)
            {
                T_Loja loj = new T_Loja(this);

                if (!loj.select_rows_loja(cod_loja))
                {
                    PublishError("Código de Loja inexistente");
                    return(false);
                }

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

                fk_loja = loj.get_identity();
            }

            // ## Busca Relação da loja com Empresa (Convênio)

            if ((cnpj_loja.Length > 0 || cod_loja.Length > 0) &&
                cod_empresa.Length > 0)
            {
                LINK_LojaEmpresa loj_emp = new LINK_LojaEmpresa(this);

                if (!loj_emp.select_fk_empresa_loja(fk_empresa, fk_loja))
                {
                    PublishError("Loja não conveniada com a empresa");
                    return(false);
                }
            }

            // ## Confere terminal

            if (st_terminal.Length > 0)
            {
                T_Terminal term = new T_Terminal(this);

                if (!term.select_rows_terminal(st_terminal))
                {
                    PublishError("Terminal inexistente");
                    return(false);
                }

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

                fk_terminal = term.get_identity();

                // ## Confere convenio com loja (se preenchida)

                if (fk_empresa.Length > 0)
                {
                    if (term.get_fk_loja() != fk_empresa)
                    {
                        PublishError("Terminal não residente à loja");
                        return(false);
                    }
                }
            }

            #endregion

            // ## Obtem mais filtros

            st_nsu   = input_cont_dct.get_st_nsu();
            nu_parc  = input_cont_dct.get_nu_parcelas();
            en_oper  = input_cont_dct.get_en_oper();
            vr_valor = input_cont_dct.get_vr_valor();

            if (input_cont_dct.get_tg_status() != "-1")
            {
                en_conf = input_cont_dct.get_tg_status();
            }

            // ## Escolha da query mais vantajosa pela ordem de filtros
            // ## informados

            if (fk_terminal.Length > 0 &&
                fk_empresa.Length > 0 &&
                dt_ini.Length > 0 &&
                dt_fim.Length > 0)
            {
                // ## Obtem registros com período

                if (!l_tr.select_rows_term_emp_dt(fk_terminal,
                                                  fk_empresa,
                                                  dt_ini,
                                                  dt_fim))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (fk_terminal.Length > 0 &&
                     fk_empresa.Length > 0 &&
                     dt_ini.Length > 0)
            {
                // ## Obtem registros com período inicial

                if (!l_tr.select_rows_term_emp_dt_ini(fk_terminal,
                                                      fk_empresa,
                                                      dt_ini))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (fk_terminal.Length > 0 &&
                     fk_empresa.Length > 0)
            {
                // ## Obtem registros com terminal e empresa

                if (!l_tr.select_fk_term_empresa(fk_terminal, fk_empresa))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (dt_ini.Length > 0 && dt_fim.Length > 0)
            {
                // ## Obtem registro por período de inicio e fim

                if (!l_tr.select_rows_dt(dt_ini, dt_fim))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (dt_ini.Length > 0)
            {
                // ## Obtem registro por período de inicio

                if (!l_tr.select_rows_dt_ini(dt_ini))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (fk_empresa.Length > 0)
            {
                // ## Obtem registros com empresa

                if (!l_tr.select_fk_empresa(fk_empresa))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (fk_terminal.Length > 0)
            {
                // ## Obtem registros com terminal

                if (!l_tr.select_fk_terminal(fk_terminal))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (nu_parc.Length > 0 &&
                     en_oper.Length > 0 &&
                     vr_valor.Length > 0 &&
                     dt_ini.Length > 0 &&
                     dt_fim.Length > 0)
            {
                // ## Obtem registro por parcelas, operacao, valor
                // ## e por período de inicio e fim

                if (!l_tr.select_rows_par_oper_valor_dt(nu_parc,
                                                        en_oper,
                                                        vr_valor,
                                                        dt_ini,
                                                        dt_fim))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (nu_parc.Length > 0 &&
                     en_oper.Length > 0 &&
                     vr_valor.Length > 0 &&
                     dt_ini.Length > 0)
            {
                // ## Obtem registro por parcelas, operacao, valor
                // ## e por período de inicio

                if (!l_tr.select_rows_par_oper_valor_dt_ini(nu_parc,
                                                            en_oper,
                                                            vr_valor,
                                                            dt_ini))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (nu_parc.Length > 0 &&
                     en_oper.Length > 0 &&
                     vr_valor.Length > 0)
            {
                // ## Obtem registro por parcelas, operacao, valor

                if (!l_tr.select_rows_par_oper_valor(nu_parc, en_oper, vr_valor))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (nu_parc.Length > 0 &&
                     en_oper.Length > 0)
            {
                // ## Obtem registro por parcelas, operacao

                if (!l_tr.select_rows_parc_oper(nu_parc, en_oper))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (nu_parc.Length > 0)
            {
                // ## Obtem registro por parcelas

                if (!l_tr.select_rows_parc(nu_parc))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (st_cart_id.Length > 0)
            {
                // ## Obtem registro por somente determinado cartão

                if (!l_tr.select_fk_cartao(st_cart_id))
                {
                    PublishError("NSU inválido");
                    return(false);
                }
            }
            else
            {
                // ## Obtem TODOS os registros

                if (!l_tr.selectAll())
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }

            /// USER [ authenticate ] END

            Registry("authenticate done fetch_consultaTransacao ");

            return(true);
        }
        public override bool execute( )
        {
            Registry("execute exec_pos_buscaCartao ");

            /// USER [ execute ]

            T_Cartao   cart = new T_Cartao(this);
            T_Empresa  emp  = new T_Empresa(this);
            T_Terminal term = new T_Terminal(this);

            if (!term.select_rows_terminal(input_st_terminal))
            {
                return(false);
            }

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

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

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

            if (emp.get_tg_blocked() == Context.TRUE)
            {
                return(false);
            }

            if (!cart.select_rows_empresa_matricula(input_st_empresa, input_st_matricula))
            {
                return(false);
            }

            while (cart.fetch())
            {
                DadosCartao dc = new DadosCartao();

                dc.set_st_titularidade(cart.get_st_titularidade());

                if (cart.get_st_titularidade() != "01")
                {
                    // dependente

                    T_Dependente dep = new T_Dependente(this);

                    if (dep.select_rows_prop_tit(cart.get_fk_dadosProprietario(),
                                                 cart.get_st_titularidade()))
                    {
                        if (dep.fetch())
                        {
                            string nome = dep.get_st_nome().Trim();

                            if (nome.Length > 20)
                            {
                                nome = nome.Substring(0, 20);
                            }

                            dc.set_st_proprietario(nome);
                        }
                    }
                }
                else
                {
                    // proprietario

                    T_Proprietario prop = new T_Proprietario(this);

                    if (prop.selectIdentity(cart.get_fk_dadosProprietario()))
                    {
                        string nome = prop.get_st_nome().Trim();

                        if (nome.Length > 20)
                        {
                            nome = nome.Substring(0, 20);
                        }

                        dc.set_st_proprietario(nome);
                    }
                }

                output_array_generic_lst.Add(dc);
            }

            /// USER [ execute ] END

            Registry("execute done exec_pos_buscaCartao ");

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

            Registry("execute exec_vincula_lojista ");

            /// USER [ execute ]

            T_Loja loj = new T_Loja(this);

            if (!loj.select_rows_loja(input_st_cod_loja))
            {
                PublishError("loja inexistente");
                return(false);
            }

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

            T_Usuario lojista = new T_Usuario(this);

            if (!lojista.selectIdentity(input_id_usuario))
            {
                PublishError("Usuário inexistente");
                return(false);
            }

            if (lojista.get_tg_nivel() != TipoUsuario.Lojista)
            {
                PublishError("Usuário incorreto");
                return(false);
            }

            T_Terminal term = new T_Terminal(this);

            if (!term.select_fk_loja(loj.get_identity()))
            {
                PublishError("Loja não possui terminais");
                return(false);
            }

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

            LINK_UsuarioTerminal lut = new LINK_UsuarioTerminal(this);

            if (lut.select_fk_user(lojista.get_identity()))
            {
                PublishError("Usuário já possui terminal");
                return(false);
            }

            lut.set_fk_term(term.get_identity());
            lut.set_fk_user(lojista.get_identity());

            if (!lut.create_LINK_UsuarioTerminal())
            {
                return(false);
            }

            PublishNote("Lojista vinculado ao seu terminal com sucesso");

            /// USER [ execute ] END

            Registry("execute done exec_vincula_lojista ");

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

            Registry("execute fetch_pf_telefoneLojista ");

            /// USER [ execute ]

            // ## Obtem loja por código

            T_Loja loj = new T_Loja(this);

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

                // ## Obtem terminais vinculados

                T_Terminal term = new T_Terminal(this);

                if (term.select_fk_loja(loj.get_identity()))
                {
                    T_PayFone pf = new T_PayFone(this);

                    // ## Para todos os terminais

                    while (term.fetch())
                    {
                        // ## busca payfone

                        if (pf.select_fk_term(term.get_identity()))
                        {
                            // ## para todos os registros

                            while (pf.fetch())
                            {
                                // ## somente lojista

                                if (pf.get_tg_tipoCelular() == TipoCelular.LOJA)
                                {
                                    // ## Achou telefone

                                    output_st_telefone = pf.get_st_telefone();
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }

            ///
            /// USER [ execute ] END

            Registry("execute done fetch_pf_telefoneLojista ");

            return(true);
        }
        public override bool authenticate( )
        {
            Registry("authenticate exec_pos_vendaEmpresarialSITEF ");

            /// USER [ authenticate ]

            cart  = new T_Cartao(this);
            emp   = new T_Empresa(this);
            l_nsu = new LOG_NSU(this);
            info  = new T_InfoAdicionais(this);
            prot  = new T_Proprietario(this);
            loj   = new T_Loja(this);

            // Default é erro genérico
            var_codResp = "9999";

            // Normal
            var_nu_nsuAtual    = Context.NONE;
            var_nu_nsuEntidade = Context.NONE;

            // Cancelamento
            var_nu_nsuOrig    = Context.NONE;
            var_nu_nsuEntOrig = Context.NONE;

            // Valores básicos de comércio
            var_vr_total    = input_cont_pe.get_vr_valor();
            var_nu_parcelas = input_cont_pe.get_nu_parcelas();

            var_codResp = "0606";

            // alterado

            #region - valida loja AO INVES DE TERMINAL (antigo) -

            // ## Busca terminal pelo seu código

            // pega os 7 ultimos
            if (!loj.select_rows_loja(input_cont_pe.get_st_terminal().Substring(1).TrimStart('0')))
            {
                output_st_msg = "Loja inexistente";
                var_codResp   = "0303";
                return(false);
            }

            if (!loj.fetch())
            {
                output_st_msg = "Erro aplicativo";
                return(false);
            }

            // alterado!
            // busca o primeiro terminal vinculado

            if (!term.select_fk_loja(loj.get_identity()))
            {
                output_st_msg = "Erro do terminal";
                return(false);
            }

            term.fetch();

            #endregion

            // continua igual

            #region - valida empresa -

            // ## Busca empresa informada

            if (!emp.select_rows_empresa(input_cont_pe.get_st_empresa()))
            {
                output_st_msg = "Empresa inexistente";
                var_codResp   = "0303";
                return(false);
            }

            if (!emp.fetch())
            {
                output_st_msg = "Erro de aplicativo";
                return(false);
            }

            // ## Caso empresa bloqueada, sair

            if (emp.get_tg_bloq() == Context.TRUE)
            {
                output_st_msg = "Empresa bloqueada";
                var_codResp   = "0303";
                return(false);
            }

            #endregion

            // alterado!

            #region - valida relação da Loja do Terminal com Empresa (Convênio)

            LINK_LojaEmpresa loj_emp = new LINK_LojaEmpresa(this);

            if (!loj_emp.select_fk_empresa_loja(emp.get_identity(), loj.get_identity()))
            {
                output_st_msg = "Loja não conveniada";
                var_codResp   = "0303";
                return(false);
            }

            if (loj.get_tg_blocked() == Context.TRUE)
            {
                output_st_msg = "Loja bloqueada";
                var_codResp   = "0303";
                return(false);
            }

            if (loj.get_tg_cancel() == Context.TRUE)
            {
                output_st_msg = "Loja cancelada";
                var_codResp   = "0303";
                return(false);
            }

            #endregion

            // continua igual

            #region - valida cartão -

            if (!cart.select_rows_tudo(input_cont_pe.get_st_empresa(),
                                       input_cont_pe.get_st_matricula(),
                                       input_cont_pe.get_st_titularidade()))
            {
                output_st_msg = "Cartão inexistente";
                var_codResp   = "0606";
                return(false);
            }

            if (!cart.fetch())
            {
                output_st_msg = "Erro aplicativo";
                return(false);
            }

            // ## Verifica bloqueio

            if (cart.get_tg_status() == CartaoStatus.Bloqueado)
            {
                output_st_msg = "Cartão inválido";
                var_codResp   = "0505";
                return(false);
            }

            if (cart.get_tg_emitido() != StatusExpedicao.Expedido)
            {
                output_st_msg = "Cartão inválido";
                var_codResp   = "0505";
                return(false);
            }

            if (cart.get_tg_tipoCartao() == TipoCartao.educacional)
            {
                // ## No caso educacional, permitir somente venda
                // ## em uma parcela

                if (input_cont_pe.get_nu_parcelas().TrimStart('0') != "1")
                {
                    output_st_msg = "Somente uma parcela";
                    var_codResp   = "0606";
                    return(false);
                }
            }

            // ## Conferir vencto do cartão

            /*
             * if ( cart.get_tg_tipoCartao() == TipoCartao.empresarial )
             * {
             *      int year  = 2000 + Convert.ToInt32 ( cart.get_st_venctoCartao().Substring ( 2,2 ) );
             *      int month = Convert.ToInt32 ( cart.get_st_venctoCartao().Substring ( 0,2 ) );
             *      int day   = 1;
             *
             * DateTime tim_venc = new DateTime ( year, month, day );
             *
             * if ( tim_venc < DateTime.Now )
             *      {
             * output_st_msg     = "Cartão vencido";
             * var_codResp       = "7676";
             * return false;
             *      }
             * }
             */

            #endregion

            var_vr_total    = input_cont_pe.get_vr_valor();
            var_nu_parcelas = input_cont_pe.get_nu_parcelas();

            SQL_LOGGING_ENABLE = false;

            // continua igual

            #region - Verifica disponivel mensal nas parcelas -

            T_Parcelas parc = new T_Parcelas(this);

            string myId = cart.get_identity();

            if (cart.get_st_titularidade() != "01")
            {
                cart.select_rows_tudo(cart.get_st_empresa(),
                                      cart.get_st_matricula(),
                                      "01");
                cart.fetch();
            }

            vr_dispMes = cart.get_int_vr_limiteMensal() + cart.get_int_vr_extraCota();
            vr_dispTot = cart.get_int_vr_limiteTotal() + cart.get_int_vr_extraCota();

            vr_valor = Convert.ToInt64(input_cont_pe.get_vr_valor());

            if (cart.get_tg_tipoCartao() != TipoCartao.presente)
            {
                new ApplicationUtil().GetSaldoDisponivel(ref cart, ref vr_dispMes, ref vr_dispTot);

                int tmp_nu_parc = Convert.ToInt32(input_cont_pe.get_nu_parcelas());

                if (tmp_nu_parc > 1)
                {
                    if (vr_valor > vr_dispTot)
                    {
                        output_st_msg = "limite excedido";
                        var_codResp   = "2727";

                        SQL_LOGGING_ENABLE = true;

                        return(false);
                    }

                    LOG_Transacoes ltr     = new LOG_Transacoes(this);
                    T_Parcelas     parcTot = new T_Parcelas(this);

                    string tmp = input_cont_pe.get_st_valores();

                    ArrayList lstCartoes = new ArrayList();

                    T_Cartao c_t = new T_Cartao(this);

                    c_t.select_rows_empresa_matricula(cart.get_st_empresa(),
                                                      cart.get_st_matricula());

                    while (c_t.fetch())
                    {
                        lstCartoes.Add(c_t.get_identity());
                    }

                    for (int t = 1, index_pos = 0; t <= tmp_nu_parc; ++t)
                    {
                        long valor_unit_parc = Convert.ToInt64(tmp.Substring(index_pos, 12));

                        index_pos += 12;

                        if (valor_unit_parc > cart.get_int_vr_limiteMensal())
                        {
                            output_st_msg = "limite excedido";
                            var_codResp   = "2727";

                            SQL_LOGGING_ENABLE = true;

                            return(false);
                        }

                        long dispMesParc = cart.get_int_vr_limiteMensal();

                        // Verifica disponivel mensal nas parcelas
                        if (parcTot.select_rows_cartao_mensal(ref lstCartoes, t.ToString()))                              // este mês
                        {
                            while (parcTot.fetch())
                            {
                                if (ltr.selectIdentity(parcTot.get_fk_log_transacoes()))                                      // busca transação
                                {
                                    if (ltr.get_tg_confirmada() == TipoConfirmacao.Confirmada ||
                                        ltr.get_tg_confirmada() == TipoConfirmacao.Pendente)
                                    {
                                        dispMesParc -= parcTot.get_int_vr_valor();
                                    }
                                }
                            }
                        }

                        if (valor_unit_parc > dispMesParc)
                        {
                            output_st_msg = "limite excedido";
                            var_codResp   = "2727";

                            SQL_LOGGING_ENABLE = true;

                            return(false);
                        }
                    }
                }
                else
                {
                    if (vr_valor > vr_dispMes || vr_valor > vr_dispTot)
                    {
                        output_st_msg = "limite excedido";
                        var_codResp   = "2727";

                        SQL_LOGGING_ENABLE = true;

                        return(false);
                    }
                }
            }
            else
            {
                if (vr_valor > cart.get_int_vr_limiteTotal())
                {
                    output_st_msg = "limite excedido";
                    var_codResp   = "2727";

                    SQL_LOGGING_ENABLE = true;

                    return(false);
                }
            }

            if (myId != cart.get_identity())
            {
                // restaurar cartão dep
                cart.selectIdentity(myId);
            }

            #endregion

            SQL_LOGGING_ENABLE = true;

            /// USER [ authenticate ] END

            Registry("authenticate done exec_pos_vendaEmpresarialSITEF ");

            return(true);
        }
        public override bool authenticate( )
        {
            Registry("authenticate exec_pos_desfazVendaEmpresarial ");

            /// USER [ authenticate ]

            // ## Buscar terminal

            term = new T_Terminal(this);

            var_codResp = "0606";

            if (!term.select_rows_terminal(input_cont_pe.get_st_terminal()))
            {
                output_st_msg = "Erro aplicativo";
                return(false);
            }

            if (!term.fetch())
            {
                output_st_msg = "Erro aplicativo";
                return(false);
            }

            // ## Buscar transação pelo terminal e pelo valor

            l_tr = new LOG_Transacoes(this);

            if (!l_tr.select_rows_term_vr(term.get_identity(),
                                          input_cont_pe.get_vr_valor()))
            {
                output_st_msg = "Erro aplicativo";
                return(false);
            }

            l_tr.SetReversedFetch();

            if (!l_tr.fetch())
            {
                output_st_msg = "Erro aplicativo";
                return(false);
            }

            // ## Conferir se status já desfeito

            if (l_tr.get_tg_confirmada() == TipoConfirmacao.Desfeita)
            {
                var_codResp   = "N3N3";
                output_st_msg = "Trans. já desfeita";
                return(false);
            }

            // ## Conferir se status dif de pendente

            if (l_tr.get_tg_confirmada() != TipoConfirmacao.Pendente)
            {
                output_st_msg = "Erro aplicativo";
                return(false);
            }

            var_codResp = "0000";

            /// USER [ authenticate ] END

            Registry("authenticate done exec_pos_desfazVendaEmpresarial ");

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

            Registry("execute fetch_consultaLojasGift ");

            /// USER [ execute ]

            input_st_empresa = input_st_empresa.PadLeft(6, '0');

            T_Empresa emp = new T_Empresa(this);

            if (!emp.select_rows_empresa(input_st_empresa))
            {
                PublishError("Empresa não disponível");
                return(false);
            }

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

            LINK_LojaEmpresa lje  = new LINK_LojaEmpresa(this);
            T_Loja           loj  = new T_Loja(this);
            T_Terminal       term = new T_Terminal(this);

            StringBuilder sb = new StringBuilder();

            ArrayList lstSort = new ArrayList();

            if (lje.select_fk_empresa_geral(emp.get_identity()))
            {
                SQL_LOGGING_ENABLE = false;

                while (lje.fetch())
                {
                    if (loj.selectIdentity(lje.get_fk_loja()))
                    {
                        lstSort.Add(loj.get_st_nome());
                    }
                }

                lstSort.Sort();

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

                    if (loj.select_rows_nome(nome_loja))
                    {
                        if (loj.fetch())
                        {
                            if (!term.select_fk_loja(loj.get_identity()))
                            {
                                return(false);
                            }

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

                            DadosLoja dl = new DadosLoja();

                            dl.set_st_nome(loj.get_st_nome() + " - " + loj.get_st_social());
                            dl.set_st_obs(term.get_nu_terminal());

                            DataPortable tmp = dl as DataPortable;

                            // ## obtem indexador

                            sb.Append(MemorySave(ref tmp));
                            sb.Append(",");
                        }
                    }
                }

                SQL_LOGGING_ENABLE = true;
            }

            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_consultaLojasGift ");

            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);
        }
Exemple #16
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute fetch_financ_lojista ");

            /// USER [ execute ]

            T_Terminal term = new T_Terminal(this);

            if (!term.select_rows_terminal(input_cont_header.get_nu_terminal()))
            {
                return(false);
            }

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

            DateTime tim = new DateTime(Convert.ToInt32(input_dt.Substring(0, 4)),
                                        Convert.ToInt32(input_dt.Substring(5, 2)),
                                        Convert.ToInt32(input_dt.Substring(8, 2)));

            LOG_Transacoes ltr = new LOG_Transacoes(this);

            if (!ltr.select_rows_dt_loj(GetDataBaseTime(tim),
                                        GetDataBaseTime(tim.AddDays(1)),
                                        term.get_fk_loja()))
            {
                PublishError("Nenhum registro encontrado");
                return(false);
            }

            long vendas = 0;
            long canc   = 0;
            int  opers  = 0;

            while (ltr.fetch())
            {
                if (ltr.get_tg_confirmada() != TipoConfirmacao.Confirmada &&
                    ltr.get_tg_confirmada() != TipoConfirmacao.Cancelada)
                {
                    continue;
                }

                opers++;

                if (ltr.get_tg_confirmada() == TipoConfirmacao.Confirmada)
                {
                    vendas += ltr.get_int_vr_total();
                }
                else
                {
                    canc += ltr.get_int_vr_total();
                }
            }

            output_canc   = Convert.ToString(canc);
            output_oper   = Convert.ToString(opers);
            output_vendas = Convert.ToString(vendas);

            /// USER [ execute ] END

            Registry("execute done fetch_financ_lojista ");

            return(true);
        }
Exemple #17
0
        public override bool execute( )
        {
            Registry("execute exec_login ");

            /// USER [ execute ]

            output_tg_trocaSenha = Context.FALSE;

            user = new T_Usuario(this);

            user.ExclusiveAccess();

            // ## Busca usuário com nome e cód de empresa

            if (loginLojista)
            {
                string st_loja = input_st_empresa.Replace("L", "");

                T_Loja loj = new T_Loja(this);

                if (!loj.select_rows_loja(st_loja))
                {
                    PublishError("Usuário ou senha incorretos");
                    return(false);
                }

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

                T_Terminal term = new T_Terminal(this);

                if (!term.select_fk_loja(loj.get_identity()))
                {
                    PublishError("Usuário ou senha incorretos");
                    return(false);
                }

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

                LINK_UsuarioTerminal lut = new LINK_UsuarioTerminal(this);

                if (!lut.select_fk_term(term.get_identity()))
                {
                    PublishError("Usuário ou senha incorretos");
                    return(false);
                }

                bool found = false;

                T_Usuario usr_lojista = new T_Usuario(this);

                while (lut.fetch())
                {
                    if (!usr_lojista.selectIdentity(lut.get_fk_user()))
                    {
                        return(false);
                    }

                    Trace(usr_lojista.get_st_nome());

                    if (usr_lojista.get_st_nome() == input_st_nome)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    PublishError("Usuário ou senha incorretos");
                    return(false);
                }

                if (!user.selectIdentity(usr_lojista.get_identity()))
                {
                    return(false);
                }

                input_st_empresa = st_loja;

                output_cont_header.set_nu_terminal(term.get_nu_terminal());
            }
            else
            {
                if (!user.select_rows_login(input_st_nome, input_st_empresa))
                {
                    PublishError("Usuário ou senha incorretos");
                    return(false);
                }

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

            // ## Confere bloqueio

            if (user.get_tg_bloqueio() != Context.FALSE)
            {
                PublishError("Usuário ou senha incorretos");
                return(false);
            }

            // ## Confere senha

            if (user.get_st_senha() != input_st_senha)
            {
                user.set_nu_senhaErrada(Convert.ToString(user.get_int_nu_senhaErrada() + 1));

                if (user.get_int_nu_senhaErrada() >= 3)
                {
                    // ## Na terceira senha errada, bloqueia cartão

                    //user.set_tg_bloqueio      ( Context.TRUE  );
                    //user.set_nu_senhaErrada   (  0            );
                }

                // ## Atualiza

                if (!user.synchronize_T_Usuario())
                {
                    return(false);
                }

                PublishError("Usuário ou senha incorretos");
                return(false);
            }
            else
            {
                // ## Zera senhas erradas

                ut_coverMark(1);

                user.set_nu_senhaErrada(0);
            }

            // ## Caso o ultimo logoff não foi executado, ou seja,
            // ## o usuário não fechou corretamente sua última instância

            if (user.get_tg_logoff() == Context.FALSE)
            {
                // ## Mais de cinco minutos se passaram...

                if (TimeSpanCtrl(user.get_dt_ultUso(),
                                 TSpan_Mode.MORE_THAN,
                                 5,
                                 TSpan_Range.Minutes) == true)
                {
                    PublishNote("Disconectando sessão ociosa por mais de cinco minutos");
                }
                else
                {
                    PublishError("Não são permitidas multiplas sessões");
                    return(false);
                }
            }

            // ## Seto que o logoff precisa ser feito

            user.set_tg_logoff(Context.FALSE);

            // ## Confere se senha expirou...

            if (TimeSpanCtrl(user.get_dt_trocaSenha(),
                             TSpan_Mode.MORE_THAN,
                             60,
                             TSpan_Range.Days) == true)
            {
                output_tg_trocaSenha = Context.TRUE;

                PublishNote("É necessário trocar sua senha");
            }

            // ## Confere se admin requisitou troca de senha

            if (user.get_tg_trocaSenha() == Context.TRUE)
            {
                output_tg_trocaSenha = Context.TRUE;

                PublishNote("É necessário trocar sua senha");
            }

            // ## Seto login feito agora

            user.set_dt_ultUso(GetDataBaseTime());

            // ## Atualizo usuário

            if (!user.synchronize_T_Usuario())
            {
                return(false);
            }

            output_cont_header.set_st_session(var_SessionKey);
            output_cont_header.set_st_empresa(input_st_empresa);
            output_cont_header.set_st_user_id(user.get_identity());
            output_cont_header.set_tg_user_type(user.get_tg_nivel());

            /// USER [ execute ] END

            Registry("execute done exec_login ");

            return(true);
        }
		public override bool execute ( ) 
		{
			if ( base.execute() == false) return false;
			
			Registry ( "execute fetch_canc_dia_lojista " ); 
		
			/// USER [ execute ]
			
			T_Terminal term  = new T_Terminal (this);
			
			if ( !term.select_rows_terminal ( input_cont_header.get_nu_terminal() ) )
				return false;
			
			if ( !term.fetch() )
				return false;
			
			DateTime tim = new DateTime ( DateTime.Now.Year, 
			                              DateTime.Now.Month,
			                              DateTime.Now.Day );
			
			LOG_Transacoes ltr = new LOG_Transacoes (this);
			
			if ( !ltr.select_rows_dt_loj ( 	GetDataBaseTime ( tim) , 
			                        		GetDataBaseTime ( tim.AddDays(1) ) ,
			                        		term.get_fk_loja() ) )
			{
				PublishError ( "Nenhum registro encontrado" );
				return false;
			}
			
			StringBuilder sb = new StringBuilder();
			
			T_Cartao cart = new T_Cartao (this);
			
			while ( ltr.fetch() )
			{
				if ( !cart.selectIdentity ( ltr.get_fk_cartao() ) )
					continue;
				
				if ( ltr.get_tg_confirmada() != TipoConfirmacao.Confirmada )
					continue;
				
				string st_cartao =  cart.get_st_empresa() + 
					 				cart.get_st_matricula() + 
									cart.get_st_titularidade();
				
				DadosConsultaTransacao dct = new DadosConsultaTransacao();
				
				dct.set_vr_valor ( ltr.get_vr_total() );
				dct.set_st_nsu   ( ltr.get_nu_nsu()   );
				dct.set_dt_transacao ( ltr.get_dt_transacao() );
				dct.set_st_cartao  ( st_cartao );
				
				DataPortable tmp = dct as DataPortable;
				
				// ## Obtem identificador para registro
					
				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 );
			
			output_st_content = MemorySave ( ref dp );			
			
			/// USER [ execute ] END
		
			Registry ( "execute done fetch_canc_dia_lojista " ); 
		
			return true;
		}