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

            Registry("execute exec_validGift ");

            /// USER [ execute ]

            T_Cartao cart = new T_Cartao(this);

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

            if (!cart.select_rows_empresa_matricula(input_st_empresa,
                                                    input_st_matricula))
            {
                PublishError("Cartão não disponível");
                return(false);
            }

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

            ApplicationUtil util = new ApplicationUtil();

            string cod_acesso = util.calculaCodigoAcesso(cart.get_st_empresa(),
                                                         cart.get_st_matricula(),
                                                         cart.get_st_venctoCartao());

            Trace(cod_acesso);

            if (input_st_acesso != cod_acesso)
            {
                PublishError("Código de acesso inválido");
                return(false);
            }

            if (input_tg_recarga == Context.TRUE)
            {
                if (cart.get_fk_dadosProprietario() == Context.NONE)
                {
                    PublishError("Cartão previamente adquirido");
                    return(false);
                }
            }

            /// USER [ execute ] END

            Registry("execute done exec_validGift ");

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

            Registry("execute fetch_cartoes_grafica ");

            /// USER [ execute ]

            StringBuilder sb = new StringBuilder();

            T_Cartao       cart     = new T_Cartao(this);
            T_Cartao       cart_upd = new T_Cartao(this);
            T_Proprietario prot     = new T_Proprietario(this);
            T_Empresa      emp      = new T_Empresa(this);

            ApplicationUtil util = new ApplicationUtil();

            // ## Busca empresa informada

            if (!emp.select_rows_empresa(input_st_empresa))
            {
                PublishError("Empresa inválida");
                return(false);
            }

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

            string nome_empresa = emp.get_st_fantasia().PadRight(25, ' ');

            // ## Busca todos cartões vinculados à empresa

            if (cart.select_rows_empresa(input_st_empresa))
            {
                while (cart.fetch())
                {
                    // ## Se cartão não estiver expedido...

                    if (cart.get_tg_emitido() == StatusExpedicao.NaoExpedido)
                    {
                        DadosExpedicao port = new DadosExpedicao();

                        string line = "+";

                        string nome = "";

                        if (cart.get_tg_tipoCartao() == TipoCartao.presente)
                        {
                            nome = "";
                        }
                        else
                        {
                            if (!prot.selectIdentity(cart.get_fk_dadosProprietario()))
                            {
                                return(false);
                            }

                            nome = prot.get_st_nome();

                            T_Dependente dep_f = new T_Dependente(this);

                            if (dep_f.select_rows_prop_tit(cart.get_fk_dadosProprietario(),
                                                           cart.get_st_titularidade()))
                            {
                                if (dep_f.fetch())
                                {
                                    nome = dep_f.get_st_nome();
                                }
                            }
                        }

                        line += nome + ",";
                        line += cart.get_st_empresa() + ",";
                        line += cart.get_st_matricula() + ",";

                        cart.set_st_venctoCartao(cart.get_st_venctoCartao().PadLeft(4, '0'));

                        line += cart.get_st_venctoCartao().Substring(0, 2) + "/" +
                                cart.get_st_venctoCartao().Substring(2, 2) + ",";

                        if (cart.get_tg_tipoCartao() == TipoCartao.presente)
                        {
                            line += util.calculaCodigoAcesso(cart.get_st_empresa(),
                                                             cart.get_st_matricula(),
                                                             cart.get_st_venctoCartao());
                        }
                        else
                        {
                            line += util.calculaCodigoAcesso(cart.get_st_empresa(),
                                                             cart.get_st_matricula(),
                                                             cart.get_st_titularidade(),
                                                             cart.get_nu_viaCartao(),
                                                             prot.get_st_cpf());
                        }

                        line += ",";
                        line += nome + ",";

                        // # Trilha

                        line += "|";

                        line += "826766" + cart.get_st_empresa() +
                                cart.get_st_matricula() +
                                cart.get_st_titularidade() +
                                cart.get_nu_viaCartao() +
                                "65" + cart.get_st_venctoCartao();

                        line += "|";

                        port.set_st_line(line);

                        // ## Salva em memória

                        DataPortable mem_port = port as DataPortable;

                        sb.Append(MemorySave(ref mem_port));
                        sb.Append(",");

                        // ## Atualiza estado do cartão para 'em expedição'

                        cart_upd.ExclusiveAccess();

                        if (!cart_upd.selectIdentity(cart.get_identity()))
                        {
                            return(false);
                        }

                        cart_upd.set_tg_emitido(StatusExpedicao.EmExpedicao);

                        // ## Atualiza

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

                        cart_upd.ReleaseExclusive();
                    }
                }
            }

            // ## Gera bloco de linhas em um identificador

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

            if (list_ids == "")
            {
                PublishError("Nenhum cartão encontrado para ser expedido à grafica");
                return(false);
            }

            DataPortable dp = new DataPortable();

            dp.setValue("ids", list_ids);

            // ## Copia para saída

            output_st_csv = MemorySave(ref dp);

            /// USER [ execute ] END

            Registry("execute done fetch_cartoes_grafica ");

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

            Registry("execute fetch_comprov_Gift ");

            /// USER [ execute ]

            ArrayList lstContent = new ArrayList();

            ApplicationUtil util = new ApplicationUtil();

            LOG_VendaCartaoGift lvc  = new LOG_VendaCartaoGift(this);
            T_Empresa           emp  = new T_Empresa(this);
            T_Cartao            cart = new T_Cartao(this);
            T_Proprietario      prot = new T_Proprietario(this);

            lvc.ExclusiveAccess();

            if (!lvc.selectIdentity(input_id_gift))
            {
                return(false);
            }

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

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

            if (!prot.selectIdentity(cart.get_fk_dadosProprietario()))
            {
                return(false);
            }

            if (input_tg_reimp == Context.TRUE)
            {
                lstContent.Add("Reimpressão de comprovante de venda giftcard");
                lstContent.Add("");

                DateTime tm = Convert.ToDateTime(lvc.get_dt_compra());

                string data = "Porto Alegre, " + tm.ToLongDateString() + " - " + tm.ToLongTimeString();

                lstContent.Add(data.PadLeft(80, ' '));
            }
            else
            {
                string data = "Porto Alegre, " + DateTime.Now.ToLongDateString() + " - " + DateTime.Now.ToLongTimeString();

                lstContent.Add(data.PadLeft(80, ' '));
            }

            lstContent.Add("");
            lstContent.Add(emp.get_st_social());
            lstContent.Add("GIFTCARD LINDÓIA");

            string num_cart = cart.get_st_empresa() + "." + cart.get_st_matricula() + ".";

            num_cart += util.calculaCodigoAcesso(cart.get_st_empresa(),
                                                 cart.get_st_matricula(),
                                                 cart.get_st_venctoCartao());

            num_cart += ".";
            num_cart += cart.get_st_venctoCartao().PadLeft(4, '0');

            lstContent.Add("Número do cartão: " + num_cart);

            string cod_trans = var_util.DESCript(cart.get_st_matricula() +
                                                 DateTime.Now.Second.ToString().PadLeft(2, '0'),
                                                 "66666666");

            lvc.set_st_codImpresso(cod_trans);

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

            lstContent.Add("Cod. Transação: " + cod_trans);
            lstContent.Add("Cpf do comprador: " + prot.get_st_cpf());
            lstContent.Add("--------------------------------------------");
            lstContent.Add("Valor da carga: R$ " + new money().formatToMoney(lvc.get_vr_carga()));
            lstContent.Add("--------------------------------------------");

            LOG_VendaProdutoGift lvp = new LOG_VendaProdutoGift(this);

            long extras       = 0;
            long total_extras = 0;

            if (lvp.select_fk_venda(input_id_gift))
            {
                extras = lvp.RowCount();
            }

            lstContent.Add("Extras: " + extras.ToString());

            while (lvp.fetch())
            {
                total_extras += lvp.get_int_vr_valor();

                lstContent.Add("-" +
                               lvp.get_st_produto().PadRight(25, ' ') +
                               " R$ " +
                               new money().formatToMoney(lvp.get_vr_valor()));
            }

            lstContent.Add("Total Extras: R$ " + new money().formatToMoney(total_extras.ToString()));

            total_extras += lvc.get_int_vr_carga();

            lstContent.Add("Valor Total: R$ " + new money().formatToMoney(total_extras.ToString()));

            string formPag = "dinheiro";

            if (lvc.get_tg_tipoPag() == TipoPagamento.Cheque)
            {
                formPag = "Cheque (" + lvc.get_st_cheque() + ")";
            }
            else if (lvc.get_tg_tipoPag() == TipoPagamento.Cartao)
            {
                formPag = "Cartão (" + lvc.get_nu_nsuCartao() + ")";
            }

            lstContent.Add("Forma de pagamento: " + formPag);
            lstContent.Add("");
            lstContent.Add("RECEBI O CARTAO GIFTCARD LINDOIA, COMPROMETO-ME A ORIENTAR O");
            lstContent.Add("PRESENTEADO QUANTO AO SEU USO E GUARDA.");
            lstContent.Add("");
            lstContent.Add("_________________________________");
            lstContent.Add(prot.get_st_nome());
            lstContent.Add("");
            lstContent.Add("**Caso o pagamento tenha sido efetuado em cheque, somente estará liberado o uso");
            lstContent.Add("do cartão após a compensação do mesmo");

            for (int t = 0; t < lstContent.Count; ++t)
            {
                DataPortable port = new DataPortable();
                port.setValue("linha", lstContent[t].ToString());
                output_array_generic_lst.Add(port);
            }

            {
                DataPortable port = new DataPortable();
                port.setValue("linha", "");
                output_array_generic_lst.Add(port);
            }


            {
                DataPortable port = new DataPortable();
                port.setValue("linha", "---------------------------------------------------------------");
                output_array_generic_lst.Add(port);
            }


            {
                DataPortable port = new DataPortable();
                port.setValue("linha", "");
                output_array_generic_lst.Add(port);
            }


            for (int t = 0; t < lstContent.Count; ++t)
            {
                DataPortable port = new DataPortable();
                port.setValue("linha", lstContent[t].ToString());
                output_array_generic_lst.Add(port);
            }

            /// USER [ execute ] END

            Registry("execute done fetch_comprov_Gift ");

            return(true);
        }