示例#1
0
        ///Список SQL запросов.
        private void BtnSQL1Click(object sender, EventArgs e)
        {
            //Добавить.
            if (sender == btnSQL1)
            {
                string FileName = "";
                if (!sys.InputValue("Название запроса", "Введите название запроса:", SizeMode.Small, ValueType.String, ref FileName))
                {
                    return;
                }
                ListBox1.Items.Add(FileName);
                ListSQL.Text           = "";
                ListBox1.SelectedIndex = ListBox1.Items.Count - 1;
            }

            //Удалить.
            if (sender == btnSQL2)
            {
                string FileName = ListBox1.Items[ListBox1.SelectedIndex].ToString();
                string ErrorMes = "";
                if (!FBAFile.FileDelete(FBAPath.PathSettings + FileName + ".txt", out ErrorMes, true))
                {
                    return;
                }
                FBAFile.FileDelete(FBAPath.PathSettings + FileName + "_Result.txt", out ErrorMes, true);
                ListBox1.Items.RemoveAt(ListBox1.SelectedIndex);
            }

            //Сохранить.
            if (sender == btnSQL3)
            {
                if (ListBox1.SelectedIndex == -1)
                {
                    sys.SM("Выберите запрос!");
                    return;
                }
                string FileName = ListBox1.Items[ListBox1.SelectedIndex].ToString();
                FBAFile.FileWriteTextObject(ListSQL, FBAPath.PathSettings + FileName + ".txt", false);
                FBAFile.FileWriteTextObject(ListResult, FBAPath.PathSettings + FileName + "_Result.txt", false);
            }

            //Использовать.
            if (sender == btnSQL4)
            {
                textQuery.Text            = ListSQL.Text;
                tabControl1.SelectedIndex = 1;
            }

            //Тест только парсинг.
            if (sender == btnSQL5)
            {
                RunTest(false, "Test");
            }

            //Тест парсинг и выполнение.
            if (sender == btnSQL6)
            {
                RunTest(true, "Test");
            }

            //Тест парсинг и выполнение.
            if (sender == btnSQL9)
            {
                RunTest(true, "WORK");
            }

            //Переименование.
            if (sender == btnSQL7)
            {
                string     fileName    = ListBox1.Items[ListBox1.SelectedIndex].ToString();
                string     fileSource1 = FBAPath.PathSettings + fileName + ".txt";
                string     fileSource2 = FBAPath.PathSettings + fileName + "_Result.txt";
                const bool showMes     = true;
                string     errorMes    = "";
                if (!sys.InputValue("Новое название запроса", "Введите новое название запроса:", SizeMode.Small, ValueType.String, ref fileName))
                {
                    return;
                }
                string fileDestination1 = FBAPath.PathSettings + fileName + ".txt";
                string fileDestination2 = FBAPath.PathSettings + fileName + "_Result.txt";
                //Переименование файла. FileExists = (Overwrite, Skip, Ask)
                if (File.Exists(fileSource1))
                {
                    if (!FBAFile.FileRename(fileSource1, fileDestination1, FileOverwrite.Ask, showMes, out errorMes))
                    {
                        return;
                    }
                }
                if (File.Exists(fileSource2))
                {
                    if (!FBAFile.FileRename(fileSource2, fileDestination2, FileOverwrite.Ask, showMes, out errorMes))
                    {
                        return;
                    }
                }
                sys.SM("Запрос переименован!", MessageType.Information);
            }

            //Кнопка "Обновить список MSQL запросов".
            if (sender == btnSQL8)
            {
                RefreshFiles();
            }
        }