예제 #1
0
            static void Database(int Index)
            {
                Tracker.Add(Engines.DB_ShortName[Index - 1]);

                Engines.Load.Sqlite(Engines.DB_Path[Index - 1]);

                Engines.GetSchema(Engines.CurrentDatabase);
                Engines.GetColumnsofTable(Engines.CurrentDatabase, Engines.CurrentTable);

                LDControls.ComboBoxContent(GlobalStatic.ComboBox["FunctionList"], Engines.Functions(Engines.EnginesMode.SQLITE).ToPrimitiveArray());

                Sorts(1);
                Table(1);
                LDControls.ComboBoxSelect(GlobalStatic.ComboBox["Sorts"], 1);
                LDControls.ComboBoxSelect(GlobalStatic.ComboBox["Table"], 1);

                if (GlobalStatic.SortBy == 4)
                {
                    Engines.SetDefaultTable("sqlite_master");
                    Engines.GetColumnsofTable(Engines.CurrentDatabase, Engines.CurrentTable);
                    LDControls.ComboBoxContent(GlobalStatic.ComboBox["Table"], "1=" + Engines.CurrentTable + ";2=sqlite_temp_master;");
                    return;
                }

                Engines.GetColumnsofTable(Engines.CurrentDatabase, Engines.CurrentTable);
                return;
            }
예제 #2
0
파일: DBM.cs 프로젝트: 65001/DBM-CSharp
        public static void DisplayResults()
        {
            int StackPointer = Stack.Add("UI.DisplayResults()");

            LDGraphicsWindow.PauseUpdates();
            //Clears the Dictionary to prevent errors
            _Buttons.Clear();
            _TextBox.Clear();

            /*
             * _CheckBox.Clear();
             * _ComboBox.Clear();
             */

            LDGraphicsWindow.Width  = Desktop.Width;
            LDGraphicsWindow.Height = Desktop.Height;
            GraphicsWindow.Left     = 0;
            GraphicsWindow.Top      = 0;
            GlobalStatic.UIx        = GlobalStatic.Listview_Width + 50;
            DisplayHelper();

            //Sort
            GraphicsWindow.FontSize = GlobalStatic.DefaultFontSize + 1;
            string AscDesc = "1=" + Language.Localization["Asc"] + ";2=" + Language.Localization["Desc"] + ";3=RANDOM();";

            GlobalStatic.ComboBox["Sort"]    = LDControls.AddComboBox(Engines.Schema, 100, 100);
            GlobalStatic.ComboBox["ASCDESC"] = LDControls.AddComboBox(AscDesc, 110, 100);

            _Buttons.AddOrReplace("Sort", Controls.AddButton(Language.Localization["Sort"], GlobalStatic.UIx + 10, 120));

            Controls.Move(GlobalStatic.ComboBox["Sort"], GlobalStatic.UIx + 80, 77);
            Controls.Move(GlobalStatic.ComboBox["ASCDESC"], GlobalStatic.UIx + 190, 77);
            Controls.SetSize(_Buttons["Sort"], 290, 30);

            LDDialogs.ToolTip(_Buttons["Sort"], "Iniates a sort based on user set parameters");                     //Localize
            LDDialogs.ToolTip(GlobalStatic.ComboBox["ASCDESC"], "Sorts Ascending and Decending based on position"); //Localize

            //Search
            GlobalStatic.ComboBox["Search"] = LDControls.AddComboBox(Engines.Schema, 200, 120);
            _TextBox.AddOrReplace("Search", Controls.AddTextBox(GlobalStatic.UIx + 100, 210));
            GlobalStatic.CheckBox["StrictSearch"] = LDControls.AddCheckBox(Language.Localization["Strict Search"]);
            GlobalStatic.CheckBox["InvertSearch"] = LDControls.AddCheckBox(Language.Localization["Invert"]);
            _Buttons.AddOrReplace("Search", Controls.AddButton(Language.Localization["Search"].ToUpper(), GlobalStatic.UIx + 10, 260));

            Controls.Move(GlobalStatic.CheckBox["StrictSearch"], GlobalStatic.UIx + 20, 240);
            Controls.Move(GlobalStatic.CheckBox["InvertSearch"], GlobalStatic.UIx + 150, 240);
            Controls.Move(GlobalStatic.ComboBox["Search"], GlobalStatic.UIx + 100, 180);

            Controls.SetSize(_TextBox["Search"], 200, 25);
            Controls.SetSize(_Buttons["Search"], 290, 30);

            //Functions
            GlobalStatic.ComboBox["FunctionList"] = LDControls.AddComboBox(Engines.Functions(Engines.CurrentEngine).ToPrimitiveArray(), 130, 100);
            GlobalStatic.ComboBox["ColumnList"]   = LDControls.AddComboBox(Engines.Schema, 135, 100);

            Controls.Move(GlobalStatic.ComboBox["FunctionList"], GlobalStatic.UIx + 10, 315);
            Controls.Move(GlobalStatic.ComboBox["ColumnList"], GlobalStatic.UIx + 160, 315);

            _Buttons.AddOrReplace("RunFunction", Controls.AddButton(Language.Localization["Run Function"].ToUpper(), GlobalStatic.UIx + 10, 345));
            Controls.SetSize(_Buttons["RunFunction"], 290, 30);

            //Custom Query
            _TextBox["CustomQuery"] = Controls.AddMultiLineTextBox(GlobalStatic.UIx, 420);
            Controls.SetSize(_TextBox["CustomQuery"], 310, 150);

            _Buttons.AddOrReplace("Query", Controls.AddButton(Language.Localization["Query"].ToUpper(), GlobalStatic.UIx, 580));
            Controls.SetSize(_Buttons["Query"], 310, 30);

            _Buttons.AddOrReplace("Command", Controls.AddButton(Language.Localization["Command"].ToUpper(), GlobalStatic.UIx, 615));

            Controls.SetSize(_Buttons["Command"], 310, 30);
            LDDialogs.ToolTip(_Buttons["Command"], "Executes customized SQL command statements onto the database");                                                      //Localize
            string CustomQueryData = "This Textbox allows you to use Custom\nSQL Queries. Remove this and type in an SQL \nstatement. \nYou also use it to export data"; //Localize

            Controls.SetTextBoxText(_TextBox["CustomQuery"], CustomQueryData);

            //Hide Display Results
            _HideDisplay.Clear();
            _HideDisplay.Add(GlobalStatic.ComboBox["Sort"]);
            _HideDisplay.Add(GlobalStatic.ComboBox["ASCDESC"]);
            _HideDisplay.Add(Buttons["Sort"]);
            _HideDisplay.Add(GlobalStatic.ComboBox["Search"]);
            _HideDisplay.Add(_TextBox["Search"]);
            _HideDisplay.Add(GlobalStatic.CheckBox["StrictSearch"]);
            _HideDisplay.Add(GlobalStatic.CheckBox["InvertSearch"]);
            _HideDisplay.Add(Buttons["Search"]);
            _HideDisplay.Add(GlobalStatic.ComboBox["FunctionList"]);
            _HideDisplay.Add(GlobalStatic.ComboBox["ColumnList"]);
            _HideDisplay.Add(Buttons["RunFunction"]);
            _HideDisplay.Add(_TextBox["CustomQuery"]);
            _HideDisplay.Add(Buttons["Query"]);
            _HideDisplay.Add(Buttons["Command"]);

            LDGraphicsWindow.ResumeUpdates();
            Stack.Exit(StackPointer);
        }
예제 #3
0
        public static void Buttons(string LastButton)
        {
            int StackPointer = Stack.Add($"Handlers.Buttons({LastButton})");

            try
            {
                if (LastButton == UI.Buttons["Search"] || LastButton == UI.Buttons["Sort"] || LastButton == UI.Buttons["RunFunction"])
                {
                    Primitive ASCDESC_Sorts = "1=ASC;2=DESC;3=RANDOM();";
                    bool      Search = false, Sort = true, Function = false;

                    bool.TryParse(LDControls.CheckBoxGetState(GlobalStatic.CheckBox["StrictSearch"]), out bool StrictSearch);
                    bool.TryParse(LDControls.CheckBoxGetState(GlobalStatic.CheckBox["InvertSearch"]), out bool InvertSearch);

                    string SearchIn       = "\"" + Engines.Schema[LDControls.ComboBoxGetSelected(GlobalStatic.ComboBox["Search"])] + "\"";
                    string SearchText     = Controls.GetTextBoxText(UI.TextBox["Search"]).ToString().Replace("'", "''");
                    string FunctionIn     = "\"" + Engines.Schema[LDControls.ComboBoxGetSelected(GlobalStatic.ComboBox["ColumnList"])] + "\"";
                    string FunctionCalled = Engines.Functions(Engines.CurrentEngine)[LDControls.ComboBoxGetSelected(GlobalStatic.ComboBox["FunctionList"]) - 1];

                    string SortBy  = "\"" + Engines.Schema[LDControls.ComboBoxGetSelected(GlobalStatic.ComboBox["Sort"])] + "\"";
                    string ASCDESC = ASCDESC_Sorts[LDControls.ComboBoxGetSelected(GlobalStatic.ComboBox["ASCDESC"])];

                    if (LastButton == UI.Buttons["Search"])
                    {
                        Search = true;
                    }
                    else if (LastButton == UI.Buttons["RunFunction"])
                    {
                        Function = true;
                    }

                    /*
                     * Console.WriteLine();
                     * Console.WriteLine("Search: {0} Sort : {1} Function :{2}", Search, Sort, Function);
                     * Console.WriteLine("Strict Search : {0} Invert Search : {1}", StrictSearch, InvertSearch);
                     * Console.WriteLine("SearchIn : {0} Search Text : {1} FunctionIn : {2} FunctionCalled : {3} SortBy : {4} ASCDESC : {5} LastButton : {6}", SearchIn, SearchText, FunctionIn, FunctionCalled, SortBy, ASCDESC, Controls.GetButtonCaption(LastButton));
                     */
                    var GQS = new Engines.GenerateQuerySettings
                    {
                        //bool
                        Search      = Search,
                        Sort        = Sort,
                        RunFunction = Function,

                        SearchBy = SearchIn,
                        OrderBy  = SortBy,

                        StrictSearch     = StrictSearch,
                        InvertSearch     = InvertSearch,
                        FunctionSelected = FunctionCalled,
                        FunctionColumn   = FunctionIn,
                        SearchText       = SearchText
                    };
                    switch (ASCDESC)
                    {
                    case "ASC":
                        GQS.Order = Engines.GenerateQuerySettings.SortOrder.Ascending;
                        break;

                    case "DESC":
                        GQS.Order = Engines.GenerateQuerySettings.SortOrder.Descding;
                        break;

                    case "RANDOM()":
                        GQS.Order = Engines.GenerateQuerySettings.SortOrder.Random;
                        break;
                    }
                    string Query             = Engines.GenerateQuery(GQS, Engines.CurrentTable.SanitizeFieldName());
                    Engines.QuerySettings QS = new Engines.QuerySettings
                    {
                        Database    = Engines.CurrentDatabase,
                        SQL         = Query,
                        ListView    = GlobalStatic.ListView,
                        User        = GlobalStatic.UserName,
                        Explanation = "Auto Generated Query on behalf of " + GlobalStatic.UserName
                    };

                    Engines.Query(QS);
                }
                else if (LastButton == UI.Buttons["Query"])
                {
                    Engines.Cache.Clear();
                    Engines.QuerySettings QS = new Engines.QuerySettings
                    {
                        Database    = Engines.CurrentDatabase,
                        SQL         = Controls.GetTextBoxText(UI.TextBox["CustomQuery"]),
                        ListView    = GlobalStatic.ListView,
                        User        = GlobalStatic.UserName,
                        Explanation = Language.Localization["User Requested"]
                    };
                    Engines.Query(QS);
                }
                else if (LastButton == UI.Buttons["Command"]) //Custom Command
                {
                    Engines.Cache.Clear();
                    var CS = new Engines.CommandSettings()
                    {
                        Database    = Engines.CurrentDatabase,
                        SQL         = Controls.GetTextBoxText(UI.TextBox["CustomQuery"]),
                        User        = GlobalStatic.UserName,
                        Explanation = Language.Localization["User Requested"]
                    };
                    Engines.Command(CS);
                }
            }
            catch (KeyNotFoundException)
            {
                string Message = Controls.GetButtonCaption(LastButton) + "(" + LastButton + ") |" + UI.Buttons.ContainsKey(LastButton) + "|" + Controls.GetButtonCaption(LastButton) == Language.Localization["Query"].ToUpper() + "| does not exist in context or has not yet implemented.";
                Events.LogMessage(Message, "System");
            }
            Stack.Exit(StackPointer);
        }