// Listagem Widget
        public (List <Aplicativos_Widgets>, WidgetsListConfig) ListarWidget(FormCollection form = null)
        {
            try
            {
                List <Aplicativos_Widgets> list    = new List <Aplicativos_Widgets>();
                WidgetsListConfig          control = new WidgetsListConfig();
                string filter = "";

                // Parametros de pesquisa
                int    page      = 1;
                int    registers = 10;
                string order     = "w.txwidget";
                string direction = "asc";

                // Filtra somente os widgets do aplicativo
                filter += "AND aw.idaplicativo = " + Convert.ToInt32(form["widget_temp_main_id"]) + "";

                // Filtro de resultados
                if (form != null)
                {
                    // Aplicativo
                    if (form.AllKeys.Contains("filter_txaplicativo"))
                    {
                        string filter_txaplicativo = Utils.ClearText(form["filter_txaplicativo"], 20);
                        if (filter_txaplicativo.Length > 0)
                        {
                            filter += "AND a.txaplicativo LIKE '%" + filter_txaplicativo.Replace(" ", "%") + "%' ";
                        }
                    }

                    // Action
                    if (form.AllKeys.Contains("filter_txwidget"))
                    {
                        string filter_txaction = Utils.ClearText(form["filter_txwidget"], 20);
                        if (filter_txaction.Length > 0)
                        {
                            filter += "AND w.txwidget LIKE '%" + filter_txaction.Replace(" ", "%") + "%' ";
                        }
                    }

                    // Variáveis de controle
                    if (form.AllKeys.Contains("widget_temp_page"))
                    {
                        page = Convert.ToInt32(form["widget_temp_page"]);
                    }
                    if (form.AllKeys.Contains("widget_temp_registers"))
                    {
                        registers = Convert.ToInt32(form["widget_temp_registers"]);
                    }
                    if (form.AllKeys.Contains("widget_temp_order"))
                    {
                        order = form["widget_temp_order"];
                    }
                    if (form.AllKeys.Contains("widget_temp_direction"))
                    {
                        direction = form["widget_temp_direction"];
                    }
                }

                // Controle de widget
                control.count     = 0;
                control.registers = registers;
                control.page      = page;
                control.order     = order;
                control.direction = direction;
                control.columns   = new int[13] {
                    0, 0, 16, 0, 16, 8, 8, 8, 8, 8, 12, 8, 8
                };
                control.show = new int[13] {
                    0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0
                };
                control.headers = new string[13] {
                    "289", "229", "230", "265", "267", "262", "263", "231", "232", "294", "291", "292", "293"
                };
                control.orderfields = new string[13] {
                    "aw.idaplicativo_widget", "aw.idaplicativo", "a.txaplicativo", "aw.idwidget", "w.txwidget", "aw.nrxpos", "aw.nrypos", "aw.txaction", "aw.txcontroller", "aw.idcodigoidioma", "aw.txappaction", "aw.txclass", "aw.txmethod"
                };
                control.fields = new string[13] {
                    "idaplicativo_widget", "idaplicativo", "txaplicativo", "idwidget", "txwidget", "nrxpos", "nrypos", "txaction", "txcontroller", "idcodigoidioma", "txappaction", "txclass", "txmethod"
                };
                control.formatFields = new string[13] {
                    "master", "", "", "", "", "", "", "", "", "language", "", "", ""
                };

                // Query
                string qry = "";
                qry += "SELECT COUNT (*) OVER () AS ROW_COUNT, aw.idaplicativo_widget, aw.idaplicativo, a.txaplicativo, aw.idwidget, w.txwidget, aw.nrxpos, aw.nrypos, ";
                qry += "aw.txaction, aw.txcontroller, aw.idcodigoidioma, aw.txappaction, aw.txclass, aw.txmethod ";
                qry += "FROM Aplicativos_Widgets aw ";
                qry += "INNER JOIN Aplicativos a ON a.idaplicativo = aw.idaplicativo ";
                qry += "INNER JOIN Widgets w ON w.idwidget = aw.idwidget ";
                qry += "WHERE 1=1 " + filter;
                qry += "ORDER BY " + Utils.Null(order, "w.txwidget") + " " + direction + " ";
                qry += "OFFSET " + ((page - 1) * registers) + " ROWS FETCH NEXT " + registers + " ROWS ONLY";

                Connection  session = new Connection();
                Query       query   = session.CreateQuery(qry);
                IDataReader reader  = query.ExecuteQuery();

                while (reader.Read())
                {
                    control.count = Convert.ToInt32(reader["ROW_COUNT"]);

                    Aplicativos_Widgets temp = new Aplicativos_Widgets();
                    temp.idaplicativo_widget.value = Convert.ToInt32(reader["idaplicativo_widget"]);
                    temp.idaplicativo.value        = Convert.ToInt32(reader["idaplicativo"]);
                    temp.idwidget.value            = Convert.ToInt32(reader["idwidget"]);
                    temp.nrxpos.value         = Convert.ToInt32(reader["nrxpos"]);
                    temp.nrypos.value         = Convert.ToInt32(reader["nrypos"]);
                    temp.txaction.value       = Convert.ToString(reader["txaction"]);
                    temp.txcontroller.value   = Convert.ToString(reader["txcontroller"]);
                    temp.idcodigoidioma.value = Convert.ToInt32(reader["idcodigoidioma"]);
                    temp.txappaction.value    = Convert.ToString(reader["txappaction"]);
                    temp.txclass.value        = Convert.ToString(reader["txclass"]);
                    temp.txmethod.value       = Convert.ToString(reader["txmethod"]);
                    temp.txwidget.value       = Convert.ToString(reader["txwidget"]);
                    temp.txaplicativo.value   = Convert.ToString(reader["txaplicativo"]);
                    list.Add(temp);
                }

                reader.Close();
                session.Close();

                return(list, control);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Beispiel #2
0
        // Listagem Widget
        public (List <Aplicativos>, WidgetsListConfig) ListarWidget(FormCollection form = null)
        {
            try
            {
                List <Aplicativos> list    = new List <Aplicativos>();
                WidgetsListConfig  control = new WidgetsListConfig();
                string             filter  = "";

                // Parametros de pesquisa
                int    page      = 1;
                int    registers = 10;
                string order     = "a.txaplicativo";
                string direction = "asc";

                // Filtro de resultados
                if (form != null)
                {
                    // Aplicativo
                    if (form.AllKeys.Contains("filter_txaplicativo"))
                    {
                        string filter_txaplicativo = Utils.ClearText(form["filter_txaplicativo"], 20);
                        if (filter_txaplicativo.Length > 0)
                        {
                            filter += "AND a.txaplicativo LIKE '%" + filter_txaplicativo.Replace(" ", "%") + "%' ";
                        }
                    }

                    // Action
                    if (form.AllKeys.Contains("filter_txaction"))
                    {
                        string filter_txaction = Utils.ClearText(form["filter_txaction"], 20);
                        if (filter_txaction.Length > 0)
                        {
                            filter += "AND a.txaction LIKE '%" + filter_txaction.Replace(" ", "%") + "%' ";
                        }
                    }

                    // Controller
                    if (form.AllKeys.Contains("filter_txcontroller"))
                    {
                        string filter_txcontroller = Utils.ClearText(form["filter_txcontroller"], 20);
                        if (filter_txcontroller.Length > 0)
                        {
                            filter += "AND a.txcontroller LIKE '%" + filter_txcontroller.Replace(" ", "%") + "%' ";
                        }
                    }

                    // Variáveis de controle
                    if (form.AllKeys.Contains("widget_temp_page"))
                    {
                        page = Convert.ToInt32(form["widget_temp_page"]);
                    }
                    if (form.AllKeys.Contains("widget_temp_registers"))
                    {
                        registers = Convert.ToInt32(form["widget_temp_registers"]);
                    }
                    if (form.AllKeys.Contains("widget_temp_order"))
                    {
                        order = form["widget_temp_order"];
                    }
                    if (form.AllKeys.Contains("widget_temp_direction"))
                    {
                        direction = form["widget_temp_direction"];
                    }
                }

                // Controle de widget
                control.count     = 0;
                control.registers = registers;
                control.page      = page;
                control.order     = order;
                control.direction = direction;
                control.columns   = new int[9] {
                    0, 28, 12, 12, 0, 12, 12, 12, 12
                };
                control.show = new int[9] {
                    0, 1, 1, 1, 0, 1, 1, 1, 1
                };
                control.headers = new string[9] {
                    "199", "230", "231", "232", "143", "144", "272", "280", "281"
                };
                control.orderfields = new string[9] {
                    "a.idaplicativo", "a.txaplicativo", "a.txaction", "a.txcontroller", "a.idtabela", "t.txtabela", "a.txmainaction", "a.txpasta", "a.flscript"
                };
                control.fields = new string[9] {
                    "idaplicativo", "txaplicativo", "txaction", "txcontroller", "idtabela", "txtabela", "txmainaction", "txpasta", "flscript"
                };
                control.formatFields = new string[9] {
                    "master", "", "", "", "", "", "", "", "boolean"
                };

                // Query
                string qry = "";
                qry += "SELECT COUNT (*) OVER () AS ROW_COUNT, a.idaplicativo, a.txaplicativo, a.txaction, a.txcontroller, a.idtabela, t.txtabela, a.txmainaction, a.txpasta, a.flscript ";
                qry += "FROM Aplicativos a ";
                qry += "LEFT JOIN Tabelas t ON t.idtabela = a.idtabela ";
                qry += "WHERE 1=1 " + filter;
                qry += "ORDER BY " + Utils.Null(order, "a.txaplicativo") + " " + direction + " ";
                qry += "OFFSET " + ((page - 1) * registers) + " ROWS FETCH NEXT " + registers + " ROWS ONLY";

                Connection  session = new Connection();
                Query       query   = session.CreateQuery(qry);
                IDataReader reader  = query.ExecuteQuery();

                while (reader.Read())
                {
                    control.count = Convert.ToInt32(reader["ROW_COUNT"]);

                    Aplicativos temp = new Aplicativos();
                    temp.idaplicativo.value = Convert.ToInt32(reader["idaplicativo"]);
                    temp.txaplicativo.value = Convert.ToString(reader["txaplicativo"]);
                    temp.txaction.value     = Convert.ToString(reader["txaction"]);
                    temp.txcontroller.value = Convert.ToString(reader["txcontroller"]);
                    temp.idtabela.value     = Convert.ToInt32(reader["idtabela"]);
                    temp.txtabela.value     = Convert.ToString(reader["txtabela"]);
                    temp.txmainaction.value = Convert.ToString(reader["txmainaction"]);
                    temp.txpasta.value      = Convert.ToString(reader["txpasta"]);
                    temp.flscript.value     = Convert.ToInt32(reader["flscript"]);
                    list.Add(temp);
                }

                reader.Close();
                session.Close();

                return(list, control);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Beispiel #3
0
        // Listagem
        public (List <Menus>, WidgetsListConfig) ListarWidget(FormCollection form = null)
        {
            try
            {
                List <Menus>      list    = new List <Menus>();
                WidgetsListConfig control = new WidgetsListConfig();
                string            filter  = "";

                // Parametros de pesquisa
                int    page      = 1;
                int    registers = 10;
                string order     = "m.idmenu";
                string direction = "asc";

                // Filtro de resultados
                if (form != null)
                {
                    // Aplicativo
                    if (form.AllKeys.Contains("filter_aplicativo"))
                    {
                        string filter_aplicativo = Utils.ClearText(form["filter_aplicativo"], 50);
                        if (filter_aplicativo.Length > 0)
                        {
                            filter += "AND a.txaplicativo LIKE '%" + filter_aplicativo.Replace(" ", "%") + "%' ";
                        }
                    }

                    // Ativo
                    if (form.AllKeys.Contains("filter_flativo"))
                    {
                        filter += "AND m.flativo = " + Convert.ToInt32(Utils.Null(form["filter_flativo"], "0")) + " ";
                    }

                    // Master
                    if (form.AllKeys.Contains("filter_flmaster"))
                    {
                        filter += "AND m.flmaster = " + Convert.ToInt32(Utils.Null(form["filter_flmaster"], "0")) + " ";
                    }

                    if (form.AllKeys.Contains("widget_temp_page"))
                    {
                        page = Convert.ToInt32(form["widget_temp_page"]);
                    }
                    if (form.AllKeys.Contains("widget_temp_registers"))
                    {
                        registers = Convert.ToInt32(form["widget_temp_registers"]);
                    }
                    if (form.AllKeys.Contains("widget_temp_order"))
                    {
                        order = form["widget_temp_order"];
                    }
                    if (form.AllKeys.Contains("widget_temp_direction"))
                    {
                        direction = form["widget_temp_direction"];
                    }
                }

                // Controle de widget
                control.count     = 0;
                control.registers = registers;
                control.page      = page;
                control.order     = order;
                control.direction = direction;
                control.columns   = new int[8] {
                    0, 20, 20, 20, 10, 10, 10, 10
                };
                control.show = new int[8] {
                    0, 1, 1, 1, 1, 1, 1, 1
                };
                control.headers = new string[8] {
                    "244", "28", "245", "230", "247", "246", "33", "34"
                };
                control.orderfields = new string[8] {
                    "m.idmenu", "m.idcodigoidioma", "m.idmenupai", "a.txaplicativo", "", "m.nrordem", "m.flativo", "m.flmaster"
                };
                control.fields = new string[8] {
                    "idmenu", "idcodigoidioma", "menupai", "aplicativo", "txicone", "nrordem", "flativo", "flmaster"
                };
                control.formatFields = new string[8] {
                    "master", "language", "language", "", "", "", "boolean", "boolean"
                };

                // Query
                string qry = "";
                qry += "SELECT COUNT (*) OVER () AS ROW_COUNT, m.idmenu, m.idcodigoidioma, m.idmenupai, m.idaplicativo, m.txicone, m.nrordem, ";
                qry += "m.flativo, m.flmaster, ISNULL(mp.idcodigoidioma, 0) as idcodigoidioma_pai, a.txaplicativo ";
                qry += "FROM Menus m ";
                qry += "LEFT JOIN menus mp ON mp.idmenu = m.idmenupai ";
                qry += "LEFT JOIN aplicativos a ON a.idaplicativo = m.idaplicativo ";
                qry += "WHERE 1=1 " + filter;
                qry += "ORDER BY " + Utils.Null(order, "m.idmenu") + " " + direction + " ";
                qry += "OFFSET " + ((page - 1) * registers) + " ROWS FETCH NEXT " + registers + " ROWS ONLY";

                Connection  session = new Connection();
                Query       query   = session.CreateQuery(qry);
                IDataReader reader  = query.ExecuteQuery();

                while (reader.Read())
                {
                    control.count = Convert.ToInt32(reader["ROW_COUNT"]);

                    Menus temp = new Menus();
                    temp.idmenu.value         = Convert.ToInt32(reader["idmenu"]);
                    temp.idmenupai.value      = Convert.ToInt32(reader["idmenupai"]);
                    temp.idcodigoidioma.value = Convert.ToInt32(reader["idcodigoidioma"]);
                    temp.idaplicativo.value   = Convert.ToInt32(reader["idaplicativo"]);
                    temp.txicone.value        = Convert.ToString(reader["txicone"]);
                    temp.nrordem.value        = Convert.ToInt32(reader["nrordem"]);
                    temp.flativo.value        = Convert.ToInt32(reader["flativo"]);
                    temp.flmaster.value       = Convert.ToInt32(reader["flmaster"]);
                    temp.menupai.value        = Convert.ToInt32(reader["idcodigoidioma_pai"]);
                    temp.aplicativo.value     = Convert.ToString(reader["txaplicativo"]);
                    temp.menu_nome.value      = Language.XmlLang(Convert.ToInt32(Utils.Null(Convert.ToString(reader["idcodigoidioma"]), "0")), 2).Text;
                    temp.menupai_nome.value   = Language.XmlLang(Convert.ToInt32(Utils.Null(Convert.ToString(reader["idcodigoidioma_pai"]), "0")), 2).Text;
                    list.Add(temp);
                }

                reader.Close();
                session.Close();

                return(list, control);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Beispiel #4
0
        // Listagem
        public (List <Widgets>, WidgetsListConfig) ListarWidget(FormCollection form = null)
        {
            try
            {
                List <Widgets>    list    = new List <Widgets>();
                WidgetsListConfig control = new WidgetsListConfig();
                string            filter  = "";

                // Parametros de pesquisa
                int    page      = 1;
                int    registers = 10;
                string order     = "txwidget";
                string direction = "asc";

                // Filtro de resultados
                if (form != null)
                {
                    // Variáveis de controle
                    if (form.AllKeys.Contains("widget_temp_page"))
                    {
                        page = Convert.ToInt32(form["widget_temp_page"]);
                    }
                    if (form.AllKeys.Contains("widget_temp_registers"))
                    {
                        registers = Convert.ToInt32(form["widget_temp_registers"]);
                    }
                    if (form.AllKeys.Contains("widget_temp_order"))
                    {
                        order = form["widget_temp_order"];
                    }
                    if (form.AllKeys.Contains("widget_temp_direction"))
                    {
                        direction = form["widget_temp_direction"];
                    }
                }

                // Controle de widget
                control.count     = 0;
                control.registers = registers;
                control.page      = page;
                control.order     = order;
                control.direction = direction;
                control.columns   = new int[7] {
                    0, 40, 10, 15, 10, 15, 10
                };
                control.show = new int[7] {
                    0, 1, 1, 1, 1, 1, 1
                };
                control.headers = new string[7] {
                    "199", "264", "257", "259", "258", "260", "261"
                };
                control.orderfields = new string[7] {
                    "idwidget", "txwidget", "nrwidth", "nrminwidth", "nrheight", "nrminheight", "flresize"
                };
                control.fields = new string[7] {
                    "idwidget", "txwidget", "nrwidth", "nrminwidth", "nrheight", "nrminheight", "flresize"
                };
                control.formatFields = new string[7] {
                    "master", "", "", "", "", "", "boolean"
                };

                // Query
                string qry = "";
                qry += "SELECT COUNT (*) OVER () AS ROW_COUNT, idwidget, txwidget, nrwidth, nrminwidth, nrheight, nrminheight, flresize ";
                qry += "FROM Widgets ";
                qry += "WHERE 1=1 " + filter;
                qry += "ORDER BY " + Utils.Null(order, "idwidget") + " " + direction + " ";
                qry += "OFFSET " + ((page - 1) * registers) + " ROWS FETCH NEXT " + registers + " ROWS ONLY";

                Connection  session = new Connection();
                Query       query   = session.CreateQuery(qry);
                IDataReader reader  = query.ExecuteQuery();

                while (reader.Read())
                {
                    control.count = Convert.ToInt32(reader["ROW_COUNT"]);

                    Widgets widgets = new Widgets();
                    widgets.idwidget.value    = Convert.ToInt32(reader["idwidget"]);
                    widgets.txwidget.value    = Convert.ToString(reader["txwidget"]);
                    widgets.nrwidth.value     = Convert.ToInt32(reader["nrwidth"]);
                    widgets.nrheight.value    = Convert.ToInt32(reader["nrheight"]);
                    widgets.nrminwidth.value  = Convert.ToInt32(reader["nrminwidth"]);
                    widgets.nrminheight.value = Convert.ToInt32(reader["nrminheight"]);
                    widgets.flresize.value    = Convert.ToInt32(reader["flresize"]);
                    list.Add(widgets);
                }

                reader.Close();
                session.Close();

                return(list, control);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Beispiel #5
0
        // Listagem
        public (List <Tabelas>, WidgetsListConfig) ListarWidget(FormCollection form = null)
        {
            try
            {
                List <Tabelas>    list    = new List <Tabelas>();
                WidgetsListConfig control = new WidgetsListConfig();
                string            filter  = "";

                // Parametros de pesquisa
                int    page      = 1;
                int    registers = 10;
                string order     = "txtabela";
                string direction = "asc";

                // Filtro de resultados
                if (form != null)
                {
                    if (form.AllKeys.Contains("filter_txtabela"))
                    {
                        string filter_txtabela = Utils.ClearText(form["filter_txtabela"], 50);
                        if (filter_txtabela.Length > 0)
                        {
                            filter += "AND txtabela LIKE '%" + filter_txtabela.Replace(" ", "%") + "%' ";
                        }
                    }

                    if (form.AllKeys.Contains("widget_temp_page"))
                    {
                        page = Convert.ToInt32(form["widget_temp_page"]);
                    }
                    if (form.AllKeys.Contains("widget_temp_registers"))
                    {
                        registers = Convert.ToInt32(form["widget_temp_registers"]);
                    }
                    if (form.AllKeys.Contains("widget_temp_order"))
                    {
                        order = form["widget_temp_order"];
                    }
                    if (form.AllKeys.Contains("widget_temp_direction"))
                    {
                        direction = form["widget_temp_direction"];
                    }
                }

                // Controle de widget
                control.count     = 0;
                control.registers = registers;
                control.page      = page;
                control.order     = order;
                control.direction = direction;
                control.columns   = new int[4] {
                    0, 34, 33, 34
                };
                control.show = new int[4] {
                    0, 1, 1, 1
                };
                control.headers = new string[4] {
                    "199", "144", "141", "139"
                };
                control.orderfields = new string[4] {
                    "idtabela", "txtabela", "flauditoria", "idcodigoidioma"
                };
                control.fields = new string[4] {
                    "idtabela", "txtabela", "flauditoria", "idcodigoidioma"
                };
                control.formatFields = new string[4] {
                    "master", "", "boolean", "language"
                };

                // Query
                string qry = "";
                qry += "SELECT COUNT (*) OVER () AS ROW_COUNT, idtabela, txtabela, flauditoria, idcodigoidioma ";
                qry += "FROM Tabelas ";
                qry += "WHERE 1=1 " + filter;
                qry += "ORDER BY " + Utils.Null(order, "txtabela") + " " + direction + " ";
                qry += "OFFSET " + ((page - 1) * registers) + " ROWS FETCH NEXT " + registers + " ROWS ONLY";

                Connection  session = new Connection();
                Query       query   = session.CreateQuery(qry);
                IDataReader reader  = query.ExecuteQuery();

                while (reader.Read())
                {
                    control.count = Convert.ToInt32(reader["ROW_COUNT"]);

                    Tabelas temp = new Tabelas();
                    temp.idtabela.value       = Convert.ToInt32(reader["idtabela"]);
                    temp.txtabela.value       = Convert.ToString(reader["txtabela"]);
                    temp.flauditoria.value    = Convert.ToInt32(reader["flauditoria"]);
                    temp.idcodigoidioma.value = Convert.ToInt32(reader["idcodigoidioma"]);
                    list.Add(temp);
                }

                reader.Close();
                session.Close();

                return(list, control);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
        // Listagem Widget
        public (List <Aplicativos_Tabs>, WidgetsListConfig) ListarWidget(FormCollection form = null)
        {
            try
            {
                List <Aplicativos_Tabs> list    = new List <Aplicativos_Tabs>();
                WidgetsListConfig       control = new WidgetsListConfig();
                string filter = "";

                // Parametros de pesquisa
                int    page      = 1;
                int    registers = 10;
                string order     = "at.idtab";
                string direction = "asc";

                // Filtra somente os widgets do aplicativo
                filter += "AND aw.idaplicativo = " + Convert.ToInt32(form["widget_temp_main_id"]) + "";

                // Filtro de resultados
                if (form != null)
                {
                    // Variáveis de controle
                    if (form.AllKeys.Contains("widget_temp_page"))
                    {
                        page = Convert.ToInt32(form["widget_temp_page"]);
                    }
                    if (form.AllKeys.Contains("widget_temp_registers"))
                    {
                        registers = Convert.ToInt32(form["widget_temp_registers"]);
                    }
                    if (form.AllKeys.Contains("widget_temp_order"))
                    {
                        order = form["widget_temp_order"];
                    }
                    if (form.AllKeys.Contains("widget_temp_direction"))
                    {
                        direction = form["widget_temp_direction"];
                    }
                }

                // Controle de widget
                control.count     = 0;
                control.registers = registers;
                control.page      = page;
                control.order     = order;
                control.direction = direction;
                control.columns   = new int[8] {
                    0, 0, 20, 20, 20, 10, 20, 10
                };
                control.show = new int[8] {
                    0, 0, 1, 1, 1, 1, 1, 1
                };
                control.headers = new string[8] {
                    "268", "229", "230", "231", "232", "247", "145", "246"
                };
                control.orderfields = new string[8] {
                    "at.idtab", "at.idaplicativo", "a.txaplicativo", "at.txaction", "at.txcontroller", "at.txicone", "at.idcodigoidioma", "at.nrordem"
                };
                control.fields = new string[8] {
                    "idtab", "idaplicativo", "txaplicativo", "txaction", "txcontroller", "txicone", "idcodigoidioma", "nrordem"
                };
                control.formatFields = new string[8] {
                    "master", "", "", "", "", "", "language", ""
                };

                // Query
                string qry = "";
                qry += "SELECT COUNT (*) OVER () AS ROW_COUNT, at.idtab, at.idaplicativo, a.txaplicativo, at.txaction, at.txcontroller, at.txicone, at.idcodigoidioma, at.nrordem ";
                qry += "FROM Aplicativos_Tabs at ";
                qry += "INNER JOIN Aplicativos a ON a.idaplicativo = at.idaplicativo ";
                qry += "WHERE 1=1 " + filter;
                qry += "ORDER BY " + Utils.Null(order, "at.idtab") + " " + direction + " ";
                qry += "OFFSET " + ((page - 1) * registers) + " ROWS FETCH NEXT " + registers + " ROWS ONLY";

                Connection  session = new Connection();
                Query       query   = session.CreateQuery(qry);
                IDataReader reader  = query.ExecuteQuery();

                while (reader.Read())
                {
                    control.count = Convert.ToInt32(reader["ROW_COUNT"]);

                    Aplicativos_Tabs temp = new Aplicativos_Tabs();
                    temp.idtab.value          = Convert.ToInt32(reader["idtab"]);
                    temp.idaplicativo.value   = Convert.ToString(reader["idaplicativo"]);
                    temp.txaction.value       = Convert.ToString(reader["txaction"]);
                    temp.txcontroller.value   = Convert.ToString(reader["txcontroller"]);
                    temp.txicone.value        = Convert.ToString(reader["txicone"]);
                    temp.idcodigoidioma.value = Convert.ToInt32(reader["idcodigoidioma"]);
                    temp.nrordem.value        = Convert.ToInt32(reader["nrordem"]);
                    temp.txaplicativo.value   = Convert.ToString(reader["txaplicativo"]);
                    list.Add(temp);
                }

                reader.Close();
                session.Close();

                return(list, control);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Beispiel #7
0
        // Listagem
        public (List <Modulos>, WidgetsListConfig) ListarWidget(FormCollection form = null)
        {
            try
            {
                List <Modulos>    list    = new List <Modulos>();
                WidgetsListConfig control = new WidgetsListConfig();
                string            filter  = "";

                // Parametros de pesquisa
                int    page      = 1;
                int    registers = 10;
                string order     = "txmodulo";
                string direction = "asc";

                // Filtro de resultados
                if (form != null)
                {
                    if (form.AllKeys.Contains("filter_txmodulo"))
                    {
                        string filter_txmodulo = Utils.ClearText(form["filter_txmodulo"], 50);
                        if (filter_txmodulo.Length > 0)
                        {
                            filter += "AND txmodulo LIKE '%" + filter_txmodulo.Replace(" ", "%") + "%' ";
                        }
                    }

                    if (form.AllKeys.Contains("widget_temp_page"))
                    {
                        page = Convert.ToInt32(form["widget_temp_page"]);
                    }
                    if (form.AllKeys.Contains("widget_temp_registers"))
                    {
                        registers = Convert.ToInt32(form["widget_temp_registers"]);
                    }
                    if (form.AllKeys.Contains("widget_temp_order"))
                    {
                        order = form["widget_temp_order"];
                    }
                    if (form.AllKeys.Contains("widget_temp_direction"))
                    {
                        direction = form["widget_temp_direction"];
                    }
                }

                // Controle de widget
                control.count     = 0;
                control.registers = registers;
                control.page      = page;
                control.order     = order;
                control.direction = direction;
                control.columns   = new int[6] {
                    0, 30, 30, 10, 10, 10
                };
                control.show = new int[6] {
                    0, 1, 1, 1, 1, 1
                };
                control.headers = new string[6] {
                    "244", "255", "230", "254", "147", "148"
                };
                control.orderfields = new string[6] {
                    "m.idmodulo", "m.txmodulo", "a.txaplicativo", "m.flinserir", "m.flalterar", "m.flexcluir"
                };
                control.fields = new string[6] {
                    "idmodulo", "txmodulo", "aplicativo", "flinserir", "flalterar", "flexcluir"
                };
                control.formatFields = new string[6] {
                    "master", "", "", "boolean", "boolean", "boolean"
                };

                // Query
                string qry = "";
                qry += "SELECT COUNT (*) OVER () AS ROW_COUNT, m.idmodulo, m.txmodulo, m.idaplicativo, m.flinserir, m.flalterar, m.flexcluir, a.txaplicativo ";
                qry += "FROM modulos m ";
                qry += "LEFT JOIN aplicativos a ON a.idaplicativo = m.idaplicativo ";
                qry += "WHERE 1=1 " + filter;
                qry += "ORDER BY " + Utils.Null(order, "m.idmodulo") + " " + direction + " ";
                qry += "OFFSET " + ((page - 1) * registers) + " ROWS FETCH NEXT " + registers + " ROWS ONLY";

                Connection  session = new Connection();
                Query       query   = session.CreateQuery(qry);
                IDataReader reader  = query.ExecuteQuery();

                while (reader.Read())
                {
                    control.count = Convert.ToInt32(reader["ROW_COUNT"]);

                    Modulos temp = new Modulos();
                    temp.idmodulo.value     = Convert.ToInt32(reader["idmodulo"]);
                    temp.idaplicativo.value = Convert.ToInt32(reader["idaplicativo"]);
                    temp.txmodulo.value     = Convert.ToString(reader["txmodulo"]);
                    temp.flinserir.value    = Convert.ToInt32(reader["flinserir"]);
                    temp.flalterar.value    = Convert.ToInt32(reader["flalterar"]);
                    temp.flexcluir.value    = Convert.ToInt32(reader["flexcluir"]);
                    temp.aplicativo.value   = Convert.ToString(reader["txaplicativo"]);
                    list.Add(temp);
                }

                reader.Close();
                session.Close();

                return(list, control);
            }
            catch (Exception error)
            {
                throw error;
            }
        }