Esempio n. 1
0
        public override bool authenticate( )
        {
            Registry("authenticate exec_loginLojista ");

            /// USER [ authenticate ]

            T_Loja loj = new T_Loja(this);

            if (!loj.select_rows_loja(input_st_cnpj))
            {
                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);
            }

            output_nome = loj.get_st_nome() + " - " + loj.get_st_social();

            /// USER [ authenticate ] END

            Registry("authenticate done exec_loginLojista ");

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

            Registry("authenticate fetch_listaConveniosLoja ");

            /// USER [ authenticate ]

            // ## Obtem loja

            loj = new T_Loja(this);

            if (!loj.select_rows_loja(input_st_loja))
            {
                PublishError("Código de loja inválido");
                return(false);
            }

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

            output_st_cnpj = loj.get_nu_CNPJ();

            /// USER [ authenticate ] END

            Registry("authenticate done fetch_listaConveniosLoja ");

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

            Registry("authenticate fetch_termLoja ");

            /// USER [ authenticate ]

            loj = new T_Loja(this);

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

            if (!loj.select_rows_loja(input_st_cod_loja))
            {
                PublishError("Código de loja inválido");
                return(false);
            }

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

            /// USER [ authenticate ] END

            Registry("authenticate done fetch_termLoja ");

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

            Registry("authenticate ins_chamado ");

            /// USER [ authenticate ]

            loj = new T_Loja(this);

            if (!loj.select_rows_loja(input_cont_dc.get_st_cod_loja()))
            {
                PublishError("Loja inexistente");
                return(false);
            }

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

            /// USER [ authenticate ] END

            Registry("authenticate done ins_chamado ");

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

            Registry("authenticate exec_alteraLoja ");

            /// USER [ authenticate ]

            loj = new T_Loja(this);

            // ## Busca loja em questão por um CNPJ

            if (!loj.select_rows_cnpj(input_cont_dl.get_nu_CNPJ()))
            {
                if (!loj.select_rows_loja(input_cont_dl.get_st_loja()))
                {
                    PublishError("Loja não disponível");
                    return(false);
                }
            }

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

            /// USER [ authenticate ] END

            Registry("authenticate done exec_alteraLoja ");

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

            Registry("execute fetch_convenioLojaGift ");

            /// USER [ execute ]

            T_Empresa emp = new T_Empresa(this);

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

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

            T_Loja loj = new T_Loja(this);

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

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

            LINK_LojaEmpresa le = new LINK_LojaEmpresa(this);

            if (!le.select_fk_empresa_loja(emp.get_identity(), loj.get_identity()))
            {
                return(false);
            }

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

            output_st_ag    = le.get_st_ag();
            output_st_banco = le.get_st_banco();
            output_st_conta = le.get_st_conta();

            /// USER [ execute ] END

            Registry("execute done fetch_convenioLojaGift ");

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

            Registry("authenticate fetch_rel_2_rlt ");

            /// USER [ authenticate ]

            if (input_st_loja.Length == 0)
            {
                PublishError("Loja inválida");
                return(false);
            }

            loj = new T_Loja(this);

            // ## Busca loja pelo seu código

            if (!loj.select_rows_loja(input_st_loja))
            {
                PublishError("Loja inválida");
                return(false);
            }

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

            output_st_nome_loja = loj.get_st_social();

            fk_loja = loj.get_identity();

            l_tr = new LOG_Transacoes(this);

            // ## busca transações pelo período e loja

            if (!l_tr.select_rows_dt_loj(input_st_dt_ini,
                                         input_st_dt_fim,
                                         fk_loja))
            {
                PublishError("Nenhum registro encontrado");
                return(false);
            }

            /// USER [ authenticate ] END

            Registry("authenticate done fetch_rel_2_rlt ");

            return(true);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute exec_bloq_loja ");

            /// USER [ execute ]

            T_Loja loj = new T_Loja(this);

            loj.ExclusiveAccess();

            if (!loj.select_rows_cnpj(input_st_cnpj))
            {
                PublishError("Loja não disponível");
                return(false);
            }

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

            if (loj.get_tg_blocked() == Context.TRUE)
            {
                PublishError("Loja previamente bloqueada");
                return(false);
            }

            st_cod_loja = loj.get_st_loja();

            loj.set_tg_blocked(Context.TRUE);

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

            PublishNote("Loja bloqueada com sucesso");

            /// USER [ execute ] END

            Registry("execute done exec_bloq_loja ");

            return(true);
        }
Esempio n. 10
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);
        }
		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;
		}
Esempio n. 12
0
        public override bool authenticate( )
        {
            if (base.authenticate() == false)
            {
                return(false);
            }

            Registry("authenticate fetch_dadosLoja ");

            /// USER [ authenticate ]

            // ## Busca loja pelo CNPJ

            loj = new T_Loja(this);

            if (input_st_cod == "")
            {
                if (!loj.select_rows_cnpj(input_st_cnpj.PadLeft(6, '0')))
                {
                    PublishError("Loja de CNPJ " + input_st_cnpj + " inexistente");
                    return(false);
                }
            }
            else
            {
                if (!loj.select_rows_loja(input_st_cod))
                {
                    PublishError("Loja de código " + input_st_cod + " inexistente");
                    return(false);
                }
            }

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

            /// USER [ authenticate ] END

            Registry("authenticate done fetch_dadosLoja ");

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

            Registry("authenticate fetch_terminalLoja ");

            /// USER [ authenticate ]

            loj = new T_Loja(this);

            if (!loj.select_rows_loja(input_st_cnpj_loja))
            {
                PublishError("Loja inexistente");
                return(false);
            }

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

            term = new T_Terminal(this);

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

            /// USER [ authenticate ] END

            Registry("authenticate done fetch_terminalLoja ");

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

            Registry("authenticate del_Terminal ");

            /// USER [ authenticate ]

            loj = new T_Loja(this);

            if (!loj.select_rows_cnpj(input_st_loja_cnpj))
            {
                PublishError("Loja não cadastrada");
                return(false);
            }

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

            term = new T_Terminal(this);

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

            /// USER [ authenticate ] END

            Registry("authenticate done del_Terminal ");

            return(true);
        }
Esempio n. 15
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);
        }
Esempio n. 16
0
        public override bool authenticate( )
        {
            if (base.authenticate() == false)
            {
                return(false);
            }

            Registry("authenticate fetch_rel_1_rtc ");

            /// USER [ authenticate ]

            input_st_cart = input_st_cart.PadLeft(14, '0');

            l_tr = new LOG_Transacoes(this);

            // ## Confere telefone

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

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

                    st_cart_id = pf.get_fk_cartao();
                }
            }

            // ##  Confere cartão

            else if (input_st_cart.Length == 14)
            {
                T_Cartao cart = new T_Cartao(this);

                if (!cart.select_rows_tudo(input_st_cart.Substring(0, 6),                               // empresa
                                           input_st_cart.Substring(6, 6),                               // matricula
                                           input_st_cart.Substring(12, 2)))                             // titularidade
                {
                    PublishError("Cartão inválido");
                    return(true);
                }
                else
                {
                    if (!cart.fetch())
                    {
                        return(false);
                    }

                    st_cart_id = cart.get_identity();
                }
            }

            // ## Confere Loja

            loj = new T_Loja(this);

            if (input_st_loja.Length > 0)
            {
                // ## Busca pelo código

                if (!loj.select_rows_loja(input_st_loja))
                {
                    PublishError("Loja inexistente");
                    return(true);
                }

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

                fk_loja = loj.get_identity();
            }

            // ## Seleciona os registros de transações

            l_tr.select_rows_dt_cart(input_st_dt_ini,
                                     input_st_dt_fim,
                                     st_cart_id);

            /// USER [ authenticate ] END

            Registry("authenticate done fetch_rel_1_rtc ");

            return(true);
        }
Esempio n. 17
0
        public override bool authenticate( )
        {
            Registry("authenticate exec_pos_desfazVendaEmpresarialSITEF ");

            /// USER [ authenticate ]

            // ## Buscar terminal

            T_Loja loja = new T_Loja(this);

            var_codResp = "0606";

            //alterado
            if (!loja.select_rows_loja(input_cont_pe.get_st_terminal().Substring(1).TrimStart('0')))
            {
                output_st_msg = "Erro aplicativo1";
                return(false);
            }

            if (!loja.fetch())
            {
                output_st_msg = "Erro aplicativo2";
                return(false);
            }



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

            l_tr = new LOG_Transacoes(this);

            if (!l_tr.select_rows_loj_vr(loja.get_identity(),
                                         input_cont_pe.get_vr_valor(),
                                         input_cont_pe.get_st_nsuOrigemSITEF()))
            {
                output_st_msg = "Erro aplicativo3";
                return(false);
            }

            l_tr.SetReversedFetch();

            if (!l_tr.fetch())
            {
                output_st_msg = "Erro aplicativo4";
                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 aplicativo5";
                return(false);
            }

            term = new T_Terminal(this);

            if (!term.selectIdentity(l_tr.get_fk_terminal()))
            {
                output_st_msg = "Erro aplicativo6";
                return(false);
            }

            var_codResp = "0000";

            /// USER [ authenticate ] END

            Registry("authenticate done exec_pos_desfazVendaEmpresarialSITEF ");

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

            Registry("execute schedule_faturamento ");

            /// USER [ execute ]

            T_Empresa emp   = new T_Empresa(this);
            DateTime  dtFat = DateTime.Now.AddDays(-1);

            #region - ## Busca todas as empresas -

            if (emp.selectAll())
            {
                // ## Busco todos os registros

                while (emp.fetch())
                {
                    // ## Se dia é hoje

                    if (emp.get_int_nu_periodoFat() == dtFat.Day &&
                        emp.get_tg_isentoFat() == Context.FALSE)
                    {
                        T_Faturamento fat     = new T_Faturamento(this);
                        T_Faturamento fat_upd = new T_Faturamento(this);

                        DateTime aux = dtFat;

                        // ## Para casos onde o mês deve ser o próximo

                        if (emp.get_int_nu_diaVenc() < dtFat.Day)
                        {
                            aux = dtFat.AddMonths(1);
                        }

                        DateTime dtVenc = new DateTime(aux.Year,
                                                       aux.Month,
                                                       (int)emp.get_int_nu_diaVenc());

                        fat.set_dt_vencimento(GetDataBaseTime(dtVenc));
                        fat.set_fk_empresa(emp.get_identity());
                        fat.set_tg_situacao(TipoSitFat.Pendente);

                        // ## Crio registro

                        fat.create_T_Faturamento();

                        long vr_total_fat = 0;

                        // ## Crio registro detalhe

                        #region - 1 - mensalidade -

                        {
                            T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

                            fat_det.set_fk_fatura(fat.get_identity());
                            fat_det.set_vr_cobranca(emp.get_vr_mensalidade());
                            fat_det.set_tg_tipoFat(TipoFat.TBM);
                            fat_det.set_tg_desconto(Context.FALSE);
                            fat_det.set_fk_empresa(emp.get_identity());
                            fat_det.set_fk_loja(Context.FALSE);

                            vr_total_fat += fat_det.get_int_vr_cobranca();

                            fat_det.create_T_FaturamentoDetalhes();
                        }

                        #endregion

                        #region - 2 - valor por transações -

                        if (emp.get_int_vr_transacao() > 0)
                        {
                            LOG_Transacoes l_tr = new LOG_Transacoes(this);

                            l_tr.SetCountMode();

                            l_tr.select_rows_dt_emp(GetDataBaseTime(dtFat.AddMonths(-1)),
                                                    GetDataBaseTime(dtFat),
                                                    emp.get_identity());

                            long trans = l_tr.GetCount() - emp.get_int_nu_franquia();

                            if (trans > 0)
                            {
                                T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

                                fat_det.set_fk_fatura(fat.get_identity());
                                fat_det.set_vr_cobranca((trans * emp.get_int_vr_transacao()).ToString());
                                fat_det.set_tg_tipoFat(TipoFat.FixoTrans);
                                fat_det.set_nu_quantidade(l_tr.GetCount().ToString());
                                fat_det.set_tg_desconto(Context.FALSE);
                                fat_det.set_fk_empresa(emp.get_identity());
                                fat_det.set_fk_loja(Context.FALSE);

                                vr_total_fat += fat_det.get_int_vr_cobranca();

                                fat_det.create_T_FaturamentoDetalhes();
                            }
                        }

                        #endregion

                        #region - 3 - valor percentual por transações -

                        if (emp.get_int_nu_pctValor() > 0)
                        {
                            LOG_Transacoes l_tr = new LOG_Transacoes(this);

                            // ## Busca por período e empresa

                            if (l_tr.select_rows_dt_emp(GetDataBaseTime(dtFat.AddMonths(-1)),
                                                        GetDataBaseTime(dtFat),
                                                        emp.get_identity()))
                            {
                                long vr_trans = 0;

                                while (l_tr.fetch())
                                {
                                    if (l_tr.get_tg_confirmada() == TipoConfirmacao.Confirmada)
                                    {
                                        vr_trans += l_tr.get_int_vr_total();
                                    }
                                }

                                if (vr_trans > 0)
                                {
                                    vr_trans = vr_trans * emp.get_int_nu_pctValor() / 10000;

                                    T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

                                    fat_det.set_fk_fatura(fat.get_identity());
                                    fat_det.set_vr_cobranca(vr_trans.ToString());
                                    fat_det.set_tg_tipoFat(TipoFat.Percent);
                                    fat_det.set_tg_desconto(Context.FALSE);
                                    fat_det.set_fk_empresa(emp.get_identity());
                                    fat_det.set_fk_loja(Context.FALSE);

                                    vr_total_fat += fat_det.get_int_vr_cobranca();

                                    fat_det.create_T_FaturamentoDetalhes();
                                }
                            }
                        }

                        #endregion

                        #region - 4 - valor cartão ativo -

                        if (emp.get_int_vr_cartaoAtivo() > 0)
                        {
                            T_Cartao cart = new T_Cartao(this);

                            // ## Busca por período e empresa

                            if (cart.select_rows_empresa(emp.get_st_empresa()))
                            {
                                T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

                                fat_det.set_fk_fatura(fat.get_identity());
                                fat_det.set_vr_cobranca((cart.RowCount() * emp.get_int_vr_cartaoAtivo()).ToString());
                                fat_det.set_tg_tipoFat(TipoFat.CartaoAtiv);
                                fat_det.set_tg_desconto(Context.FALSE);
                                fat_det.set_fk_empresa(emp.get_identity());
                                fat_det.set_fk_loja(Context.FALSE);

                                vr_total_fat += fat_det.get_int_vr_cobranca();

                                fat_det.create_T_FaturamentoDetalhes();
                            }
                        }

                        #endregion

                        #region - 5 - valores extras -

                        T_FaturamentoDetalhes fat_extras = new T_FaturamentoDetalhes(this);

                        if (fat_extras.select_rows_emp(emp.get_identity(), TipoFat.Extras))
                        {
                            while (fat_extras.fetch())
                            {
                                vr_total_fat += fat_extras.get_int_vr_cobranca();

                                T_FaturamentoDetalhes fat_extras_upd = new T_FaturamentoDetalhes(this);

                                fat_extras_upd.ExclusiveAccess();

                                fat_extras_upd.selectIdentity(fat_extras.get_identity());
                                fat_extras_upd.set_fk_fatura(fat.get_identity());

                                fat_extras_upd.synchronize_T_FaturamentoDetalhes();
                                fat_extras_upd.ReleaseExclusive();
                            }
                        }

                        #endregion

                        if (emp.get_int_vr_minimo() > vr_total_fat)
                        {
                            vr_total_fat = emp.get_int_vr_minimo();
                        }

                        fat_upd.ExclusiveAccess();
                        fat_upd.selectIdentity(fat.get_identity());

                        fat_upd.set_vr_cobranca(vr_total_fat.ToString());

                        fat_upd.synchronize_T_Faturamento();
                        fat_upd.ReleaseExclusive();
                    }
                }
            }

            #endregion

            T_Loja loj = new T_Loja(this);

            // ## Busca todas as lojas

            if (loj.selectAll())
            {
                // ## Busco todos os registros

                while (loj.fetch())
                {
                    // ## Se dia é hoje

                    Trace("Loja: " + loj.get_st_nome());

                    if (loj.get_tg_cancel() == Context.TRUE)
                    {
                        continue;
                    }

                    Trace("Loja ok ");

                    if (loj.get_int_nu_periodoFat() == dtFat.Day &&
                        loj.get_tg_isentoFat() == Context.FALSE)
                    {
                        Trace("[A]");

                        T_Faturamento fat     = new T_Faturamento(this);
                        T_Faturamento fat_upd = new T_Faturamento(this);

                        DateTime aux = dtFat;

                        // ## Para casos onde o mês deve ser o próximo

                        if (loj.get_int_nu_diavenc() < dtFat.Day)
                        {
                            Trace("[B]");
                            aux = dtFat.AddMonths(1);
                        }

                        Trace("[C]");

                        int zday = Convert.ToInt32(loj.get_int_nu_diavenc());

                        Trace("[C] 1 " + aux.Year.ToString());
                        Trace("[C] 2 " + aux.Month.ToString());
                        Trace("[C] 3 " + zday.ToString());

                        DateTime dtVenc = new DateTime(aux.Year, aux.Month, zday);

                        Trace("[D]");

                        fat.set_dt_vencimento(GetDataBaseTime(dtVenc));
                        fat.set_fk_loja(loj.get_identity());
                        fat.set_tg_situacao(TipoSitFat.Pendente);

                        // ## Crio registro

                        fat.create_T_Faturamento();

                        long vr_total_fat = 0;

                        // ## Crio registro detalhe

                        #region - 1 - mensalidade -

                        {
                            Trace("[E]");

                            T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

                            fat_det.set_fk_fatura(fat.get_identity());
                            fat_det.set_vr_cobranca(loj.get_vr_mensalidade());
                            fat_det.set_tg_tipoFat(TipoFat.TBM);
                            fat_det.set_tg_desconto(Context.FALSE);
                            fat_det.set_fk_empresa(Context.FALSE);
                            fat_det.set_fk_loja(loj.get_identity());

                            vr_total_fat += fat_det.get_int_vr_cobranca();

                            fat_det.create_T_FaturamentoDetalhes();
                        }

                        #endregion

                        #region - 2 - valor por transações -

                        if (loj.get_int_vr_transacao() > 0)
                        {
                            Trace("[F]");

                            LOG_Transacoes l_tr = new LOG_Transacoes(this);

                            l_tr.SetCountMode();

                            l_tr.select_rows_dt_loj(GetDataBaseTime(dtFat.AddMonths(-1)),
                                                    GetDataBaseTime(dtFat),
                                                    loj.get_identity());

                            long trans = l_tr.GetCount() - loj.get_int_nu_franquia();

                            if (trans > 0)
                            {
                                Trace("[G]");

                                T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

                                fat_det.set_fk_fatura(fat.get_identity());
                                fat_det.set_vr_cobranca((trans * loj.get_int_vr_transacao()).ToString());
                                fat_det.set_tg_tipoFat(TipoFat.FixoTrans);
                                fat_det.set_nu_quantidade(l_tr.GetCount().ToString());
                                fat_det.set_tg_desconto(Context.FALSE);
                                fat_det.set_fk_empresa(Context.FALSE);
                                fat_det.set_fk_loja(loj.get_identity());

                                vr_total_fat += fat_det.get_int_vr_cobranca();

                                fat_det.create_T_FaturamentoDetalhes();
                            }
                        }

                        #endregion

                        #region - 3 - valor percentual por transações -

                        if (loj.get_int_nu_pctValor() > 0)
                        {
                            Trace("[H]");

                            LOG_Transacoes l_tr = new LOG_Transacoes(this);

                            // ## Busca por período e empresa

                            if (l_tr.select_rows_dt_loj(GetDataBaseTime(dtFat.AddMonths(-1)),
                                                        GetDataBaseTime(dtFat),
                                                        loj.get_identity()))
                            {
                                Trace("[I]");

                                long vr_trans = 0;

                                while (l_tr.fetch())
                                {
                                    if (l_tr.get_tg_confirmada() == TipoConfirmacao.Confirmada)
                                    {
                                        vr_trans += l_tr.get_int_vr_total();
                                    }
                                }

                                if (vr_trans > 0)
                                {
                                    Trace("[J]");

                                    vr_trans = vr_trans * loj.get_int_nu_pctValor() / 10000;

                                    T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

                                    fat_det.set_fk_fatura(fat.get_identity());
                                    fat_det.set_vr_cobranca(vr_trans.ToString());
                                    fat_det.set_tg_tipoFat(TipoFat.Percent);
                                    fat_det.set_tg_desconto(Context.FALSE);
                                    fat_det.set_fk_empresa(Context.FALSE);
                                    fat_det.set_fk_loja(loj.get_identity());

                                    vr_total_fat += fat_det.get_int_vr_cobranca();

                                    fat_det.create_T_FaturamentoDetalhes();
                                }
                            }
                        }

                        #endregion

                        #region - 4 - valores extras -

                        T_FaturamentoDetalhes fat_extras = new T_FaturamentoDetalhes(this);

                        if (fat_extras.select_rows_emp(loj.get_identity(), TipoFat.Extras))
                        {
                            Trace("[K]");

                            while (fat_extras.fetch())
                            {
                                Trace("[L]");

                                vr_total_fat += fat_extras.get_int_vr_cobranca();

                                T_FaturamentoDetalhes fat_extras_upd = new T_FaturamentoDetalhes(this);

                                fat_extras_upd.ExclusiveAccess();

                                fat_extras_upd.selectIdentity(fat_extras.get_identity());
                                fat_extras_upd.set_fk_fatura(fat.get_identity());

                                fat_extras_upd.synchronize_T_FaturamentoDetalhes();
                                fat_extras_upd.ReleaseExclusive();
                            }
                        }

                        #endregion

                        if (vr_total_fat < loj.get_int_vr_minimo())
                        {
                            vr_total_fat = loj.get_int_vr_minimo();
                        }

                        fat_upd.ExclusiveAccess();
                        fat_upd.selectIdentity(fat.get_identity());

                        fat_upd.set_vr_cobranca(vr_total_fat.ToString());

                        fat_upd.synchronize_T_Faturamento();
                        fat_upd.ReleaseExclusive();

                        Trace("[M]");
                    }
                }
            }

            /// USER [ execute ] END

            Registry("execute done schedule_faturamento ");

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

            Registry("execute fetch_rel_tarifas ");

            /// USER [ execute ]

            StringBuilder sb_emp     = new StringBuilder();
            StringBuilder sb_content = new StringBuilder();

            money mon_help = new money();

            T_Empresa emp = new T_Empresa(this);

            emp.select_rows_tarifas();

            while (emp.fetch())
            {
                DadosEmpresa de = new DadosEmpresa();

                de.set_st_fantasia("(E) " + emp.get_st_empresa() + " " + emp.get_st_fantasia());

                DataPortable tmp = de as DataPortable;

                sb_emp.Append(MemorySave(ref tmp));
                sb_emp.Append(",");

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(de.get_st_fantasia());
                    //rt.set_st_desc ( "Empresa" );
                    rt.set_st_val(emp.get_st_fantasia());

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(de.get_st_fantasia());
                    //rt.set_st_desc ( "Mensalidade" );
                    rt.set_st_val(mon_help.formatToMoney(emp.get_vr_mensalidade()));

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(de.get_st_fantasia());
                    //rt.set_st_desc ( "Percentual sobre transação" );

                    string pct = emp.get_nu_pctValor().PadLeft(3, '0');

                    pct = pct.Insert(pct.Length - 2, ",") + "%";

                    rt.set_st_val(pct);

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(de.get_st_fantasia());
                    //rt.set_st_desc ( "Valor transação" );
                    rt.set_st_val(mon_help.formatToMoney(emp.get_vr_transacao()));

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(de.get_st_fantasia());
                    //rt.set_st_desc ( "Valor mínimo" );
                    rt.set_st_val(mon_help.formatToMoney(emp.get_vr_minimo()));

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(de.get_st_fantasia());
                    //rt.set_st_desc ( "Franquia de transações" );
                    rt.set_st_val(emp.get_nu_franquia());

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(de.get_st_fantasia());
                    //rt.set_st_desc ( "Valor por cartão ativo" );
                    rt.set_st_val(mon_help.formatToMoney(emp.get_vr_cartaoAtivo()));

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(de.get_st_fantasia());
                    //rt.set_st_desc ( "Isento de Fatura" );

                    if (emp.get_tg_isentoFat() == Context.TRUE)
                    {
                        rt.set_st_val("SIM");
                    }
                    else
                    {
                        rt.set_st_val("NÃO");
                    }

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(de.get_st_fantasia());
                    //rt.set_st_desc ( "Situação" );

                    if (emp.get_tg_blocked() == Context.TRUE)
                    {
                        rt.set_st_val("Bloq.");
                    }
                    else
                    {
                        rt.set_st_val("Ativo");
                    }

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }
            }

            T_Loja loj = new T_Loja(this);

            loj.select_rows_tarifas();

            while (loj.fetch())
            {
                DadosEmpresa de = new DadosEmpresa();

                string id = "(" + loj.get_st_loja() + ") CNPJ: " + loj.get_nu_CNPJ() + " " + loj.get_st_nome() + " - " + loj.get_st_social();

                de.set_st_fantasia(id);

                DataPortable tmp = de as DataPortable;

                sb_emp.Append(MemorySave(ref tmp));
                sb_emp.Append(",");

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(de.get_st_fantasia());
                    //rt.set_st_desc ( "Empresa" );
                    rt.set_st_val(id);

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(id);
                    //rt.set_st_desc ( "Mensalidade" );
                    rt.set_st_val(mon_help.formatToMoney(loj.get_vr_mensalidade()));

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(id);
                    //rt.set_st_desc ( "Percentual sobre transação" );

                    string pct = loj.get_nu_pctValor().PadLeft(3, '0');

                    pct = pct.Insert(pct.Length - 2, ",") + "%";

                    rt.set_st_val(pct);

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(id);
                    //rt.set_st_desc ( "Valor transação" );
                    rt.set_st_val(mon_help.formatToMoney(loj.get_vr_transacao()));

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(id);
                    //rt.set_st_desc ( "Valor mínimo" );
                    rt.set_st_val(mon_help.formatToMoney(loj.get_vr_minimo()));

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(id);
                    //rt.set_st_desc ( "Franquia de transações" );
                    rt.set_st_val(loj.get_nu_franquia());

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(de.get_st_fantasia());
                    //rt.set_st_desc ( "Valor por cartão ativo" );
                    rt.set_st_val("0");

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(id);
                    //rt.set_st_desc ( "Isento de Fatura" );

                    if (loj.get_tg_isentoFat() == Context.TRUE)
                    {
                        rt.set_st_val("SIM");
                    }
                    else
                    {
                        rt.set_st_val("NÃO");
                    }

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }

                {
                    Rel_Tarifas rt = new Rel_Tarifas();

                    rt.set_st_emp(de.get_st_fantasia());
                    //rt.set_st_desc ( "Situação" );

                    if (loj.get_tg_blocked() == Context.TRUE)
                    {
                        rt.set_st_val("Bloq.");
                    }
                    else
                    {
                        rt.set_st_val("Ativo");
                    }

                    if (loj.get_tg_cancel() == Context.TRUE)
                    {
                        rt.set_st_val("Cancel.");
                    }

                    DataPortable port_rt = rt as DataPortable;

                    sb_content.Append(MemorySave(ref port_rt));
                    sb_content.Append(",");
                }
            }

            // content
            {
                string list_ids = sb_content.ToString().TrimEnd(',');

                DataPortable dp = new DataPortable();

                dp.setValue("ids", list_ids);

                output_st_csv = MemorySave(ref dp);
            }

            // entidades
            {
                string list_ids = sb_emp.ToString().TrimEnd(',');

                DataPortable dp = new DataPortable();

                dp.setValue("ids", list_ids);

                output_st_csv_emp = MemorySave(ref dp);
            }

            /// USER [ execute ] END

            Registry("execute done fetch_rel_tarifas ");

            return(true);
        }
Esempio n. 20
0
        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);
        }
Esempio n. 21
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute fetch_chamados ");

            /// USER [ execute ]

            T_Usuario usrConvey        = new T_Usuario(this);
            T_Usuario usrConveyCriador = new T_Usuario(this);

            if (input_st_operador.Length > 0)
            {
                if (!usrConvey.select_rows_login(input_st_operador, "000000"))
                {
                    PublishError("Usuário inexistente");
                    return(false);
                }

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

            if (input_st_resp.Length > 0)
            {
                if (!usrConveyCriador.select_rows_login(input_st_resp, "000000"))
                {
                    PublishError("Usuário inexistente");
                    return(false);
                }

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

            T_Loja loj = new T_Loja(this);

            if (input_st_loja.Length > 0)
            {
                if (!loj.select_rows_loja(input_st_loja))
                {
                    PublishError("Código de loja inválido");
                    return(false);
                }

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

            T_Chamado cham = new T_Chamado(this);

            #region - busca pela data -

            if (input_dt_ini_ab.Length > 0 &&
                input_dt_fim_ab.Length > 0 &&
                input_dt_ini_fech.Length > 0 &&
                input_dt_fim_fech.Length > 0)
            {
                if (!cham.select_rows_abert_fech(input_dt_ini_ab,
                                                 input_dt_fim_ab,
                                                 input_dt_ini_fech,
                                                 input_dt_fim_fech))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (input_dt_ini_ab.Length > 0 &&
                     input_dt_fim_ab.Length > 0 &&
                     input_dt_ini_fech.Length > 0 &&
                     input_dt_fim_fech.Length == 0)
            {
                if (!cham.select_rows_abert_fech(input_dt_ini_ab,
                                                 input_dt_fim_ab,
                                                 input_dt_ini_fech))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (input_dt_ini_ab.Length > 0 &&
                     input_dt_fim_ab.Length > 0 &&
                     input_dt_ini_fech.Length == 0 &&
                     input_dt_fim_fech.Length == 0)
            {
                if (!cham.select_rows_abert_fech(input_dt_ini_ab,
                                                 input_dt_fim_ab))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (input_dt_ini_ab.Length > 0 &&
                     input_dt_fim_ab.Length == 0 &&
                     input_dt_ini_fech.Length == 0 &&
                     input_dt_fim_fech.Length == 0)
            {
                if (!cham.select_rows_abert_fech(input_dt_ini_ab))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (input_dt_ini_ab.Length > 0 &&
                     input_dt_fim_ab.Length == 0 &&
                     input_dt_ini_fech.Length > 0 &&
                     input_dt_fim_fech.Length == 0)
            {
                if (!cham.select_rows_abert_fech_ini(input_dt_ini_ab,
                                                     input_dt_ini_fech))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }
            else if (input_dt_ini_ab.Length == 0 &&
                     input_dt_fim_ab.Length == 0 &&
                     input_dt_ini_fech.Length > 0 &&
                     input_dt_fim_fech.Length == 0)
            {
                if (!cham.select_rows_fech(input_dt_ini_fech))
                {
                    PublishError("Nenhum registro encontrado");
                    return(false);
                }
            }

            #endregion

            StringBuilder sb = new StringBuilder();

            while (cham.fetch())
            {
                if (input_st_loja.Length > 0)
                {
                    if (cham.get_fk_loja() != loj.get_identity())
                    {
                        continue;
                    }
                }

                if (input_st_operador.Length > 0)
                {
                    if (cham.get_fk_operador() != usrConvey.get_identity())
                    {
                        continue;
                    }
                }
                else if (!usrConvey.selectIdentity(cham.get_fk_operador()))
                {
                    continue;
                }

                if (input_st_resp.Length > 0)
                {
                    if (cham.get_fk_oper_criador() != usrConveyCriador.get_identity())
                    {
                        continue;
                    }
                }
                else if (!usrConveyCriador.selectIdentity(cham.get_fk_oper_criador()))
                {
                    continue;
                }

                if (input_nu_prioridade != "-1")
                {
                    if (cham.get_nu_prioridade() != input_nu_prioridade)
                    {
                        continue;
                    }
                }

                if (input_nu_categ != "-1")
                {
                    if (cham.get_nu_categoria() != input_nu_categ)
                    {
                        continue;
                    }
                }

                if (cham.get_tg_fechado() != input_tg_closed)
                {
                    continue;
                }

                if (cham.get_tg_tecnico() != input_tg_tecnico)
                {
                    continue;
                }

                DadosChamado dc = new DadosChamado();

                dc.set_id_chamado(cham.get_identity());
                dc.set_st_oper(usrConvey.get_st_nome());
                dc.set_st_resp(usrConveyCriador.get_st_nome());
                dc.set_dt_ab(cham.get_dt_abertura());
                dc.set_st_motivo(cham.get_st_motivo());

                if (cham.get_tg_fechado() == Context.TRUE)
                {
                    dc.set_dt_fech(cham.get_dt_fechamento());
                }

                DataPortable tmp = dc as DataPortable;

                // ## indexa em memória

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

            // ## cria indexador de bloco

            output_st_block = MemorySave(ref dp);

            /// USER [ execute ] END

            Registry("execute done fetch_chamados ");

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

            Registry("execute exec_repasseLoja ");

            /// USER [ execute ]

            loj = new T_Loja(this);

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

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

            T_RepasseLoja rl = new T_RepasseLoja(this);

            rl.set_dt_efetiva(GetDataBaseTime());
            rl.set_fk_loja(loj.get_identity());
            rl.set_st_ident(input_st_ident);
            rl.set_tg_opcao(input_tg_opcao);
            rl.set_vr_valor(input_vr_valor);

            if (!rl.create_T_RepasseLoja())
            {
                return(false);
            }

            output_id_confRepasse = rl.get_identity();

            LINK_RepasseParcela lrp = new LINK_RepasseParcela(this);

            T_Parcelas parc = new T_Parcelas(this);

            for (int t = 0; t < input_array_generic_lstPar.Count; ++t)
            {
                DadosRepasse dr = new DadosRepasse(input_array_generic_lstPar[t] as DataPortable);

                if (dr.get_tg_confirmado() == Context.FALSE)
                {
                    continue;
                }

                parc.ExclusiveAccess();

                if (!parc.selectIdentity(dr.get_id_parcela()))
                {
                    return(false);
                }

                // esta parcela foi repassada
                parc.set_tg_pago(Context.TRUE);

                if (!parc.synchronize_T_Parcelas())
                {
                    return(false);
                }

                parc.ReleaseExclusive();

                lrp.set_fk_parcela(parc.get_identity());
                lrp.set_fk_repasseLoja(rl.get_identity());

                if (!lrp.create_LINK_RepasseParcela())
                {
                    return(false);
                }
            }

            PublishNote("Repasse feito com sucesso");

            /// USER [ execute ] END

            Registry("execute done exec_repasseLoja ");

            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 execute( )
        {
            Registry("execute fetch_consultaLojistaRep ");

            /// USER [ execute ]

            T_Loja loj = new T_Loja(this);

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

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

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

            T_Empresa emp = new T_Empresa(this);

            if (!emp.select_rows_empresa(input_empresa.PadLeft(6, '0')))
            {
                PublishError("Empresa não disponível");
                return(false);
            }

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

            LINK_LojaEmpresa lje = new LINK_LojaEmpresa(this);

            if (!lje.select_fk_empresa_loja(emp.get_identity(), loj.get_identity()))
            {
                PublishError("Loja não conveniada com associação");
                return(false);
            }

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

            double tx = lje.get_int_tx_admin();

            T_Cartao       cart = new T_Cartao(this);
            T_Parcelas     parc = new T_Parcelas(this);
            LOG_Transacoes ltr  = new LOG_Transacoes(this);
            LOG_Fechamento lf   = new LOG_Fechamento(this);

            StringBuilder sb = new StringBuilder();

            if (lf.select_rows_mes_ano(input_mes.PadLeft(2, '0'),
                                       input_ano.PadLeft(2, '0'),
                                       emp.get_identity()))
            {
                if (lf.RowCount() > 0)
                {
                    while (lf.fetch())
                    {
                        if (lf.get_fk_loja() != loj.get_identity())
                        {
                            continue;
                        }

                        if (!parc.selectIdentity(lf.get_fk_parcela()))
                        {
                            return(false);
                        }

                        if (!ltr.selectIdentity(parc.get_fk_log_transacoes()))
                        {
                            return(false);
                        }

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

                        if (!cart.selectIdentity(ltr.get_fk_cartao()))
                        {
                            return(false);
                        }

                        DadosConsultaTransacao dct = new DadosConsultaTransacao();

                        dct.set_dt_transacao(ltr.get_dt_transacao());
                        dct.set_st_nsu(ltr.get_nu_nsu());
                        dct.set_nu_parcelas(parc.get_nu_indice());

                        dct.set_st_cartao(cart.get_st_empresa() + "." +
                                          cart.get_st_matricula() + "." +
                                          cart.get_st_titularidade());

                        dct.set_vr_valor(ltr.get_vr_total());

                        long repasse = Convert.ToInt64(lf.get_int_vr_valor() -
                                                       (lf.get_int_vr_valor() * tx / 10000));

                        dct.set_vr_repasse(repasse.ToString());

                        DataPortable tmp = dct as DataPortable;

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

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

            Registry("execute fetch_rel_prevLojista ");

            /// USER [ execute ]

            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);
            }

            T_Loja loj = new T_Loja(this);

            if (!loj.select_rows_loja(input_cont_header.get_st_empresa().TrimStart('0')))
            {
                return(false);
            }

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

            LINK_LojaEmpresa loj_emp = new LINK_LojaEmpresa(this);

            if (!loj_emp.select_fk_empresa_loja(emp.get_identity(),
                                                loj.get_identity()))
            {
                PublishError("Loja não conveniada com empresa");
                return(false);
            }

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

            double tx = loj_emp.get_int_tx_admin();

            T_Parcelas     parc = new T_Parcelas(this);
            T_Cartao       cart = new T_Cartao(this);
            LOG_Transacoes ltr  = new LOG_Transacoes(this);

            if (parc.select_rows_lojista_emp(loj.get_identity(),
                                             emp.get_identity(),
                                             "1"))
            {
                SQL_LOGGING_ENABLE = false;

                StringBuilder sb = new StringBuilder();

                while (parc.fetch())
                {
                    if (parc.get_tg_pago() == Context.TRUE)
                    {
                        continue;
                    }

                    if (!ltr.selectIdentity(parc.get_fk_log_transacoes()))
                    {
                        continue;
                    }

                    if (ltr.get_tg_confirmada() != TipoConfirmacao.Confirmada)
                    {
                        continue;
                    }

                    if (!cart.selectIdentity(parc.get_fk_cartao()))
                    {
                        continue;
                    }

                    if (cart.get_st_empresa() != emp.get_st_empresa())
                    {
                        continue;
                    }

                    DadosRepasse dr = new DadosRepasse();

                    dr.set_st_cartao(cart.get_st_empresa() + "." +
                                     cart.get_st_matricula() + "." +
                                     cart.get_st_titularidade());

                    dr.set_st_nsu(parc.get_nu_nsu());
                    dr.set_dt_trans(parc.get_dt_inclusao());
                    dr.set_id_parcela(parc.get_nu_indice());
                    dr.set_vr_total(parc.get_vr_valor());

                    //DateTime t_rep = Convert.ToDateTime ( p

                    //dr.set_dt_repasse   (

                    long repasse = Convert.ToInt64(parc.get_int_vr_valor() - (parc.get_int_vr_valor() * tx / 10000));

                    dr.set_vr_repasse(repasse.ToString());

                    DataPortable mem_rtc = dr as DataPortable;

                    // ## obtem indice

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

                string list_ids = sb.ToString().TrimEnd(',');

                DataPortable dp = new DataPortable();

                dp.setValue("ids", list_ids);

                // ## obtem indice geral

                output_st_csv = MemorySave(ref dp);

                SQL_LOGGING_ENABLE = true;
            }

            /// USER [ execute ] END

            Registry("execute done fetch_rel_prevLojista ");

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

            Registry("execute graph_financeiro ");

            /// USER [ execute ]

            LOG_Transacoes ltr = new LOG_Transacoes(this);

            StringBuilder sb_global = new StringBuilder();

            T_Loja    loj = new T_Loja(this);
            T_Empresa emp = new T_Empresa(this);

            for (int u = 0; u < input_array_generic_lstCurves.Count; ++u)
            {
                DadosGraficoFinanceiro tmp_dgf = new DadosGraficoFinanceiro(input_array_generic_lstCurves[u] as DataPortable);

                DateTime t_start = Convert.ToDateTime(tmp_dgf.get_dt_ini());
                DateTime t_end   = Convert.ToDateTime(tmp_dgf.get_dt_fim()).AddHours(23).AddMinutes(59).AddSeconds(59);

                loj.Reset();

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

                emp.Reset();

                if (emp.select_rows_empresa(tmp_dgf.get_st_empresa().PadLeft(6, '0')))
                {
                    if (!emp.fetch())
                    {
                        return(false);
                    }
                }

                Hashtable hsh_globalday = new Hashtable();
                ArrayList lst_globalday = new ArrayList();

                bool loj_fetch = false;
                bool tudo      = false;

                if (t_start.Day == t_end.Day)
                {
                    if (t_start.Month == t_end.Month)
                    {
                        PublishError("Favor informar período com datas diferentes");
                        return(false);
                    }
                }

                if (loj.get_identity() != Context.NOT_SET &&
                    emp.get_identity() != Context.NOT_SET)
                {
                    loj_fetch = true;

                    if (!ltr.select_rows_graph_financ_loj(GetDataBaseTime(t_start),
                                                          GetDataBaseTime(t_end),
                                                          TipoConfirmacao.Confirmada,
                                                          loj.get_identity(),
                                                          emp.get_identity()))
                    {
                        PublishNote("Nenhum resultado para " + loj.get_st_nome());
                    }
                }
                else if (emp.get_identity() != Context.NOT_SET)
                {
                    if (!ltr.select_rows_graph_financ_emp(GetDataBaseTime(t_start),
                                                          GetDataBaseTime(t_end),
                                                          TipoConfirmacao.Confirmada,
                                                          emp.get_identity()))
                    {
                        PublishNote("Nenhum resultado para " + emp.get_st_fantasia());
                    }
                }
                else if (tmp_dgf.get_st_empresa() == Context.NOT_SET)
                {
                    tudo = true;

                    ltr.select_rows_graph_financ(GetDataBaseTime(t_start),
                                                 GetDataBaseTime(t_end),
                                                 TipoConfirmacao.Confirmada);
                }

                long vr_tot = 0;

                while (ltr.fetch())
                {
                    string day = ltr.get_dt_transacao().Substring(0, 10);

                    if (hsh_globalday [day] == null)
                    {
                        if (input_tg_tipo == "0")                           // variavel
                        {
                            hsh_globalday [day] = (long)0;
                        }
                        else
                        {
                            hsh_globalday [day] = (long)vr_tot;
                        }

                        lst_globalday.Add(day);
                    }

                    vr_tot += ltr.get_int_vr_total();

                    if (input_tg_tipo == "0")                       // variavel
                    {
                        hsh_globalday [day] = (long)hsh_globalday [day] + ltr.get_int_vr_total();
                    }
                    else
                    {
                        hsh_globalday [day] = vr_tot;
                    }
                }

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

                    string nome_desc = "";

                    if (loj_fetch)
                    {
                        nome_desc = "Loja " + loj.get_st_loja() + " " + loj.get_st_nome() + " [" + emp.get_st_empresa() + "]";
                    }
                    else if (!tudo)
                    {
                        nome_desc = "Empresa " + emp.get_st_empresa();
                    }
                    else
                    {
                        nome_desc = "ConveyNET";
                    }

                    long vr_valor = (long)hsh_globalday [day];

                    DadosGraficoFinanceiro dgf = new DadosGraficoFinanceiro();

                    dgf.set_nu_id(u.ToString());
                    dgf.set_dt_point(day + " 00:00");
                    dgf.set_st_loja(nome_desc);
                    dgf.set_vr_point(vr_valor.ToString());

                    DataPortable mem = dgf as DataPortable;

                    sb_global.Append(MemorySave(ref mem));
                    sb_global.Append(",");
                }
            }

            string list_ids = sb_global.ToString().TrimEnd(',');

            if (list_ids == "")
            {
                PublishNote("Nenhum registro encontrado");
                return(false);
            }

            DataPortable dp = new DataPortable();

            dp.setValue("ids", list_ids);

            output_st_content = MemorySave(ref dp);

            /// USER [ execute ] END

            Registry("execute done graph_financeiro ");

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

            Registry("execute fetch_dadosDespesas ");

            /// USER [ execute ]

            string fk = "";

            if (input_tg_empresa == Context.TRUE)
            {
                T_Empresa emp = new T_Empresa(this);

                if (!emp.select_rows_empresa(input_st_codigo.PadLeft(6, '0')))
                {
                    PublishError("Código de empresa inválido");
                    return(false);
                }

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

                fk             = emp.get_identity();
                output_st_nome = emp.get_st_fantasia();
            }
            else
            {
                T_Loja loj = new T_Loja(this);

                if (!loj.select_rows_loja(input_st_codigo))
                {
                    PublishError("Código de loja inválido");
                    return(false);
                }

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

                fk             = loj.get_identity();
                output_st_nome = loj.get_st_nome();
            }

            T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

            if (input_tg_empresa == Context.TRUE)
            {
                if (!fat_det.select_rows_emp(fk, TipoFat.Extras))
                {
                    PublishError("Nenhuma despesa encontrada");
                    return(false);
                }
            }
            else
            {
                if (!fat_det.select_rows_loja(fk, TipoFat.Extras))
                {
                    PublishError("Nenhuma despesa encontrada");
                    return(false);
                }
            }

            T_Faturamento fat = new T_Faturamento(this);

            while (fat_det.fetch())
            {
                if (fat.selectIdentity(fat_det.get_fk_fatura()))
                {
                    if (fat.get_tg_situacao() != TipoSitFat.Pendente)
                    {
                        continue;
                    }
                }

                DadosDespesas dd = new DadosDespesas();

                dd.set_fk_faturadet(fat_det.get_identity());
                dd.set_st_info(fat_det.get_st_extras());

                if (fat_det.get_tg_desconto() == Context.TRUE)
                {
                    dd.set_vr_cobrança("-" + fat_det.get_vr_cobranca());
                }
                else
                {
                    dd.set_vr_cobrança(fat_det.get_vr_cobranca());
                }

                output_array_generic_list.Add(dd);
            }

            /// USER [ execute ] END

            Registry("execute done fetch_dadosDespesas ");

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

            Registry("execute exec_fat_recManual ");

            /// USER [ execute ]

            T_Empresa emp = new T_Empresa(this);
            T_Loja    loj = new T_Loja(this);

            if (input_tg_empresa == Context.TRUE)
            {
                if (!emp.select_rows_empresa(input_st_codigo.PadLeft(6, '0')))
                {
                    PublishError("Empresa não disponível");
                    return(false);
                }

                if (!emp.fetch())
                {
                    return(false);
                }
            }
            else
            {
                if (!loj.select_rows_loja(input_st_codigo))
                {
                    PublishError("Loja não disponível");
                    return(false);
                }

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

            T_Faturamento fat     = new T_Faturamento(this);
            T_Faturamento fat_upd = new T_Faturamento(this);

            if (input_tg_empresa == Context.TRUE)
            {
                fat.select_rows_emp(emp.get_identity());
            }
            else
            {
                fat.select_rows_loj(loj.get_identity());
            }

            while (fat.fetch())
            {
                if (fat.get_tg_situacao() == TipoSitFat.EmCobrança)
                {
                    fat_upd.ExclusiveAccess();

                    if (!fat_upd.selectIdentity(fat.get_identity()))
                    {
                        return(false);
                    }

                    fat_upd.set_tg_situacao(TipoSitFat.PagoOutros);
                    fat_upd.set_vr_cobranca(input_vr_valor);

                    if (!fat_upd.synchronize_T_Faturamento())
                    {
                        return(false);
                    }

                    fat_upd.ReleaseExclusive();

                    PublishNote("Faturamento atualizado com sucesso");
                    break;
                }
            }

            /// USER [ execute ] END

            Registry("execute done exec_fat_recManual ");

            return(true);
        }