Пример #1
0
            static void Button(string LastClickedButton)
            {
                int StackPointer = Stack.Add($"UI.Settings.Button({LastClickedButton})");

                if (LastClickedButton == _Buttons["Settings Save"])
                {
                    GlobalStatic.Settings["Listview"]    = string.Format("Width={0};Height={1};", Controls.GetTextBoxText(_TextBox["Settings_Width"]), Controls.GetTextBoxText(_TextBox["Settings_Height"]));
                    GlobalStatic.Settings["Extensions"]  = Controls.GetTextBoxText(_TextBox["Settings_Extensions"]);
                    GlobalStatic.Settings["Deliminator"] = Controls.GetTextBoxText(_TextBox["Settings_Deliminator"]);
                    GlobalStatic.Settings["Language"]    = Language.ISO_LangCode[LDControls.ComboBoxGetSelected(GlobalStatic.ComboBox["Language"]) - 1];
                    GlobalStatic.LanguageCode            = GlobalStatic.Settings["Language"];
                    DBM.Settings.Save();
                    DBM.Settings.Load(GlobalStatic.RestoreSettings, GlobalStatic.SettingsPath);

                    Language.Load(
                        Path.Combine(GlobalStatic.LocalizationFolder, GlobalStatic.LanguageCode + ".xml"),
                        Path.Combine(GlobalStatic.Localization_LanguageCodes_Path, GlobalStatic.LanguageCode + ".txt")
                        );

                    Button(_Buttons["Settings Close"]);
                    Stack.Exit(StackPointer);
                    return;
                }
                else if (LastClickedButton == _Buttons["Settings Close"])
                {
                    Clear();
                    Stack.Exit(StackPointer);
                    return;
                }
            }
Пример #2
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);
        }