Ejemplo n.º 1
0
        public override bool doEvent(int event_number, object arg)
        {
            switch (event_number)
            {
                #region - event_Load -

            case event_Load:
            {
                //InitEventCode event_Load

                                        #if ROBOT
                var_util.execDefinedRobot(this, var_alias);
                                        #else
                doEvent(event_Translate, null);
                doEvent(event_FormIsOpening, null);
                                        #endif

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Translate -

            case event_Translate:
            {
                //InitEventCode event_Translate
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_FormIsOpening -

            case event_FormIsOpening:
            {
                //InitEventCode event_FormIsOpening

                ctrl_TxtDtIni.AcquireTextBox(i_Form.TxtDtIni, this, event_val_TxtDtIni, dateTextController.FORMAT_DDMMYYYY);
                ctrl_TxtDtFim.AcquireTextBox(i_Form.TxtDtFim, this, event_val_TxtDtFim, dateTextController.FORMAT_DDMMYYYY);

                ctrl_TxtDtIni.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);
                ctrl_TxtDtFim.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);

                ctrl_TxtDtIni.SetTextBoxText("01" +
                                             DateTime.Now.Month.ToString().PadLeft(2, '0') +
                                             DateTime.Now.Year.ToString().PadLeft(4, '0'));


                ctrl_TxtDtFim.SetTextBoxText("15" +
                                             DateTime.Now.Month.ToString().PadLeft(2, '0') +
                                             DateTime.Now.Year.ToString().PadLeft(4, '0'));


                //EndEventCode
                return(true);
            }

                #endregion

                #region - robot_ShowDialog -

            case robot_ShowDialog:
            {
                //InitEventCode robot_ShowDialog
                //EndEventCode
                return(true);
            }

                #endregion

                #region - robot_CloseDialog -

            case robot_CloseDialog:
            {
                //InitEventCode robot_CloseDialog
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtDtIni -

            case event_val_TxtDtIni:
            {
                //InitEventCode event_val_TxtDtIni

                switch (arg as string)
                {
                case dateTextController.DATE_VALID:
                {
                    i_Form.TxtDtIni.BackColor     = Color.White;
                    ctrl_TxtDtIni.IsUserValidated = true;
                    ctrl_TxtDtIni.CleanError();
                    break;
                }

                case dateTextController.DATE_INVALID:
                {
                    i_Form.TxtDtIni.BackColor     = colorInvalid;
                    ctrl_TxtDtIni.IsUserValidated = false;
                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtDtFim -

            case event_val_TxtDtFim:
            {
                //InitEventCode event_val_TxtDtFim

                switch (arg as string)
                {
                case dateTextController.DATE_VALID:
                {
                    i_Form.TxtDtFim.BackColor     = Color.White;
                    ctrl_TxtDtFim.IsUserValidated = true;
                    ctrl_TxtDtFim.CleanError();
                    break;
                }

                case dateTextController.DATE_INVALID:
                {
                    i_Form.TxtDtFim.BackColor     = colorInvalid;
                    ctrl_TxtDtFim.IsUserValidated = false;
                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Confirmar -

            case event_Confirmar:
            {
                //InitEventCode event_Confirmar

                bool bOk = true;

                if (!ctrl_TxtDtFim.IsUserValidated)
                {
                    ctrl_TxtDtFim.SetErrorMessage("Informe o dia final");
                    bOk = false;
                }

                if (!ctrl_TxtDtIni.IsUserValidated)
                {
                    ctrl_TxtDtIni.SetErrorMessage("Informe o dia inicial");
                    bOk = false;
                }

                if (i_Form.CboRelat.SelectedIndex == -1)
                {
                    MessageBox.Show("Informe a opção de cobrança", "Aviso");
                    bOk = false;
                }

                if (!bOk)
                {
                    return(false);
                }

                i_Form.BtnConfirmar.Enabled = false;

                if (i_Form.CboRelat.SelectedIndex == 0)
                {
                    #region - pendentes com detalhe -

                    // ##############################
                    // # SETUP LISTS ################
                    // ##############################

                    ArrayList lstHeader     = new ArrayList();
                    ArrayList lstContent    = new ArrayList();
                    ArrayList lstTableSizes = new ArrayList();
                    ArrayList lstFooter     = new ArrayList();
                    ArrayList lstMessages   = new ArrayList();
                    ArrayList lstFilters    = new ArrayList();

                    // ##############################
                    // # CUSTOMIZE
                    // ##############################

                    string output_st_total                 = "";
                    string output_st_total_desconto        = "";
                    string output_st_csv_subtotal          = "";
                    string output_st_csv_subtotal_desconto = "";
                    string output_st_content_block         = "";
                    string output_st_emp_loj_block         = "";

                    string output_CartaoAtiv = "";
                    string output_Extras     = "";
                    string output_FixoTrans  = "";
                    string output_Percent    = "";
                    string output_TBM        = "";

                    i_Form.Visible = false;

                    dlgStatus stat = new dlgStatus("Relatório");

                    stat.LblActivity.Text = "Processando relatório no servidor";
                    stat.Show();
                    Application.DoEvents();

                    if (!var_exchange.fetch_rel_6_fat(var_util.GetDataBaseTimeFormat(ctrl_TxtDtIni.getTextBoxValue_Date()),
                                                      var_util.GetDataBaseTimeFormat(ctrl_TxtDtFim.getTextBoxValue_Date().AddDays(1)),
                                                      ref header,
                                                      ref output_st_total,
                                                      ref output_st_total_desconto,
                                                      ref output_st_csv_subtotal,
                                                      ref output_st_csv_subtotal_desconto,
                                                      ref output_st_content_block,
                                                      ref output_st_emp_loj_block,
                                                      ref output_CartaoAtiv,
                                                      ref output_Extras,
                                                      ref output_FixoTrans,
                                                      ref output_Percent,
                                                      ref output_TBM))
                    {
                        stat.Close();
                        return(false);
                    }

                    stat.LblActivity.Text = "Buscando detalhes de faturamento";
                    Application.DoEvents();

                    // index de todos os itens de cobrança
                    Hashtable hsh_Memory = new Hashtable();

                    while (output_st_content_block != "")
                    {
                        ArrayList tmp_memory = new ArrayList();

                        if (var_exchange.fetch_memory(output_st_content_block, "200",
                                                      ref output_st_content_block,
                                                      ref tmp_memory))
                        {
                            for (int t = 0; t < tmp_memory.Count; ++t)
                            {
                                Rel_FAT f_t = new Rel_FAT(tmp_memory [t] as DataPortable);

                                if (hsh_Memory [f_t.get_fk_fatura()] == null)
                                {
                                    hsh_Memory [f_t.get_fk_fatura()] = new ArrayList();
                                }

                                ArrayList tmp = hsh_Memory [f_t.get_fk_fatura()] as ArrayList;

                                tmp.Add(f_t);
                            }
                        }
                    }

                    // lista de todas as empresas e lojas
                    ArrayList full_memory_ent = new ArrayList();

                    stat.LblActivity.Text = "Buscando lista de lojas e empresas";
                    Application.DoEvents();

                    while (output_st_emp_loj_block != "")
                    {
                        ArrayList tmp_memory = new ArrayList();

                        if (var_exchange.fetch_memory(output_st_emp_loj_block, "200",
                                                      ref output_st_emp_loj_block,
                                                      ref tmp_memory))
                        {
                            for (int t = 0; t < tmp_memory.Count; ++t)
                            {
                                Entidade ent = new Entidade(tmp_memory[t] as DataPortable);

                                full_memory_ent.Add(ent);
                            }
                        }
                    }

                    stat.LblActivity.Text = "Gerando relatório para web";
                    Application.DoEvents();

                    stat.pgStatus.Maximum = full_memory_ent.Count;
                    stat.pgStatus.Minimum = 0;

                    money money_helper = new money();

                    // tradução do indice para texto
                    ArrayList desc = new TipoFatDesc().GetArray();

                    // Passa por todas as empresas e lojas
                    for (int g = 0; g < full_memory_ent.Count; ++g)
                    {
                        Entidade ent = full_memory_ent [g] as Entidade;

                        stat.pgStatus.Value = g + 1;

                        Application.DoEvents();

                        // Sub-título
                        lstMessages.Add(ent.get_st_nome());
                        lstTableSizes.Add(500);

                        ArrayList lst_sub_tbl_head = new ArrayList();

                        lst_sub_tbl_head.Add("Descrição de item faturado");
                        lst_sub_tbl_head.Add("Valor Cobrança R$");

                        lstHeader.Add(lst_sub_tbl_head);

                        // Lista de items
                        ArrayList my_cobranca = new ArrayList();

                        // Obtem index da memoria
                        ArrayList lstMemory = hsh_Memory [ent.get_fk_fatura()] as ArrayList;

                        if (lstMemory == null)
                        {
                            my_cobranca.Add(new ArrayList());
                        }
                        else
                        {
                            for (int t = 0; t < lstMemory.Count; ++t)
                            {
                                Rel_FAT f_t = lstMemory [t] as Rel_FAT;

                                // Lista de items para uma linha
                                ArrayList lst_sub_content = new ArrayList();

                                string st_desc = "";
                                string vr_cob  = "";

                                switch (f_t.get_tg_tipoFat())
                                {
                                case TipoFat.Extras:            st_desc = "Extra: " + f_t.get_st_extra();       break;

                                case TipoFat.TBM:                       st_desc = "Tarifa básica mensal";                       break;

                                case TipoFat.CartaoAtiv:        st_desc = "Tarifa por cartões ativos";          break;

                                case TipoFat.FixoTrans:         st_desc = "Valor sobre Transações";             break;

                                case TipoFat.Percent:           st_desc = "Percentual sobre Transações";        break;

                                default: break;
                                }

                                if (f_t.get_tg_desconto() == Context.TRUE)
                                {
                                    vr_cob = "-" + f_t.get_vr_cob();
                                }
                                else
                                {
                                    vr_cob = f_t.get_vr_cob();
                                }

                                lst_sub_content.Add(st_desc);
                                lst_sub_content.Add(money_helper.formatToMoney(vr_cob));

                                my_cobranca.Add(lst_sub_content);
                            }
                        }

                        lstContent.Add(my_cobranca);

                        ArrayList lst_sub_foot = new ArrayList();

                        var_util.indexCSV(output_st_csv_subtotal);
                        lst_sub_foot.Add("Sub-Total: R$ " + money_helper.formatToMoney(var_util.getCSV(g)));

                        var_util.indexCSV(output_st_csv_subtotal_desconto);
                        lst_sub_foot.Add("Sub-Total desconto: R$ " + money_helper.formatToMoney(var_util.getCSV(g)));

                        if (g == full_memory_ent.Count - 1)
                        {
                            lst_sub_foot.Add("");
                            lst_sub_foot.Add("Total de faturamento no período: R$ " + money_helper.formatToMoney(output_st_total));
                            lst_sub_foot.Add("Total em descontos no faturamento no período: R$ " + money_helper.formatToMoney(output_st_total_desconto));
                            lst_sub_foot.Add("");
                            lst_sub_foot.Add("Valor em cartões ativos: " + money_helper.formatToMoney(output_CartaoAtiv));
                            lst_sub_foot.Add("Valor em despesas extras: " + money_helper.formatToMoney(output_Extras));
                            lst_sub_foot.Add("Valor fixo por transações: " + money_helper.formatToMoney(output_FixoTrans));
                            lst_sub_foot.Add("Valor por percentual em transações: " + money_helper.formatToMoney(output_Percent));
                            lst_sub_foot.Add("Valor em mensalidades: " + money_helper.formatToMoney(output_TBM));
                        }

                        lstFooter.Add(lst_sub_foot);
                    }

                    stat.Close();

                    SyCrafReport rel = new SyCrafReport("Relatório de faturamento pendente",
                                                        "RFP",
                                                        "",
                                                        ctrl_TxtDtIni.getTextBoxValue(),
                                                        ctrl_TxtDtFim.getTextBoxValue(),
                                                        ref lstHeader,
                                                        ref lstContent,
                                                        ref lstTableSizes,
                                                        ref lstFooter,
                                                        ref lstMessages,
                                                        ref lstFilters);

                    #endregion
                }
                else
                {
                    #region - pagos -

                    // ##############################
                    // # SETUP LISTS ################
                    // ##############################

                    ArrayList lstHeader     = new ArrayList();
                    ArrayList lstContent    = new ArrayList();
                    ArrayList lstTableSizes = new ArrayList();
                    ArrayList lstFooter     = new ArrayList();
                    ArrayList lstMessages   = new ArrayList();
                    ArrayList lstFilters    = new ArrayList();

                    // ##############################
                    // # CUSTOMIZE
                    // ##############################

                    string output_st_total         = "";
                    string output_st_content_block = "";

                    int sel = i_Form.CboRelat.SelectedIndex;

                    string tg_type = "";
                    string st_rel  = "";

                    switch (sel)
                    {
                    case 1:         tg_type = TipoSitFat.EmCobrança;        st_rel = "Relatório de faturamento em cobrança";                                               break;

                    case 2:         tg_type = TipoSitFat.PagoDoc;           st_rel = "Relatório de faturamento pago com doc";                                              break;

                    case 3:         tg_type = TipoSitFat.PagoCC;            st_rel = "Relatório de faturamento pago em débito em conta";                   break;

                    case 4:         tg_type = TipoSitFat.BaixaCfeInst;      st_rel = "Relatório de faturamento baixado conforme instrução banco";  break;
                    }

                    dlgStatus stat = new dlgStatus("Relatório");

                    stat.LblActivity.Text = "Processando relatório no servidor";
                    stat.Show();
                    Application.DoEvents();

                    if (!var_exchange.fetch_relFat(var_util.GetDataBaseTimeFormat(ctrl_TxtDtIni.getTextBoxValue_Date()),
                                                   var_util.GetDataBaseTimeFormat(ctrl_TxtDtFim.getTextBoxValue_Date().AddDays(1)),
                                                   tg_type,
                                                   ref header,
                                                   ref output_st_total,
                                                   ref output_st_content_block))
                    {
                        stat.Close();
                        i_Form.BtnConfirmar.Enabled = true;
                        return(false);
                    }

                    stat.LblActivity.Text = "Buscando detalhes de faturamento";
                    Application.DoEvents();

                    ArrayList full_memory = new ArrayList();

                    ArrayList sortMem = new ArrayList();

                    while (output_st_content_block != "")
                    {
                        ArrayList tmp_memory = new ArrayList();

                        if (var_exchange.fetch_memory(output_st_content_block, "500",
                                                      ref output_st_content_block,
                                                      ref tmp_memory))
                        {
                            for (int t = 0; t < tmp_memory.Count; ++t)
                            {
                                Rel_FatCompleto tmp = new Rel_FatCompleto(tmp_memory[t] as DataPortable);

                                sortMem.Add(tmp.get_st_nome());

                                full_memory.Add(tmp);
                            }
                        }
                    }

                    sortMem.Sort();

                    stat.LblActivity.Text = "Gerando relatório para web";
                    Application.DoEvents();

                    stat.pgStatus.Maximum = full_memory.Count;
                    stat.pgStatus.Minimum = 0;

                    money money_helper = new money();

                    ArrayList lst_sub_tbl_head = new ArrayList();

                    lst_sub_tbl_head.Add("Empresa/Loja");
                    lst_sub_tbl_head.Add("Cobrança R$");
                    lst_sub_tbl_head.Add("Vencimento");
                    lst_sub_tbl_head.Add("Cód. Banco");
                    lst_sub_tbl_head.Add("Mensagem");
                    lst_sub_tbl_head.Add("Data Baixa");

                    lstHeader.Add(lst_sub_tbl_head);

                    // Sub-título
                    lstMessages.Add("");
                    lstTableSizes.Add(800);

                    ArrayList lst_lines = new ArrayList();

                    for (int g = 0; g < sortMem.Count; ++g)
                    {
                        stat.pgStatus.Value = g + 1;
                        Application.DoEvents();

                        for (int u = 0; u < full_memory.Count; ++u)
                        {
                            Rel_FatCompleto rel = full_memory [u] as Rel_FatCompleto;

                            if (rel.get_st_nome() != sortMem[g].ToString())
                            {
                                continue;
                            }

                            // Lista de items para uma linha
                            ArrayList lst_sub_content = new ArrayList();

                            lst_sub_content.Add(rel.get_st_nome());
                            lst_sub_content.Add(money_helper.formatToMoney(rel.get_vr_cobranca()));
                            lst_sub_content.Add(var_util.getDDMMYYYY_format(rel.get_dt_vencimento()).Substring(0, 10));

                            if (rel.get_dt_baixa() == "")
                            {
                                lst_sub_content.Add("-");
                                lst_sub_content.Add("-");
                                lst_sub_content.Add("-");
                            }
                            else
                            {
                                lst_sub_content.Add(rel.get_cod_retBanco());
                                lst_sub_content.Add(rel.get_st_msgBanco());
                                lst_sub_content.Add(var_util.getDDMMYYYY_format(rel.get_dt_baixa()).Substring(0, 10));
                            }

                            lst_lines.Add(lst_sub_content);

                            if (g == full_memory.Count - 1)
                            {
                                ArrayList lst_sub_foot = new ArrayList();

                                lst_sub_foot.Add("Total contabilizado no período: R$ " +
                                                 money_helper.formatToMoney(output_st_total));

                                lstFooter.Add(lst_sub_foot);
                            }
                        }
                    }

                    lstContent.Add(lst_lines);

                    stat.Close();
                    Application.DoEvents();

                    SyCrafReport relat = new SyCrafReport(st_rel,
                                                          "RFD",
                                                          "Lista completa de empresas e lojas",
                                                          ctrl_TxtDtIni.getTextBoxValue(),
                                                          ctrl_TxtDtFim.getTextBoxValue(),
                                                          ref lstHeader,
                                                          ref lstContent,
                                                          ref lstTableSizes,
                                                          ref lstFooter,
                                                          ref lstMessages,
                                                          ref lstFilters);
                    #endregion
                }

                i_Form.BtnConfirmar.Enabled = true;

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BtnConfirmarClick -

            case event_BtnConfirmarClick:
            {
                //InitEventCode event_BtnConfirmarClick
                //EndEventCode
                return(true);
            }

                #endregion

            default: break;
            }

            return(false);
        }
        public override bool doEvent(int event_number, object arg)
        {
            switch (event_number)
            {
                #region - event_Load -

            case event_Load:
            {
                //InitEventCode event_Load

                                        #if ROBOT
                var_util.execDefinedRobot(this, var_alias);
                                        #else
                doEvent(event_Translate, null);
                doEvent(event_FormIsOpening, null);
                                        #endif

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Translate -

            case event_Translate:
            {
                //InitEventCode event_Translate
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_FormIsOpening -

            case event_FormIsOpening:
            {
                //InitEventCode event_FormIsOpening

                if (header.get_tg_user_type() == TipoUsuario.Lojista)
                {
                    ArrayList lst = new ArrayList();

                    var_exchange.fetch_lojistaEmpresas(header.get_st_empresa(), ref header, ref lst);

                    for (int t = 0; t < lst.Count; ++t)
                    {
                        DadosEmpresa de = new DadosEmpresa(lst[t] as DataPortable);

                        i_Form.LstEmp.Items.Add(de.get_st_empresa() + " " + de.get_st_fantasia());
                    }
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - robot_ShowDialog -

            case robot_ShowDialog:
            {
                //InitEventCode robot_ShowDialog
                //EndEventCode
                return(true);
            }

                #endregion

                #region - robot_CloseDialog -

            case robot_CloseDialog:
            {
                //InitEventCode robot_CloseDialog
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Confirmar -

            case event_Confirmar:
            {
                //InitEventCode event_Confirmar

                if (i_Form.LstEmp.SelectedIndex == -1)
                {
                    return(false);
                }

                string st_empresa = i_Form.LstEmp.SelectedItem.ToString();

                st_empresa = st_empresa.Substring(0, st_empresa.IndexOf(" "));

                // ##############################
                // # SETUP LISTS ################
                // ##############################

                ArrayList lstHeader     = new ArrayList();
                ArrayList lstContent    = new ArrayList();
                ArrayList lstTableSizes = new ArrayList();
                ArrayList lstFooter     = new ArrayList();
                ArrayList lstMessages   = new ArrayList();
                ArrayList lstFilters    = new ArrayList();

                // ##############################
                // # CUSTOMIZE
                // ##############################

                string st_csv_contents = "";

                dlgStatus stat = new dlgStatus("Relatório");

                stat.LblActivity.Text = "Processando relatório no servidor";
                stat.Show();
                Application.DoEvents();

                if (!var_exchange.fetch_rel_prevLojista(st_empresa,
                                                        ref header,
                                                        ref st_csv_contents))
                {
                    stat.Close();
                    return(false);
                }

                ArrayList full_memory = new ArrayList();

                stat.LblActivity.Text = "Buscando detalhes...";
                Application.DoEvents();

                while (st_csv_contents != "")
                {
                    ArrayList tmp_memory = new ArrayList();

                    if (var_exchange.fetch_memory(st_csv_contents, "400", ref st_csv_contents, ref tmp_memory))
                    {
                        for (int t = 0; t < tmp_memory.Count; ++t)
                        {
                            full_memory.Add(tmp_memory[t]);
                        }
                    }
                }

                money money_helper = new money();

                stat.LblActivity.Text = "Gerando relatório para web";
                Application.DoEvents();

                lstMessages.Add("Transações confirmadas para a loja: " + header.get_st_empresa());

                lstTableSizes.Add(650);

                ArrayList lst_sub_tbl_head = new ArrayList();

                lst_sub_tbl_head.Add("Cartão");
                lst_sub_tbl_head.Add("NSU");
                lst_sub_tbl_head.Add("Data e Hora");
                lst_sub_tbl_head.Add("Parcela");
                lst_sub_tbl_head.Add("Valor R$");
                lst_sub_tbl_head.Add("Valor Repasse R$");

                lstHeader.Add(lst_sub_tbl_head);

                long tot_repasse = 0;

                ArrayList my_line_container = new ArrayList();

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

                    ArrayList lst_line_content = new ArrayList();

                    lst_line_content.Add(dr.get_st_cartao());
                    lst_line_content.Add(dr.get_st_nsu());
                    lst_line_content.Add(var_util.getDDMMYYYY_format(dr.get_dt_trans()));
                    lst_line_content.Add(dr.get_id_parcela());
                    lst_line_content.Add(money_helper.formatToMoney(dr.get_vr_total()));
                    lst_line_content.Add(money_helper.formatToMoney(dr.get_vr_repasse()));

                    tot_repasse += Convert.ToInt64(dr.get_vr_repasse());

                    my_line_container.Add(lst_line_content);
                }

                lstContent.Add(my_line_container);

                ArrayList lst_sub_foot = new ArrayList();

                lst_sub_foot.Add("Total de repasse: " + money_helper.formatToMoney(tot_repasse.ToString()));

                lstFooter.Add(lst_sub_foot);

                stat.Close();

                SyCrafReport rel = new SyCrafReport("Relatório de previsão de repasse ao lojista",
                                                    "RPR",
                                                    i_Form.LstEmp.SelectedItem.ToString(),
                                                    var_util.getDDMMYYYY_format(DateTime.Now.ToString()),
                                                    "",
                                                    ref lstHeader,
                                                    ref lstContent,
                                                    ref lstTableSizes,
                                                    ref lstFooter,
                                                    ref lstMessages,
                                                    ref lstFilters);

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BtnConfirmarClick -

            case event_BtnConfirmarClick:
            {
                //InitEventCode event_BtnConfirmarClick
                //EndEventCode
                return(true);
            }

                #endregion

            default: break;
            }

            return(false);
        }
Ejemplo n.º 3
0
        public override bool doEvent(int event_number, object arg)
        {
            switch (event_number)
            {
                #region - event_Load -

            case event_Load:
            {
                //InitEventCode event_Load

                                        #if ROBOT
                var_util.execDefinedRobot(this, var_alias);
                                        #else
                doEvent(event_Translate, null);
                doEvent(event_FormIsOpening, null);
                                        #endif

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Translate -

            case event_Translate:
            {
                //InitEventCode event_Translate
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_FormIsOpening -

            case event_FormIsOpening:
            {
                //InitEventCode event_FormIsOpening

                i_Form.Text += " " + st_cod_empresa.PadLeft(6, '0');

                i_Form.CboReport.SelectedIndex = 0;

                ctrl_TxtMes.AcquireTextBox(i_Form.TxtMes, this, event_val_TxtMes, 2);
                ctrl_TxtAno.AcquireTextBox(i_Form.TxtAno, this, event_val_TxtAno, 4);

                ctrl_TxtMes.SetTextBoxText(DateTime.Now.Month.ToString());
                ctrl_TxtAno.SetTextBoxText(DateTime.Now.Year.ToString());

                ArrayList lst = new ArrayList();

                string nome_emp = "";

                var_exchange.fetch_empresasAfiliadas(st_cod_empresa,
                                                     ref header,
                                                     ref nome_emp,
                                                     ref lst);

                for (int t = 0; t < lst.Count; ++t)
                {
                    DadosEmpresa de = new DadosEmpresa(lst [t] as DataPortable);

                    i_Form.CboAfiliada.Items.Add(de.get_st_empresa());
                }

                if (lst.Count == 0)
                {
                    i_Form.CboAfiliada.Items.Add("");
                }

                i_Form.CboAfiliada.SelectedIndex = 0;

                //EndEventCode
                return(true);
            }

                #endregion

                #region - robot_ShowDialog -

            case robot_ShowDialog:
            {
                //InitEventCode robot_ShowDialog
                //EndEventCode
                return(true);
            }

                #endregion

                #region - robot_CloseDialog -

            case robot_CloseDialog:
            {
                //InitEventCode robot_CloseDialog
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Confirmar -

            case event_Confirmar:
            {
                //InitEventCode event_Confirmar

                if (!ctrl_TxtAno.IsUserValidated && !ctrl_TxtMes.IsUserValidated)
                {
                    return(false);
                }

                switch (i_Form.CboReport.SelectedIndex)
                {
                case 0: doEvent(event_PorEmpresa, null);     break;

                case 1: doEvent(event_PorCartao, null);      break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtMes -

            case event_val_TxtMes:
            {
                //InitEventCode event_val_TxtMes

                if (ctrl_TxtMes.getTextBoxValue() == "" ||
                    ctrl_TxtMes.getTextBoxValue_Long() > 12)
                {
                    i_Form.TxtMes.BackColor     = colorInvalid;
                    ctrl_TxtMes.IsUserValidated = false;
                }
                else
                {
                    i_Form.TxtMes.BackColor     = Color.White;
                    ctrl_TxtMes.IsUserValidated = true;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtAno -

            case event_val_TxtAno:
            {
                //InitEventCode event_val_TxtAno

                if (ctrl_TxtAno.getTextBoxValue().Length < 4)
                {
                    i_Form.TxtAno.BackColor     = colorInvalid;
                    ctrl_TxtAno.IsUserValidated = false;
                }
                else
                {
                    i_Form.TxtAno.BackColor     = Color.White;
                    ctrl_TxtAno.IsUserValidated = true;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_PorEmpresa -

            case event_PorEmpresa:
            {
                //InitEventCode event_PorEmpresa

                // ##############################
                // # SETUP LISTS ################
                // ##############################

                ArrayList lstHeader     = new ArrayList();
                ArrayList lstContent    = new ArrayList();
                ArrayList lstTableSizes = new ArrayList();
                ArrayList lstFooter     = new ArrayList();
                ArrayList lstMessages   = new ArrayList();
                ArrayList lstFilters    = new ArrayList();

                string st_empresa             = "";
                string st_csv_cartao          = "";
                string st_csv_loja            = "";
                string st_csv_loja_content    = "";
                string st_csv_subtotal_loja   = "";
                string st_csv_subtotal_cartao = "";
                string st_csv_cartao_content  = "";
                string st_total = "";

                dlgStatus stat = new dlgStatus("Relatório");

                stat.LblActivity.Text = "Processando relatório no servidor";
                stat.Show();
                Application.DoEvents();

                if (!var_exchange.fetch_rel_3_fech("0",
                                                   ctrl_TxtMes.getTextBoxValue(),
                                                   ctrl_TxtAno.getTextBoxValue(),
                                                   st_cod_empresa,
                                                   i_Form.CboAfiliada.SelectedItem.ToString(),
                                                   ref header,
                                                   ref st_empresa,
                                                   ref st_csv_cartao,
                                                   ref st_csv_loja,
                                                   ref st_csv_loja_content,
                                                   ref st_csv_subtotal_loja,
                                                   ref st_csv_subtotal_cartao,
                                                   ref st_csv_cartao_content,
                                                   ref st_total))
                {
                    stat.Close();
                    return(false);
                }

                money     money_helper = new money();
                Hashtable mem_Lojas    = new Hashtable();

                stat.LblActivity.Text = "Obtendo resultados";

                Application.DoEvents();

                #region Busca todos os registros de todos as lojas
                {
                    ArrayList full_memory = new ArrayList();

                    while (st_csv_loja_content != "")
                    {
                        ArrayList tmp_memory = new ArrayList();

                        if (var_exchange.fetch_memory(st_csv_loja_content, "400", ref st_csv_loja_content, ref tmp_memory))
                        {
                            for (int t = 0; t < tmp_memory.Count; ++t)
                            {
                                full_memory.Add(tmp_memory[t]);
                            }
                        }
                    }

                    for (int t = 0; t < full_memory.Count; ++t)
                    {
                        DadosFechamento df = new DadosFechamento(full_memory[t] as DataPortable);

                        string tmp_loja = df.get_st_loja();

                        if (mem_Lojas [tmp_loja] == null)
                        {
                            mem_Lojas [tmp_loja] = new ArrayList();
                        }

                        ArrayList memoryLoja = mem_Lojas [tmp_loja] as ArrayList;

                        memoryLoja.Add(df);
                    }
                }
                #endregion

                stat.LblActivity.Text = "Gerando relatório para web";

                Application.DoEvents();

                int tot_Lojas = var_util.indexCSV(st_csv_loja);

                long tot_repasse = 0;

                ApplicationUtil var_utilFooter = new ApplicationUtil();

                var_utilFooter.indexCSV(st_csv_subtotal_loja);

                for (int h = 0; h < tot_Lojas; ++h)
                {
                    string loja = var_util.getCSV(h);

                    ArrayList memLojaList = mem_Lojas [loja] as ArrayList;

                    ArrayList lstFooterSub  = new ArrayList();
                    ArrayList lstHeaderSub  = new ArrayList();
                    ArrayList lstContentSub = new ArrayList();

                    lstMessages.Add("Fechamento da loja: " + loja);

                    lstTableSizes.Add(650);

                    lstHeaderSub.Add("NSU");
                    lstHeaderSub.Add("Cartão");
                    lstHeaderSub.Add("Nome");
                    lstHeaderSub.Add("Data e Hora");
                    lstHeaderSub.Add("Valor R$");
                    lstHeaderSub.Add("Parcela");
                    lstHeaderSub.Add("Terminal");

                    long sub_repasse = 0;

                    if (memLojaList != null)
                    {
                        for (int t = 0; t < memLojaList.Count; ++t)
                        {
                            DadosFechamento df = new DadosFechamento(memLojaList[t] as DataPortable);

                            ArrayList lstLine = new ArrayList();

                            lstLine.Add(df.get_st_nsu().PadLeft(6, '0'));
                            lstLine.Add(df.get_st_cartao());
                            lstLine.Add(df.get_st_nome());
                            lstLine.Add(var_util.getDDMMYYYY_format(df.get_dt_trans()));
                            lstLine.Add(money_helper.formatToMoney(df.get_vr_valor()));
                            lstLine.Add(df.get_nu_parcela());
                            lstLine.Add(df.get_st_terminal());

                            sub_repasse += Convert.ToInt64(df.get_vr_repasse());

                            lstContentSub.Add(lstLine);
                        }
                    }

                    lstFooterSub.Add("Sub-Total: " + "R$ " + money_helper.formatToMoney(var_utilFooter.getCSV(h)));
                    lstFooterSub.Add("Sub-Total repasse: " + "R$ " + money_helper.setMoneyFormat(sub_repasse));

                    tot_repasse += sub_repasse;

                    lstHeader.Add(lstHeaderSub);
                    lstFooter.Add(lstFooterSub);
                    lstContent.Add(lstContentSub);

                    if (h == tot_Lojas - 1)
                    {
                        lstFooterSub.Add("");
                        lstFooterSub.Add("Total de vendas nas lojas: " + "R$ " + money_helper.formatToMoney(st_total));
                        lstFooterSub.Add("Total de repasse para lojas: " + "R$ " + money_helper.setMoneyFormat(tot_repasse));
                    }
                }

                stat.Close();

                SyCrafReport rel = new SyCrafReport("Relatório de Fechamento por loja",
                                                    "RFE",
                                                    st_empresa,
                                                    "Mês " + ctrl_TxtMes.getTextBoxValue(),
                                                    "Ano " + ctrl_TxtAno.getTextBoxValue(),
                                                    ref lstHeader,
                                                    ref lstContent,
                                                    ref lstTableSizes,
                                                    ref lstFooter,
                                                    ref lstMessages,
                                                    ref lstFilters);


                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_PorCartao -

            case event_PorCartao:
            {
                //InitEventCode event_PorCartao

                // ##############################
                // # SETUP LISTS ################
                // ##############################

                ArrayList lstHeader     = new ArrayList();
                ArrayList lstContent    = new ArrayList();
                ArrayList lstTableSizes = new ArrayList();
                ArrayList lstFooter     = new ArrayList();
                ArrayList lstMessages   = new ArrayList();
                ArrayList lstFilters    = new ArrayList();

                string st_empresa             = "";
                string st_csv_cartao          = "";
                string st_csv_loja            = "";
                string st_csv_loja_content    = "";
                string st_csv_subtotal_loja   = "";
                string st_csv_subtotal_cartao = "";
                string st_csv_cartao_content  = "";
                string st_total = "";

                dlgStatus stat = new dlgStatus("Relatório");

                stat.LblActivity.Text = "Processando relatório no servidor";
                stat.Show();
                Application.DoEvents();

                if (!var_exchange.fetch_rel_3_fech("1",
                                                   ctrl_TxtMes.getTextBoxValue(),
                                                   ctrl_TxtAno.getTextBoxValue(),
                                                   st_cod_empresa,
                                                   i_Form.CboAfiliada.SelectedItem.ToString(),
                                                   ref header,
                                                   ref st_empresa,
                                                   ref st_csv_cartao,
                                                   ref st_csv_loja,
                                                   ref st_csv_loja_content,
                                                   ref st_csv_subtotal_loja,
                                                   ref st_csv_subtotal_cartao,
                                                   ref st_csv_cartao_content,
                                                   ref st_total))
                {
                    stat.Close();
                    return(false);
                }

                money     money_helper = new money();
                Hashtable mem_Cartoes  = new Hashtable();

                stat.LblActivity.Text = "Obtendo resultados";

                Application.DoEvents();

                #region Busca todos os registros de todos os cartoes
                {
                    ArrayList full_memory = new ArrayList();

                    while (st_csv_cartao_content != "")
                    {
                        ArrayList tmp_memory = new ArrayList();

                        if (var_exchange.fetch_memory(st_csv_cartao_content, "400", ref st_csv_cartao_content, ref tmp_memory))
                        {
                            for (int t = 0; t < tmp_memory.Count; ++t)
                            {
                                full_memory.Add(tmp_memory[t]);
                            }
                        }
                    }

                    for (int t = 0; t < full_memory.Count; ++t)
                    {
                        DadosFechamento df = new DadosFechamento(full_memory[t] as DataPortable);

                        string tmp_cartao = df.get_st_cartao();

                        if (mem_Cartoes [tmp_cartao] == null)
                        {
                            mem_Cartoes [tmp_cartao] = new ArrayList();
                        }

                        ArrayList memoryCart = mem_Cartoes [tmp_cartao] as ArrayList;

                        memoryCart.Add(df);
                    }
                }

                #endregion

                stat.LblActivity.Text = "Gerando relatório para web";

                Application.DoEvents();

                int tot_Cartoes = var_util.indexCSV(st_csv_cartao);

                ApplicationUtil var_utilFooter = new ApplicationUtil();

                var_utilFooter.indexCSV(st_csv_subtotal_cartao);

                for (int h = 0; h < tot_Cartoes; ++h)
                {
                    string cart = var_util.getCSV(h);

                    ArrayList lstFooterSub  = new ArrayList();
                    ArrayList lstHeaderSub  = new ArrayList();
                    ArrayList lstContentSub = new ArrayList();

                    lstMessages.Add("Fechamento do cartão: " + cart);

                    lstTableSizes.Add(800);

                    lstHeaderSub.Add("NSU");
                    lstHeaderSub.Add("Loja");
                    lstHeaderSub.Add("Data e Hora");
                    lstHeaderSub.Add("Valor R$");
                    lstHeaderSub.Add("Parcela");

                    ArrayList memCartList = mem_Cartoes [cart] as ArrayList;

                    if (memCartList != null)
                    {
                        for (int t = 0; t < memCartList.Count; ++t)
                        {
                            DadosFechamento df = new DadosFechamento(memCartList[t] as DataPortable);

                            ArrayList lstLine = new ArrayList();

                            lstLine.Add(df.get_st_nsu().PadLeft(6, '0'));
                            lstLine.Add(df.get_st_loja());
                            lstLine.Add(var_util.getDDMMYYYY_format(df.get_dt_trans()));
                            lstLine.Add(money_helper.formatToMoney(df.get_vr_valor()));
                            lstLine.Add(df.get_nu_parcela());

                            lstContentSub.Add(lstLine);
                        }
                    }

                    lstFooterSub.Add("Sub-Total: R$ " + money_helper.formatToMoney(var_utilFooter.getCSV(h)));

                    lstHeader.Add(lstHeaderSub);
                    lstFooter.Add(lstFooterSub);
                    lstContent.Add(lstContentSub);

                    if (h == tot_Cartoes - 1)
                    {
                        lstFooterSub.Add("");
                        lstFooterSub.Add("Total: " + "R$ " + money_helper.formatToMoney(st_total));
                    }
                }

                stat.Close();

                SyCrafReport rel = new SyCrafReport("Relatório de Fechamento por cartões",
                                                    "RFE",
                                                    st_empresa,
                                                    "Mês : " + ctrl_TxtMes.getTextBoxValue(),
                                                    "Ano : " + ctrl_TxtAno.getTextBoxValue(),
                                                    ref lstHeader,
                                                    ref lstContent,
                                                    ref lstTableSizes,
                                                    ref lstFooter,
                                                    ref lstMessages,
                                                    ref lstFilters);


                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BDF -

            case event_BDF:
            {
                //InitEventCode event_BDF

                if (i_Form.CboReport.SelectedIndex != 1)
                {
                    MessageBox.Show("Geração somente para relatório de cartões", "Aviso");
                    return(false);
                }

                event_dlgDBF_Fechamento ev_call = new event_dlgDBF_Fechamento(var_util, var_exchange);

                ev_call.header = header;

                ev_call.mes            = ctrl_TxtMes.getTextBoxValue();
                ev_call.ano            = ctrl_TxtAno.getTextBoxValue();
                ev_call.st_cod_empresa = st_cod_empresa;

                ev_call.i_Form.ShowDialog();

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BtnConfirmarClick -

            case event_BtnConfirmarClick:
            {
                //InitEventCode event_BtnConfirmarClick
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BtnDBFClick -

            case event_BtnDBFClick:
            {
                //InitEventCode event_BtnDBFClick
                //EndEventCode
                return(true);
            }

                #endregion

            default: break;
            }

            return(false);
        }
Ejemplo n.º 4
0
    public void BuscaDados(DateTime tim)
    {
        RptHist.Visible = false;

        GetConnection();

        string st_cartao = Session["st_cartao"].ToString();
        string st_senha  = Session["st_senha"].ToString();

        ArrayList lst    = new ArrayList();
        ArrayList lstEmp = new ArrayList();

        DadosCartaoEdu dce = new DadosCartaoEdu();

        money mon = new money();

        try
        {
            if (var_exchange.web_fetch_edu_virtual(st_cartao,
                                                   st_senha,
                                                   var_util.ConvertDate(tim),
                                                   ref dce,
                                                   ref lst,
                                                   ref lstEmp))
            {
                if (dce.get_nu_vrRank() != "0")
                {
                    LblAluno.Text = "#" + dce.get_nu_vrRank() + " - " + dce.get_st_aluno();
                }
                else
                {
                    LblAluno.Text = dce.get_st_aluno();
                }

                LblDiaMov.Text = tim.ToLongDateString();

                TxtVrDispVirtual.Text = mon.formatToMoney(dce.get_vr_disp_virtual());
                TxtVrTotalInv.Text    = mon.formatToMoney(dce.get_vr_invest_virtual());

                TxtVrTotal.Text = mon.setMoneyFormat(Convert.ToInt64(dce.get_vr_disp_virtual()) +
                                                     Convert.ToInt64(dce.get_vr_invest_virtual()));

                ArrayList values    = new ArrayList();
                ArrayList valuesEmp = new ArrayList();

                for (int t = 0; t < lstEmp.Count; ++t)
                {
                    DadosMovEmpresaVirtual    dMov = new DadosMovEmpresaVirtual(lstEmp[t] as DataPortable);
                    PositionData_FundoEmpresa bind = new PositionData_FundoEmpresa();

                    bind.nome        = dMov.get_st_nome();
                    bind.acoes       = dMov.get_vr_acoes();
                    bind.osc         = dMov.get_vr_osc();
                    bind.vrdia       = mon.formatToMoney(dMov.get_vr_dia());
                    bind.preco_medio = mon.formatToMoney(dMov.get_vr_preco_medio());

                    bind.invest = (Convert.ToInt64(dMov.get_vr_acoes()) * Convert.ToInt64(dMov.get_vr_dia())).ToString();
                    bind.invest = mon.formatToMoney(bind.invest);

                    bool neg = false;

                    if (bind.osc.IndexOf("-") >= 0)
                    {
                        neg = true;
                    }

                    bind.osc = bind.osc.Replace("-", "");
                    bind.osc = bind.osc.PadLeft(4, '0');

                    int len = bind.osc.Length;

                    if (len == 4)
                    {
                        bind.osc = "0," + bind.osc;
                    }
                    else
                    {
                        bind.osc = bind.osc.Insert(len - 4, ",");
                    }

                    if (neg)
                    {
                        bind.osc = "-" + bind.osc;
                    }

                    bind.osc += "%";

                    if (bind.osc == "0,0000%")
                    {
                        bind.osc = "-";
                    }

                    valuesEmp.Add(bind);
                }

                RptEmpresas.DataSource = valuesEmp;
                RptEmpresas.DataBind();

                RptEmpresas.Visible = true;

                for (int t = 0; t < lst.Count; ++t)
                {
                    DadosMovEmpresaVirtual dMov = new DadosMovEmpresaVirtual(lst[t] as DataPortable);
                    PositionData_MovFundo  bind = new PositionData_MovFundo();

                    bind.nome = dMov.get_st_nome();
                    bind.mov  = dMov.get_vr_mov_fundo();

                    if (bind.mov.IndexOf("-") == -1)
                    {
                        bind.mov = "+" + bind.mov;
                    }

                    bind.total = dMov.get_vr_total();

                    values.Add(bind);
                }

                RptExtrato.DataSource = values;
                RptExtrato.DataBind();

                RptExtrato.Visible = true;
            }

            var_exchange.m_Client.ExitSession();
        }
        catch (System.Exception se)
        {
            if (se.Message == "Exit")
            {
                Session["st_error"]      = "Esgotado tempo de espera no servidor";
                Session["st_error_dest"] = "default.aspx";
                Response.Redirect("error.aspx", true);
            }
        }
    }
Ejemplo n.º 5
0
    protected void BtnConfirmar(object sender, EventArgs e)
    {
        GetConnection();

        money money_helper = new money();

        try
        {
            DateTime t_start = (DateTime)DtIni.SelectedDate;
            DateTime t_end   = (DateTime)DtFim.SelectedDate;

            t_start = new DateTime(t_start.Year, t_start.Month, t_start.Day);

            string st_csv           = "";
            string st_total_periodo = "";

            GetConnection();

            if (!var_exchange.web_fetch_rel_edu_extrato(Session["st_cartao"].ToString(),
                                                        var_util.DESCript(TxtSenha.Value.PadLeft(8, '*'), "12345678"),
                                                        var_util.GetDataBaseTimeFormat((DateTime)t_start),
                                                        var_util.GetDataBaseTimeFormat((DateTime)t_end.AddHours(23).AddMinutes(59).AddSeconds(59)),
                                                        SyCrafEngine.Context.TRUE,
                                                        ref st_csv,
                                                        ref st_total_periodo))
            {
                var_exchange.m_Client.ExitSession();

                Session["st_error"]      = var_exchange.m_Client.GetServerMessage();
                Session["st_error_dest"] = "RespExt.aspx";
                Response.Redirect("error.aspx", true);
                return;
            }

            RptExtrato.Visible = true;
            LblExtrato.Visible = true;

            LblExtrato.Text = "Extrato de atividades do cartão: " + DtIni.SelectedDate.ToShortDateString() + " até " + DtFim.SelectedDate.ToShortDateString();

            ArrayList values = new ArrayList();

            ArrayList desc    = new TipoConfirmacaoDesc().GetArray();
            ArrayList desc_op = new OperacaoCartaoDesc().GetArray();

            while (st_csv != "")
            {
                ArrayList list = new ArrayList();

                var_exchange.fetch_memory(st_csv, "400", ref st_csv, ref list);

                for (int t = 0; t < list.Count; ++t)
                {
                    EduExtrato rel_line = new EduExtrato(list[t] as DataPortable);

                    PositionData_ExtratoEdu bind = new PositionData_ExtratoEdu();

                    bind.nsu      = rel_line.get_st_nsu();
                    bind.data     = var_util.getDDMMYYYY_format(rel_line.get_dt_trans());
                    bind.valor    = money_helper.formatToMoney(rel_line.get_vr_valor());
                    bind.loja     = rel_line.get_st_loja();
                    bind.saldo    = money_helper.formatToMoney(rel_line.get_vr_disp());
                    bind.fundo    = money_helper.formatToMoney(rel_line.get_vr_fundo());
                    bind.operacao = desc_op[Convert.ToInt32(rel_line.get_en_oper())].ToString();

                    values.Add(bind);
                }
            }

            RptExtrato.DataSource = values;
            RptExtrato.DataBind();

            var_exchange.m_Client.ExitSession();
        }
        catch (System.Exception se)
        {
            if (se.Message == "Exit")
            {
                Session["st_error"]      = "Esgotado tempo de espera no servidor";
                Session["st_error_dest"] = "default.aspx";
                Response.Redirect("error.aspx", true);
            }
        }
    }
Ejemplo n.º 6
0
        public override bool doEvent(int event_number, object arg)
        {
            switch (event_number)
            {
                #region - event_Load -

            case event_Load:
            {
                //InitEventCode event_Load

                                        #if ROBOT
                var_util.execDefinedRobot(this, var_alias);
                                        #else
                doEvent(event_Translate, null);
                doEvent(event_FormIsOpening, null);
                                        #endif

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Translate -

            case event_Translate:
            {
                //InitEventCode event_Translate
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_FormIsOpening -

            case event_FormIsOpening:
            {
                //InitEventCode event_FormIsOpening

                ctrl_TxtEmpresa.AcquireTextBox(i_Form.TxtEmpresa, this, event_val_TxtEmpresa, 6);
                ctrl_TxtCartao.AcquireTextBox(i_Form.TxtCartao, this, event_val_TxtCartao, 6);

                ctrl_TxtDiario.AcquireTextBox(i_Form.TxtDiario, this, event_val_TxtDiario, "R$", 8);
                ctrl_TxtMensal.AcquireTextBox(i_Form.TxtMensal, this, event_val_TxtMensal, "R$", 8);
                ctrl_TxtEdu.AcquireTextBox(i_Form.TxtEdu, this, event_val_TxtEdu, "R$", 8);
                ctrl_TxtExtra.AcquireTextBox(i_Form.TxtExtra, this, event_val_TxtExtra, "R$", 8);

                ctrl_TxtDin.AcquireTextBox(i_Form.TxtDin, this, event_val_TxtDin, "R$", 8);

                ctrl_TxtCartao.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);
                ctrl_TxtDiario.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);
                ctrl_TxtMensal.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);
                ctrl_TxtEdu.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);
                ctrl_TxtExtra.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);

                ctrl_TxtDin.SetupErrorProvider(ErrorIconAlignment.MiddleRight, false);

                ctrl_TxtCartao.IsUserValidated = false;

                ctrl_TxtDtIni.AcquireTextBox(i_Form.TxtDtIni, this, event_val_TxtDtIni, dateTextController.FORMAT_DDMMYYYY);
                ctrl_TxtDtFim.AcquireTextBox(i_Form.TxtDtFim, this, event_val_TxtDtFim, dateTextController.FORMAT_DDMMYYYY);

                ctrl_TxtDtIni.SetTextBoxText(DateTime.Now.AddDays(-7).Day.ToString().PadLeft(2, '0') +
                                             DateTime.Now.AddDays(-7).Month.ToString().PadLeft(2, '0') +
                                             DateTime.Now.AddDays(-7).Year.ToString().PadLeft(2, '0'));

                ctrl_TxtDtFim.SetTextBoxText(DateTime.Now.Day.ToString().PadLeft(2, '0') +
                                             DateTime.Now.Month.ToString().PadLeft(2, '0') +
                                             DateTime.Now.Year.ToString().PadLeft(2, '0'));

                if (header.get_tg_user_type() != TipoUsuario.SuperUser &&
                    header.get_tg_user_type() == TipoUsuario.OperadorEdu)
                {
                    i_Form.TxtEmpresa.Text     = header.get_st_empresa();
                    i_Form.TxtEmpresa.ReadOnly = true;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - robot_ShowDialog -

            case robot_ShowDialog:
            {
                //InitEventCode robot_ShowDialog
                //EndEventCode
                return(true);
            }

                #endregion

                #region - robot_CloseDialog -

            case robot_CloseDialog:
            {
                //InitEventCode robot_CloseDialog
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Definir -

            case event_Definir:
            {
                //InitEventCode event_Definir

                if (!ctrl_TxtCartao.IsUserValidated)
                {
                    return(false);
                }

                dlgAutorizacao autor = new dlgAutorizacao();

                autor.ShowDialog();

                Application.DoEvents();

                if (autor.IsConfirmed)
                {
                    var_exchange.exec_edu_alteraDiario(var_util.getMd5Hash(autor.senha),
                                                       ctrl_TxtDiario.getTextBoxValue_NumberStr(),
                                                       ctrl_TxtEmpresa.getTextBoxValue() +
                                                       ctrl_TxtCartao.getTextBoxValue() + "01",
                                                       ref header);
                }

                doEvent(event_BuscaDados, null);

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Pagamento -

            case event_Pagamento:
            {
                //InitEventCode event_Pagamento

                if (!ctrl_TxtCartao.IsUserValidated)
                {
                    return(false);
                }

                dlgAutorizacao autor = new dlgAutorizacao();

                autor.ShowDialog();

                Application.DoEvents();

                if (autor.IsConfirmed)
                {
                    var_exchange.exec_depotEduImediato(var_util.getMd5Hash(autor.senha),
                                                       ctrl_TxtEdu.getTextBoxValue_NumberStr(),
                                                       ctrl_TxtExtra.getTextBoxValue_NumberStr(),
                                                       ctrl_TxtEmpresa.getTextBoxValue(),
                                                       ctrl_TxtCartao.getTextBoxValue(),
                                                       ref header);
                }

                doEvent(event_BuscaDados, null);

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_Vis -

            case event_Vis:
            {
                //InitEventCode event_Vis

                // ##############################
                // # SETUP LISTS ################
                // ##############################

                ArrayList lstHeader     = new ArrayList();
                ArrayList lstContent    = new ArrayList();
                ArrayList lstTableSizes = new ArrayList();
                ArrayList lstFooter     = new ArrayList();
                ArrayList lstMessages   = new ArrayList();
                ArrayList lstFilters    = new ArrayList();

                ArrayList lstFooterSub1  = new ArrayList();
                ArrayList lstHeaderSub1  = new ArrayList();
                ArrayList lstContentSub1 = new ArrayList();

                lstHeader.Add(lstHeaderSub1);
                lstFooter.Add(lstFooterSub1);
                lstContent.Add(lstContentSub1);

                // ##############################
                // # CUSTOMIZE
                // ##############################

                string st_csv           = "";
                string st_empresa       = "";
                string st_total_periodo = "";

                if (!var_exchange.fetch_rel_edu_extrato(var_util.GetDataBaseTimeFormat(ctrl_TxtDtIni.getTextBoxValue_Date()),
                                                        var_util.GetDataBaseTimeFormat(ctrl_TxtDtFim.getTextBoxValue_Date().AddDays(1)),
                                                        ctrl_TxtEmpresa.getTextBoxValue(),
                                                        ctrl_TxtCartao.getTextBoxValue(),
                                                        ref header,
                                                        ref st_csv,
                                                        ref st_empresa,
                                                        ref st_total_periodo))
                {
                    return(false);
                }

                lstMessages.Add("Extrato do aluno: " + i_Form.TxtAluno.Text);

                lstTableSizes.Add(950);

                lstHeaderSub1.Add("NSU");
                lstHeaderSub1.Add("Data");
                lstHeaderSub1.Add("Valor R$");
                lstHeaderSub1.Add("Loja");
                lstHeaderSub1.Add("Saldo R$");
                lstHeaderSub1.Add("Fundo R$");
                lstHeaderSub1.Add("Operação");

                money money_helper = new money();

                ArrayList full_memory = new ArrayList();

                while (st_csv != "")
                {
                    ArrayList tmp_memory = new ArrayList();

                    if (var_exchange.fetch_memory(st_csv, "400", ref st_csv, ref tmp_memory))
                    {
                        for (int t = 0; t < tmp_memory.Count; ++t)
                        {
                            full_memory.Add(tmp_memory[t]);
                        }
                    }
                }

                ArrayList desc    = new TipoConfirmacaoDesc().GetArray();
                ArrayList desc_op = new OperacaoCartaoDesc().GetArray();

                for (int t = 0; t < full_memory.Count; ++t)
                {
                    EduExtrato rel_line = new EduExtrato(full_memory[t] as DataPortable);

                    ArrayList lstLine1 = new ArrayList();

                    lstLine1.Add(rel_line.get_st_nsu());
                    lstLine1.Add(var_util.getDDMMYYYY_format(rel_line.get_dt_trans()));

                    lstLine1.Add(money_helper.formatToMoney(rel_line.get_vr_valor()));

                    lstLine1.Add(rel_line.get_st_loja());
                    lstLine1.Add(money_helper.formatToMoney(rel_line.get_vr_disp()));
                    lstLine1.Add(money_helper.formatToMoney(rel_line.get_vr_fundo()));

                    if (rel_line.get_en_oper() == OperacaoCartao.VENDA_EMPRESARIAL)
                    {
                        lstLine1.Add("Utilização do cartão");
                    }
                    else
                    {
                        lstLine1.Add(desc_op [Convert.ToInt32(rel_line.get_en_oper())].ToString());
                    }

                    lstContentSub1.Add(lstLine1);
                }

                SyCrafReport rel = new SyCrafReport("Extrado de Transações por cartão",
                                                    "ETC",
                                                    st_empresa,
                                                    ctrl_TxtDtIni.getTextBoxValue(),
                                                    ctrl_TxtDtFim.getTextBoxValue(),
                                                    ref lstHeader,
                                                    ref lstContent,
                                                    ref lstTableSizes,
                                                    ref lstFooter,
                                                    ref lstMessages,
                                                    ref lstFilters);

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtCartao -

            case event_val_TxtCartao:
            {
                //InitEventCode event_val_TxtCartao

                switch (arg as string)
                {
                case numberTextController.NUMBER_INCOMPLETE:
                case numberTextController.NUMBER_COMPLETE:
                {
                    if (i_Form.TxtCartao.Text.Length == 6)
                    {
                        i_Form.TxtCartao.BackColor     = Color.White;
                        ctrl_TxtCartao.IsUserValidated = true;
                        ctrl_TxtCartao.CleanError();
                    }
                    else
                    {
                        i_Form.TxtCartao.BackColor     = colorInvalid;
                        ctrl_TxtCartao.IsUserValidated = false;
                    }

                    break;
                }

                default: break;
                }

                if (ctrl_TxtCartao.IsUserValidated)
                {
                    if (ctrl_TxtCartao.GetEnterPressed())
                    {
                        doEvent(event_BuscaDados, null);
                    }
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtDiario -

            case event_val_TxtDiario:
            {
                //InitEventCode event_val_TxtDiario
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtMensal -

            case event_val_TxtMensal:
            {
                //InitEventCode event_val_TxtMensal

                if (!ctrl_TxtCartao.IsUserValidated)
                {
                    return(false);
                }

                long val = ctrl_TxtMensal.getTextBoxValue_Long();

                if (val > 0)
                {
                    ctrl_TxtDiario.SetTextBoxLong(val / 31);
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtEdu -

            case event_val_TxtEdu:
            {
                //InitEventCode event_val_TxtEdu

                if (!ctrl_TxtCartao.IsUserValidated)
                {
                    return(false);
                }

                long val = ctrl_TxtEdu.getTextBoxValue_Long() +
                           ctrl_TxtExtra.getTextBoxValue_Long();

                ctrl_TxtDin.SetTextBoxLong(val);

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtExtra -

            case event_val_TxtExtra:
            {
                //InitEventCode event_val_TxtExtra

                if (!ctrl_TxtCartao.IsUserValidated)
                {
                    return(false);
                }

                long val = ctrl_TxtEdu.getTextBoxValue_Long() +
                           ctrl_TxtExtra.getTextBoxValue_Long();

                ctrl_TxtDin.SetTextBoxLong(val);

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtDoc -

            case event_val_TxtDoc:
            {
                //InitEventCode event_val_TxtDoc

                /*if ( !ctrl_TxtCartao.IsUserValidated )
                 *      return false;
                 *
                 * if ( ctrl_TxtDoc.getTextBoxValue_Long() > 0 )
                 * {
                 *      long diario = ctrl_TxtDoc.getTextBoxValue_Long() / 31;
                 *
                 *      i_Form.rb1.Text =   "Em Fundo Educacional, definindo R$ " +
                 *                                              new money().formatToMoney ( diario.ToString() ) +
                 *                                              " diário";
                 * }
                 */

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BuscaDados -

            case event_BuscaDados:
            {
                //InitEventCode event_BuscaDados

                if (!ctrl_TxtEmpresa.IsUserValidated || !ctrl_TxtCartao.IsUserValidated)
                {
                    return(false);
                }

                DadosCartaoEdu dce = new DadosCartaoEdu();

                if (var_exchange.fetch_dadosAluno(ctrl_TxtEmpresa.getTextBoxValue() +
                                                  ctrl_TxtCartao.getTextBoxValue() +
                                                  "01",
                                                  ref header,
                                                  ref dce))
                {
                    i_Form.TxtAluno.Text = dce.get_st_aluno();

                    ctrl_TxtDiario.SetTextBoxString(dce.get_vr_diario().PadLeft(6, '0'));

                    int diario   = Convert.ToInt32(dce.get_vr_diario());
                    int calc_mes = diario * 31;

                    i_Form.TxtMensal.Text = "R$ " + new money().formatToMoney(calc_mes.ToString());

                    i_Form.TxtVrDisp.Text       = "R$ " + new money().formatToMoney(dce.get_vr_disp());
                    i_Form.TxtVrDispDiario.Text = "R$ " + new money().formatToMoney(diario.ToString());
                    i_Form.TxtVrDispMensal.Text = "R$ " + new money().formatToMoney(calc_mes.ToString());
                    i_Form.TxtSaldoTotal.Text   = "R$ " + new money().formatToMoney(dce.get_vr_depot());

                    DateTime tim = new DateTime(DateTime.Now.Year,
                                                DateTime.Now.Month,
                                                1).AddMonths(1);

                    long dias     = tim.Subtract(DateTime.Now).Days;
                    long prev_mes = dias * diario;

                    i_Form.TxtVrSaldoMes.Text = "R$ " + new money().formatToMoney(prev_mes.ToString());
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtDin -

            case event_val_TxtDin:
            {
                //InitEventCode event_val_TxtDin
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtDtIni -

            case event_val_TxtDtIni:
            {
                //InitEventCode event_val_TxtDtIni

                switch (arg as string)
                {
                case dateTextController.DATE_INVALID:
                {
                    i_Form.TxtDtIni.BackColor     = colorInvalid;
                    ctrl_TxtDtIni.IsUserValidated = false;
                    break;
                }

                case dateTextController.DATE_VALID:
                {
                    i_Form.TxtDtIni.BackColor     = Color.White;
                    ctrl_TxtDtIni.IsUserValidated = true;
                    ctrl_TxtDtIni.CleanError();
                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtDtFim -

            case event_val_TxtDtFim:
            {
                //InitEventCode event_val_TxtDtFim

                switch (arg as string)
                {
                case dateTextController.DATE_INVALID:
                {
                    i_Form.TxtDtFim.BackColor     = colorInvalid;
                    ctrl_TxtDtFim.IsUserValidated = false;
                    break;
                }

                case dateTextController.DATE_VALID:
                {
                    i_Form.TxtDtFim.BackColor     = Color.White;
                    ctrl_TxtDtFim.IsUserValidated = true;
                    ctrl_TxtDtIni.CleanError();
                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtEmpresa -

            case event_val_TxtEmpresa:
            {
                //InitEventCode event_val_TxtEmpresa

                switch (arg as string)
                {
                case numberTextController.NUMBER_INCOMPLETE:
                case numberTextController.NUMBER_COMPLETE:
                {
                    if (i_Form.TxtEmpresa.Text.Length == 6)
                    {
                        i_Form.TxtEmpresa.BackColor     = Color.White;
                        ctrl_TxtEmpresa.IsUserValidated = true;
                        ctrl_TxtEmpresa.CleanError();
                    }
                    else
                    {
                        i_Form.TxtEmpresa.BackColor     = colorInvalid;
                        ctrl_TxtEmpresa.IsUserValidated = false;
                    }

                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BtnAlterarClick -

            case event_BtnAlterarClick:
            {
                //InitEventCode event_BtnAlterarClick
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BtnPagamentoClick -

            case event_BtnPagamentoClick:
            {
                //InitEventCode event_BtnPagamentoClick
                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BtnExtratoClick -

            case event_BtnExtratoClick:
            {
                //InitEventCode event_BtnExtratoClick
                //EndEventCode
                return(true);
            }

                #endregion

            default: break;
            }

            return(false);
        }