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);
        }
예제 #2
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_TxtDataIni.AcquireTextBox(i_Form.TxtDataIni, this, event_val_TxtDataIni, dateTextController.FORMAT_DDMMYYYY);

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

                doEvent(event_BuscaDados, null);

                //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.LstLojas.SelectedItems.Count == 0)
                {
                    return(false);
                }

                event_dlgConfFinalRepasse ev_call = new event_dlgConfFinalRepasse(var_util, var_exchange);

                ev_call.header = header;

                ev_call.st_codLoja  = var_util.getSelectedListViewItemTag(i_Form.LstLojas);
                ev_call.st_loja     = i_Form.LstLojas.SelectedItems[0].SubItems[0].Text;
                ev_call.vr_valor    = i_Form.LstLojas.SelectedItems[0].SubItems[1].Text.Replace(",", "");
                ev_call.lstParcelas = hshLojas [ev_call.st_codLoja] as ArrayList;

                ev_call.i_Form.ShowDialog();

                doEvent(event_BuscaDados, null);

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_DetalheCheck -

            case event_DetalheCheck:
            {
                //InitEventCode event_DetalheCheck

                if (i_Form.LstLojas.SelectedItems.Count == 0)
                {
                    return(false);
                }

                string st_loja = var_util.getSelectedListViewItemTag(i_Form.LstLojas);

                ArrayList lstDets = hshLojas [st_loja] as ArrayList;

                long tot_detalhes = 0;

                for (int t = 0; t < i_Form.LstDetalhes.Items.Count; ++t)
                {
                    DadosRepasse dr = lstDets [t] as DadosRepasse;

                    if (i_Form.LstDetalhes.Items[t].Checked)
                    {
                        tot_detalhes += Convert.ToInt64(dr.get_vr_repasse());

                        dr.set_tg_confirmado(Context.TRUE);
                    }
                    else
                    {
                        dr.set_tg_confirmado(Context.FALSE);
                    }
                }

                i_Form.LstLojas.SelectedItems[0].SubItems[1].Text = new money().formatToMoney(tot_detalhes.ToString());

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_val_TxtDataIni -

            case event_val_TxtDataIni:
            {
                //InitEventCode event_val_TxtDataIni

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

                case dateTextController.DATE_VALID:
                {
                    i_Form.TxtDataIni.BackColor     = Color.White;
                    ctrl_TxtDataIni.IsUserValidated = true;

                    if (ctrl_TxtDataIni.GetEnterPressed())
                    {
                        doEvent(event_BuscaDados, null);
                    }
                    break;
                }

                default: break;
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_SelecionaLoja -

            case event_SelecionaLoja:
            {
                //InitEventCode event_SelecionaLoja

                if (i_Form.LstLojas.SelectedItems.Count == 0)
                {
                    return(false);
                }

                string st_loja = var_util.getSelectedListViewItemTag(i_Form.LstLojas);

                ArrayList lstDets = hshLojas [st_loja] as ArrayList;

                i_Form.LstDetalhes.Items.Clear();

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

                    DateTime tim_repasse = Convert.ToDateTime(dr.get_dt_repasse());

                    string dt_rep = var_util.getDDMMYYYY_format(dr.get_dt_repasse()).Substring(0, 10);

                    if (dt_rep == ctrl_TxtDataIni.getTextBoxValue())
                    {
                        dt_rep += " [hoje]";
                    }
                    else if (tim_repasse > ctrl_TxtDataIni.getTextBoxValue_Date())
                    {
                        dt_rep += " [futuro]";
                    }

                    string [] full_row = new string [] { new money().formatToMoney(dr.get_vr_repasse()),
                                                         dr.get_st_cartao(),
                                                         dr.get_st_nsu(),
                                                         var_util.getDDMMYYYY_format(dr.get_dt_trans()),
                                                         dt_rep };



                    if (dt_rep.IndexOf("futuro") >= 0 || dt_rep.IndexOf("hoje") >= 0)
                    {
                        i_Form.LstDetalhes.Items.Add(var_util.GetListViewItem(dr.get_st_nsu(),
                                                                              full_row,
                                                                              Color.Black,
                                                                              Color.Bisque));
                    }
                    else
                    {
                        i_Form.LstDetalhes.Items.Add(var_util.GetListViewItem(dr.get_st_nsu(),
                                                                              full_row));
                    }

                    i_Form.LstDetalhes.Items[t].Checked = false;

                    if (dr.get_tg_confirmado() == Context.TRUE)
                    {
                        i_Form.LstDetalhes.Items[t].Checked = true;
                    }
                }

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_BuscaDados -

            case event_BuscaDados:
            {
                //InitEventCode event_BuscaDados

                string block_detalhe_loja = "";
                string block_sumario_loja = "";

                i_Form.LstLojas.Items.Clear();
                i_Form.LstDetalhes.Items.Clear();

                hshLojas.Clear();

                Application.DoEvents();

                var_exchange.fetch_repasseData(ctrl_TxtDataIni.getTextBoxValue(),
                                               ref header,
                                               ref block_detalhe_loja,
                                               ref block_sumario_loja);

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

                    if (var_exchange.fetch_memory(block_detalhe_loja, "400", ref block_detalhe_loja, ref tmp_memory))
                    {
                        for (int t = 0; t < tmp_memory.Count; ++t)
                        {
                            DadosRepasse dr = new DadosRepasse(tmp_memory[t] as DataPortable);

                            string cod = dr.get_st_loja();

                            if (hshLojas [cod] == null)
                            {
                                hshLojas [cod] = new ArrayList();
                            }

                            ArrayList tmp_list = hshLojas [cod] as ArrayList;

                            string dt_rep = var_util.getDDMMYYYY_format(dr.get_dt_repasse()).Substring(0, 10);

                            DateTime tim_repasse = Convert.ToDateTime(dr.get_dt_repasse());

                            if (dt_rep == ctrl_TxtDataIni.getTextBoxValue())
                            {
                                dr.set_tg_confirmado(Context.FALSE);
                            }
                            else if (tim_repasse > ctrl_TxtDataIni.getTextBoxValue_Date())
                            {
                                dr.set_tg_confirmado(Context.FALSE);
                            }

                            tmp_list.Add(dr);
                        }
                    }
                }

                long vr_repasse = 0;

                ArrayList full_memory = new ArrayList();

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

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

                ArrayList sorted_memory = new ArrayList();

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

                    sorted_memory.Add(dsr.get_vr_valor().PadLeft(20, '0') + dsr.get_st_codLoja().PadRight(20, ' '));
                }

                sorted_memory.Sort();

                for (int g = sorted_memory.Count - 1; g >= 0; --g)
                {
                    string tag = sorted_memory[g].ToString().Substring(20, 20).Trim();

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

                        if (dsr.get_st_codLoja() == tag)
                        {
                            vr_repasse += Convert.ToInt64(dsr.get_vr_valor());

                            string [] full_row = new string [] { dsr.get_st_loja(),
                                                                 new money().formatToMoney(dsr.get_vr_valor()) };

                            i_Form.LstLojas.Items.Add(var_util.GetListViewItem(dsr.get_st_codLoja(), full_row));
                        }
                    }
                }

                i_Form.TxtRepasse.Text = "R$ " + new money().formatToMoney(vr_repasse.ToString());

                //EndEventCode
                return(true);
            }

                #endregion

                #region - event_LstLojasClick -

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

                #endregion

                #region - event_BtnConfirmarClick -

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

                #endregion

                #region - event_ListView1ItemChecked -

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

                #endregion

            default: break;
            }

            return(false);
        }