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

            Registry("execute exec_cancelaChequeGift ");

            /// USER [ execute ]

            T_ChequesGift chq = new T_ChequesGift(this);

            chq.ExclusiveAccess();

            if (!chq.select_rows_ident(input_st_ident))
            {
                PublishError("Cheque não disponível");
                return(false);
            }

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

            if (chq.get_tg_compensado() != Context.FALSE &&              // aguardando
                chq.get_tg_compensado() != Context.TRUE)                 // compensado
            {
                PublishError("Cheque previamente cancelado");
                return(false);
            }
            else if (chq.get_tg_compensado() == Context.TRUE)                 // compensado
            {
                PublishError("Não é possível cancelar cheque compensado");
                return(false);
            }

            chq.set_tg_compensado("2");

            if (!chq.synchronize_T_ChequesGift())
            {
                return(false);
            }

            PublishNote("Cheque " + input_st_ident + " cancelado");

            /// USER [ execute ] END

            Registry("execute done exec_cancelaChequeGift ");

            return(true);
        }
예제 #2
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute ins_cartaoGift ");

            /// USER [ execute ]

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

            T_Empresa emp = new T_Empresa(this);

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

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

            T_Cartao cart = new T_Cartao(this);

            if (input_tg_tipoPag != TipoPagamento.Cheque)
            {
                cart.ExclusiveAccess();
            }

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

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

            LOG_VendaCartaoGift lvc = new LOG_VendaCartaoGift(this);

            lvc.set_fk_vendedor(user.get_identity());
            lvc.set_fk_empresa(emp.get_identity());
            lvc.set_fk_cartao(cart.get_identity());
            lvc.set_tg_tipoPag(input_tg_tipoPag);
            lvc.set_dt_compra(GetDataBaseTime());
            lvc.set_tg_tipoCartao(input_tg_tipoCartao);

            if (input_tg_tipoPag == TipoPagamento.Cheque)
            {
                lvc.set_st_cheque(input_st_cheque);

                T_ChequesGift chq_gift = new T_ChequesGift(this);

                chq_gift.set_st_identificador(input_st_cheque);
                chq_gift.set_fk_cartao(cart.get_identity());
                chq_gift.set_dt_efetiva(GetDataBaseTime());
                chq_gift.set_tg_compensado(Context.FALSE);

                if (!chq_gift.create_T_ChequesGift())
                {
                    return(false);
                }
            }
            else
            {
                if (input_tg_tipoPag == TipoPagamento.Cartao)
                {
                    lvc.set_nu_nsuCartao(input_st_cheque);
                }

                cart.set_vr_limiteTotal(cart.get_int_vr_limiteTotal() +
                                        Convert.ToInt64(input_vr_carga));

                if (!cart.synchronize_T_Cartao())
                {
                    return(false);
                }

                cart.ReleaseExclusive();
            }

            lvc.set_vr_carga(input_vr_carga);
            lvc.set_tg_adesao(Context.TRUE);

            if (!lvc.create_LOG_VendaCartaoGift())
            {
                return(false);
            }

            output_id_giftCard = lvc.get_identity();

            LOG_VendaProdutoGift lvpg = new LOG_VendaProdutoGift(this);

            for (int t = 0; t < input_array_generic_prod.Count; ++t)
            {
                DadosProdutoGift dpg = new DadosProdutoGift(input_array_generic_prod[t] as DataPortable);

                lvpg.set_fk_vendaCartao(lvc.get_identity());
                lvpg.set_st_produto(dpg.get_st_nome());
                lvpg.set_vr_valor(dpg.get_vr_valor());

                if (!lvpg.create_LOG_VendaProdutoGift())
                {
                    return(false);
                }
            }

            /// USER [ execute ] END

            Registry("execute done ins_cartaoGift ");

            return(true);
        }