Beispiel #1
0
        private void miTuningLink_Click(object sender, EventArgs e)
        {
            using (frmTuning form = new frmTuning())
            {
                form.cbScreenSize.SelectedIndex = Properties.Settings.Default.ScreenSize;
                form.tbHostName.Text            = BaseServer.Settings.Host;
                form.tbPortNumber.Text          = BaseServer.Settings.Port;
                form.tbUserName.Text            = BaseServer.Settings.User;
                form.tbPassword.Text            = BaseServer.Settings.Password;
                form.tbFetchBase.Text           = BaseServer.Settings.Fetchbase;
                form.tbDatabase.Text            = BaseServer.Settings.Database;
                if (form.ShowDialog() == DialogResult.OK)
                {
                    Properties.Settings settings = Properties.Settings.Default;
                    settings.ScreenSize = form.cbScreenSize.SelectedIndex;
                    settings.Save();
                    if (BaseServer.Settings.Host != form.tbHostName.Text ||
                        BaseServer.Settings.Port != form.tbPortNumber.Text ||
                        BaseServer.Settings.User != form.tbUserName.Text ||
                        BaseServer.Settings.Password != form.tbPassword.Text ||
                        BaseServer.Settings.Fetchbase != form.tbFetchBase.Text ||
                        BaseServer.Settings.Database != form.tbDatabase.Text)
                    {
                        BaseServer.Settings.Host      = form.tbHostName.Text;
                        BaseServer.Settings.Port      = form.tbPortNumber.Text;
                        BaseServer.Settings.User      = form.tbUserName.Text;
                        BaseServer.Settings.Password  = form.tbPassword.Text;
                        BaseServer.Settings.Fetchbase = form.tbFetchBase.Text;
                        BaseServer.Settings.Database  = form.tbDatabase.Text;

                        SaveSettings();

                        Data.RestoreSQLsettings(Application.StartupPath);
                        if (Settings.CreateDataAndFetchBases())
                        {
                            try { DrawPlugin.RestoreImageCatalog(Application.StartupPath + "\\images\\"); }
                            catch (Exception ex)
                            {
                                Data.SendToSystemLog(Properties.Settings.Default.Station, "Картинки",
                                                     "Ошибка: " + ex.Message);
                            }
                            try { DrawPlugin.RestoreReportCatalog(Application.StartupPath + "\\reports\\"); }
                            catch (Exception ex)
                            {
                                Data.SendToSystemLog(Properties.Settings.Default.Station, "Отчёты",
                                                     "Ошибка: " + ex.Message);
                            }

                            Data.LoadBase(PointPlugin.LoadPlugins(Application.StartupPath));
                            MessageBox.Show(this, "Подключение к SQL-серверу успешно восстановлено.",
                                            "Настройка связи с SQL-сервером", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show(this, "Не удалось восстановить подключение к SQL-серверу.\n" +
                                            Settings.LastError,
                                            "Настройка связи с SQL-сервером", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }