示例#1
0
        public void call_exec_alteraLoja(string st_csv_empresas, string st_csv_taxas, string st_csv_dias, string st_csv_banco, string st_csv_ag, string st_csv_conta, ref DadosLoja dl, ref CNetHeader header)
        {
            m_Comm.Clear();

            DataPortable send_dp = new DataPortable();

            send_dp.MapTagValue(COMM_IN_EXEC_ALTERALOJA.st_csv_empresas, st_csv_empresas);
            send_dp.MapTagValue(COMM_IN_EXEC_ALTERALOJA.st_csv_taxas, st_csv_taxas);
            send_dp.MapTagValue(COMM_IN_EXEC_ALTERALOJA.st_csv_dias, st_csv_dias);
            send_dp.MapTagValue(COMM_IN_EXEC_ALTERALOJA.st_csv_banco, st_csv_banco);
            send_dp.MapTagValue(COMM_IN_EXEC_ALTERALOJA.st_csv_ag, st_csv_ag);
            send_dp.MapTagValue(COMM_IN_EXEC_ALTERALOJA.st_csv_conta, st_csv_conta);

            m_Comm.AddEntryPortable(ref send_dp);

            DataPortable send_dp_cont_0 = new DataPortable();
            DataPortable send_dp_cont_1 = new DataPortable();

            send_dp_cont_0.MapTagContainer(COMM_IN_EXEC_ALTERALOJA.dl, dl as DataPortable);
            send_dp_cont_1.MapTagContainer(COMM_IN_EXEC_ALTERALOJA.header, header as DataPortable);

            m_Comm.AddEntryPortable(ref send_dp_cont_0);
            m_Comm.AddEntryPortable(ref send_dp_cont_1);
        }
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute fetch_consultaLoja ");

            /// USER [ execute ]

            T_Terminal term = new T_Terminal(this);

            // ## Obtem filtros da entrada

            string nome   = input_cont_dcl.get_st_nome().ToUpper(),
                   cidade = input_cont_dcl.get_st_cidade(),
                   estado = input_cont_dcl.get_st_estado(),
                   codigo = input_cont_dcl.get_st_loja();

            long min_qtd = 0;

            if (input_cont_dcl.get_nu_qtd_term().Length > 0)
            {
                min_qtd = Convert.ToInt32(input_cont_dcl.get_nu_qtd_term());
            }

            long memory = Convert.ToInt64(new InstallData().maxPacket) / 360;

            Hashtable hshLojas = new Hashtable();

            #region - lojas para um determinado administrador -

            if (user.get_tg_nivel() == TipoUsuario.Administrador)
            {
                if (!emp.select_rows_empresa(user.get_st_empresa()))
                {
                    PublishError("CNPJ de empresa inválido");
                    return(false);
                }

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

                LINK_LojaEmpresa lnk = new LINK_LojaEmpresa(this);

                if (lnk.select_fk_empresa_geral(emp.get_identity()))
                {
                    while (lnk.fetch())
                    {
                        hshLojas [lnk.get_fk_loja()] = "*";
                    }
                }
            }

            #endregion

            bool bNome = false;

            if (nome.Length > 0)
            {
                bNome = true;
            }

            bool bCod = false;

            if (codigo.Length > 0)
            {
                bCod = true;
            }

            ArrayList lstSortLojas = new ArrayList();
            Hashtable hshSortLojas = new Hashtable();

            LINK_LojaEmpresa loj_emp_conv = new LINK_LojaEmpresa(this);
            T_Empresa        emp_comp     = new T_Empresa(this);

            // ## Loop diferente para ambos os tipos de consulta
            // ## em um só bloco

            for (;;)
            {
                if (IsEmpresa)
                {
                    // ## Busca do relacionamento loja e empresa

                    if (!loj_emp.fetch())
                    {
                        break;
                    }

                    // ## Se loja não existir, sair

                    if (!loj.selectIdentity(loj_emp.get_fk_loja()))
                    {
                        return(false);
                    }
                }
                else
                {
                    // ## busca proximo registro do select all

                    if (!loj.fetch())
                    {
                        break;
                    }

                    if (hshLojas.Count > 0)
                    {
                        // ##  filtro lojas no caso de admin

                        if (hshLojas [loj.get_identity()] == null)
                        {
                            continue;
                        }
                    }
                }

                // ## Verifica qtd de terminais

                term.select_fk_loja(loj.get_identity());

                if (bCod)
                {
                    if (loj.get_st_loja() != codigo)
                    {
                        continue;
                    }
                }

                if (bNome)
                {
                    if (!loj.get_st_nome().ToUpper().Contains(nome))
                    {
                        if (!loj.get_st_social().ToUpper().Contains(nome))
                        {
                            continue;
                        }
                    }
                }

                if (min_qtd > 0)
                {
                    if (term.GetCount() < min_qtd)
                    {
                        continue;
                    }
                }

                if (cidade.Length > 0)
                {
                    if (!loj.get_st_cidade().Contains(cidade))
                    {
                        continue;
                    }
                }

                if (estado.Length > 0)
                {
                    if (!loj.get_st_estado().Contains(estado))
                    {
                        continue;
                    }
                }

                // ## Copia dados para memória

                DadosLoja dl = new DadosLoja();

                string id_loja = loj.get_st_nome().Trim() + " - " + loj.get_st_social().Trim();

                lstSortLojas.Add(id_loja);

                dl.set_st_loja(loj.get_st_loja());
                dl.set_st_nome(id_loja);
                dl.set_st_cidade(loj.get_st_cidade());
                dl.set_st_estado(loj.get_st_estado());

                dl.set_st_endereco("Tel: " + loj.get_nu_telefone() + " End: " + loj.get_st_endereco());

                dl.set_nu_diasRep(loj_emp.get_nu_dias_repasse());

                string tx = loj_emp.get_tx_admin().PadLeft(3, '0');

                dl.set_nu_pctRep(tx.Insert(tx.Length - 2, ",") + "%");

                string st_terms = " (";

                int terms = 0;

                while (term.fetch())
                {
                    if (term.get_fk_loja() == Context.NOT_SET)
                    {
                        continue;
                    }

                    terms++;

                    st_terms += term.get_nu_terminal().TrimStart('0') + ", ";
                }

                st_terms = terms.ToString() + st_terms.Trim().TrimEnd(',') + ")";

                dl.set_st_obs(st_terms);
                dl.set_nu_CNPJ(loj.get_nu_CNPJ());

                string convs = "";

                if (loj_emp_conv.select_fk_loja(loj.get_identity()))
                {
                    while (loj_emp_conv.fetch())
                    {
                        emp_comp.selectIdentity(loj_emp_conv.get_fk_empresa());

                        convs += emp_comp.get_st_empresa().TrimStart('0') + ",";
                    }
                }

                dl.set_st_convenios(convs.TrimEnd(','));

                hshSortLojas [id_loja] = dl;
            }

            lstSortLojas.Sort();

            StringBuilder sb = new StringBuilder();

            for (int t = 0; t < lstSortLojas.Count; ++t)
            {
                DadosLoja dl = hshSortLojas [lstSortLojas [t]] as DadosLoja;

                DataPortable tmp = dl as DataPortable;

                // ## obtem indexador

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

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

            if (list_ids == "")
            {
                PublishNote("Nenhum resultado foi encontrado");
                return(true);
            }

            DataPortable dp = new DataPortable();

            dp.setValue("ids", list_ids);

            // ## Obtem indexador geral

            output_st_csv_id = MemorySave(ref dp);

            /// USER [ execute ] END

            Registry("execute done fetch_consultaLoja ");

            return(true);
        }
示例#3
0
/// USER [ custom_functions ]
/// USER [ custom_functions ] END

        public bool Item1()
        {
            #region - INPUT VARS -

            transaction.MemoryClean();

            tst_unit.LogTest("exec_alteraLoja Item1", ref m_Log);

            transaction.ut_abort = 0;

            string st_csv_empresas = "";
            string st_csv_taxas    = "";
            string st_csv_dias     = "";
            string st_csv_banco    = "";
            string st_csv_ag       = "";
            string st_csv_conta    = "";

            DadosLoja  dl     = new DadosLoja();
            CNetHeader header = new CNetHeader();

            #endregion

/// USER [ setup_test_1 ]
/// USER [ setup_test_1 ] END

            #region - MAPPING TRANSACTION -

            call_exec_alteraLoja(st_csv_empresas, st_csv_taxas, st_csv_dias, st_csv_banco, st_csv_ag, st_csv_conta, ref dl, ref header);

            if (transaction.setup() == false)
            {
                return(false);
            }

            try
            {
                #endregion

/// USER [ execute_1 ]
/// USER [ execute_1 ] END

                #region - OUTPUT VARS -
            }
            catch (System.Exception se)
            {
                if (se.Message != "ABORT")
                {
                    MessageBox.Show(se.ToString());
                }
            }

            if (transaction.finish() == false)
            {
                return(false);
            }

            transaction.sendObjections(ref my_objections);

            #endregion

/// USER [ validate_1 ]
/// USER [ validate_1 ] END

            return(true);
        }