Exemplo n.º 1
0
 private void tstbGroupCount_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         Properties.Settings settings = Properties.Settings.Default;
         int GroupsCount;
         if (int.TryParse(tstbGroupCount.Text, out GroupsCount))
         {
             if (GroupsCount < 20)
             {
                 GroupsCount         = 20;
                 tstbGroupCount.Text = GroupsCount.ToString();
             }
             else if (GroupsCount > Data.GroupCount(ParamGroupKind))
             {
                 GroupsCount         = Data.GroupCount(ParamGroupKind);
                 tstbGroupCount.Text = GroupsCount.ToString();
             }
             tstbGroupCount.SelectAll();
             if (ParamGroupKind == ParamGroup.Trend)
             {
                 settings.GroupsCount = GroupsCount;
             }
             else
             {
                 settings.TableGroupsCount = GroupsCount;
             }
             settings.Save();
             fillEntityTreeAsync();
         }
     }
 }
Exemplo n.º 2
0
 public static void CheckArguments(params string[] args)
 {
     foreach (string arg in args)
     {
         if (arg.ToLower().StartsWith("-s"))
         {
             int station;
             if (int.TryParse(arg.Substring(2), out station))
             {
                 Properties.Settings settings = Properties.Settings.Default;
                 settings.Station = station;
                 settings.Save();
             }
         }
         else if (arg.ToLower().StartsWith("-r"))
         {
             Properties.Settings settings = Properties.Settings.Default;
             settings.CurrentUser = UnquoteString(arg.Substring(2));
         }
         else if (arg.ToLower().StartsWith("-p"))
         {
             Properties.Settings settings = Properties.Settings.Default;
             settings.CurrentPoint = UnquoteString(arg.Substring(2));
         }
         else if (arg.ToLower().StartsWith("-d"))
         {
             Properties.Settings settings = Properties.Settings.Default;
             settings.CurrentScheme = UnquoteString(arg.Substring(2));
         }
         else if (arg.ToLower().StartsWith("-t"))
         {
             Properties.Settings settings = Properties.Settings.Default;
             settings.CurrentReport = UnquoteString(arg.Substring(2));
         }
         else if (arg.ToLower().StartsWith("-g"))
         {
             int groupno;
             if (int.TryParse(arg.Substring(2), out groupno))
             {
                 Properties.Settings settings = Properties.Settings.Default;
                 settings.CurrentGroup = groupno;
             }
         }
         else if (arg.ToLower().StartsWith("-q"))
         {
             int groupno;
             if (int.TryParse(arg.Substring(2), out groupno))
             {
                 Properties.Settings settings = Properties.Settings.Default;
                 settings.CurrentGroup = groupno;
             }
         }
     }
 }
Exemplo n.º 3
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);
                        }
                    }
                }
            }
        }