private void btnCreate_Click(object sender, EventArgs e) { // создание каналов string logFileName = AppData.AppDirs.LogDir + "ScadaAdminCreateCnls.txt"; bool logCreated; string msg; bool createOK = CreateCnls.CreateChannels(kpInfoList, chkInsertKPName.Checked, logFileName, out logCreated, out msg); if (msg != "") { if (createOK) { ScadaUiUtils.ShowInfo(msg); } else { AppUtils.ProcError(msg); } } if (logCreated) { Process.Start(logFileName); } }
private void miSettingsParams_Click(object sender, EventArgs e) { string oldBaseSdfFile = settings.AppSett.BaseSDFFile; // создание и отображение формы настроек приложения FrmSettings frmSettings = new FrmSettings(); frmSettings.ParamsToControls(settings.AppSett); if (frmSettings.ShowDialog() == DialogResult.OK) { frmSettings.ControlsToParams(settings.AppSett); lblBaseSdfFile.Text = settings.AppSett.BaseSDFFile; string errMsg; if (!settings.SaveAppSettings(out errMsg)) { AppUtils.ProcError(errMsg); } } // повторное соединение с БД, если изменился файл базы конфигурации if (oldBaseSdfFile != settings.AppSett.BaseSDFFile) { PrepareCloseAll(true); bool cancel; winControl.CloseAllForms(out cancel); if (!cancel) { Disconnect(); SetItemsEnabledOnWindowAction(); Connect(true); } } }
private void miSettingsParams_Click(object sender, EventArgs e) { string oldBaseSdfFile = settings.AppSett.BaseSDFFile; // creating and displaying application settings form var frmSettings = new FrmSettings(); frmSettings.ParamsToControls(settings.AppSett); if (frmSettings.ShowDialog() == DialogResult.OK) { frmSettings.ControlsToParams(settings.AppSett); lblBaseSdfFile.Text = settings.AppSett.BaseSDFFile; string errMsg; if (!settings.SaveAppSettings(out errMsg)) { AppUtils.ProcError(errMsg); } } // reconnect to the database if the configuration database file has changed if (oldBaseSdfFile != settings.AppSett.BaseSDFFile) { PrepareCloseAll(true); bool cancel; winControl.CloseAllForms(out cancel); if (!cancel) { Disconnect(); SetItemsEnabledOnWindowAction(); Connect(true); } } }
private void FrmCloneCnls_Shown(object sender, EventArgs e) { // filling in the drop-down list of objects try { var table = Tables.GetObjTable(); table.Rows.Add(-1, AppPhrases.NotReplace); table.Rows.Add(DBNull.Value, AppPhrases.Undefined); cbObj.DataSource = table; cbObj.DisplayMember = "Name"; cbObj.ValueMember = "ObjNum"; cbObj.SelectedValue = -1; } catch (Exception ex) { AppUtils.ProcError(AppPhrases.FillObjListError + ":\r\n" + ex.Message); } // filling the drop-down list of KP try { var table = Tables.GetKPTable(); table.Rows.Add(-1, AppPhrases.NotReplace); table.Rows.Add(DBNull.Value, AppPhrases.Undefined); cbKP.DataSource = table; cbKP.DisplayMember = "Name"; cbKP.ValueMember = "KPNum"; cbKP.SelectedValue = -1; } catch (Exception ex) { AppUtils.ProcError(AppPhrases.FillKPListError + ":\r\n" + ex.Message); } }
/// <summary> /// Загрузить библиотеки КП /// </summary> private void LoadKPDlls() { if (kpViewTypes == null || lastCommDir != commDirs.ExeDir) { lastCommDir = commDirs.ExeDir; kpViewTypes = new Dictionary <string, Type>(); try { DirectoryInfo dirInfo = new DirectoryInfo(commDirs.KPDir); FileInfo[] fileInfoAr = dirInfo.GetFiles("kp*.dll", SearchOption.TopDirectoryOnly); foreach (FileInfo fileInfo in fileInfoAr) { if (!fileInfo.Name.Equals("kp.dll", StringComparison.OrdinalIgnoreCase)) { Type kpViewType; try { kpViewType = KPFactory.GetKPViewType(fileInfo.FullName); } catch { kpViewType = null; } kpViewTypes.Add(fileInfo.Name, kpViewType); } } } catch (Exception ex) { AppUtils.ProcError(AppPhrases.LoadKPDllError + ":\r\n" + ex.Message); } } }
private void bindingNavigatorRefreshItem_Click(object sender, EventArgs e) { if (UpdateTable()) { Table.RowChanged -= dataTable_RowChanged; Table.RowDeleted -= dataTable_RowDeleted; bindingSource.DataSource = null; // для ускорения изменения данных в таблице try { // обновление редактируемой таблицы Table.Clear(); SqlCeDataAdapter adapter = Table.ExtendedProperties["DataAdapter"] as SqlCeDataAdapter; adapter.Fill(Table); Table.BeginLoadData(); // обновление таблиц, которые являются источниками данных для значений ячеек foreach (DataGridViewColumn col in dataGridView.Columns) { DataGridViewComboBoxColumn cbCol = col as DataGridViewComboBoxColumn; if (cbCol != null) { DataTable tbl = cbCol.DataSource as DataTable; if (tbl != null) { bool emtyRowExists = tbl.DefaultView.Find(DBNull.Value) >= 0; tbl.Clear(); adapter = tbl.ExtendedProperties["DataAdapter"] as SqlCeDataAdapter; adapter.Fill(tbl); if (emtyRowExists) { tbl.BeginLoadData(); tbl.Rows.Add(DBNull.Value, " "); } } } } } catch (Exception ex) { AppUtils.ProcError(AppPhrases.RefreshDataError + ":\r\n" + ex.Message); } Table.RowChanged += dataTable_RowChanged; Table.RowDeleted += dataTable_RowDeleted; bindingSource.DataSource = Table; bindingSource.ResetBindings(false); SetModified(WinInfo.Modified); // установка доступности кнопок } }
private void btnImport_Click(object sender, EventArgs e) { // import selected table from dat format if (AppData.Connected) { var selItem = cbTable.SelectedItem; string logFileName = AppData.AppDirs.LogDir + "ScadaAdminImport.txt"; bool importOK; bool logCreated; string msg; if (selItem is ImportAllTablesItem) { // import all tables from a directory importOK = ImportExport.ImportAllTables(txtFileName.Text, Tables.TableInfoList, logFileName, out logCreated, out msg); } else if (selItem is ImportArchiveItem) { // import archive importOK = ImportExport.ImportArchive(txtFileName.Text, Tables.TableInfoList, logFileName, out logCreated, out msg); } else { // import table var tableInfo = (Tables.TableInfo)selItem; int minID = gbIDs.Enabled && chkStartID.Checked ? Convert.ToInt32(numStartID.Value) : 0; int maxID = gbIDs.Enabled && chkFinalID.Checked ? Convert.ToInt32(numFinalID.Value) : int.MaxValue; int newMinID = gbIDs.Enabled && chkNewStartID.Checked ? Convert.ToInt32(numNewStartID.Value) : 0; importOK = ImportExport.ImportTable(txtFileName.Text, tableInfo, minID, maxID, newMinID, logFileName, out logCreated, out msg); } // display of the result message if (importOK) { ScadaUiUtils.ShowInfo(msg); } else { AppUtils.ProcError(msg); // log display in notebook if (logCreated) { Process.Start(logFileName); } } } }
private void btnImport_Click(object sender, EventArgs e) { // импорт выбранной таблицы из формата DAT if (AppData.Connected) { object selItem = cbTable.SelectedItem; string logFileName = AppData.AppDirs.LogDir + "ScadaAdminImport.txt"; bool importOK; bool logCreated; string msg; if (selItem is ImportAllTablesItem) { // импорт всех таблиц из директории importOK = ImportExport.ImportAllTables(txtFileName.Text, Tables.TableInfoList, logFileName, out logCreated, out msg); } else if (selItem is ImportArchiveItem) { // импорт архива importOK = ImportExport.ImportArchive(txtFileName.Text, Tables.TableInfoList, logFileName, out logCreated, out msg); } else { // импорт таблицы Tables.TableInfo tableInfo = (Tables.TableInfo)selItem; int minID = gbIDs.Enabled && chkStartID.Checked ? Convert.ToInt32(numStartID.Value) : 0; int maxID = gbIDs.Enabled && chkFinalID.Checked ? Convert.ToInt32(numFinalID.Value) : int.MaxValue; int newMinID = gbIDs.Enabled && chkNewStartID.Checked ? Convert.ToInt32(numNewStartID.Value) : 0; importOK = ImportExport.ImportTable(txtFileName.Text, tableInfo, minID, maxID, newMinID, logFileName, out logCreated, out msg); } // отображение сообщения о результате if (importOK) { ScadaUiUtils.ShowInfo(msg); } else { AppUtils.ProcError(msg); // отображение журнала в блокноте if (logCreated) { Process.Start(logFileName); } } } }
private void miDbBackup_Click(object sender, EventArgs e) { // резервное копирование файла базы конфигурации string msg; if (ImportExport.BackupSDF(settings.AppSett.BaseSDFFile, settings.AppSett.BackupDir, out msg)) { ScadaUiUtils.ShowInfo(msg); } else { AppUtils.ProcError(msg); } }
private void miDbBackup_Click(object sender, EventArgs e) { // backup configuration database file string msg; if (ImportExport.BackupSDF(settings.AppSett.BaseSDFFile, settings.AppSett.BackupDir, out msg)) { ScadaUiUtils.ShowInfo(msg); } else { AppUtils.ProcError(msg); } }
/// <summary> /// Заполнить таблицу КП /// </summary> private void FillKPGrid() { try { DataTable tblObj = Tables.GetObjTable(); tblObj.Rows.Add(DBNull.Value, AppPhrases.UndefinedItem); DataGridViewComboBoxColumn colObjNum = (DataGridViewComboBoxColumn)gvKPSel.Columns["colObjNum"]; colObjNum.DataSource = tblObj; colObjNum.DisplayMember = "Name"; colObjNum.ValueMember = "ObjNum"; DataTable tblKP = Tables.GetKPTable(); DataTable tblKPType = Tables.GetKPTypeTable(); foreach (DataRow rowKP in tblKP.Rows) { CreateCnls.KPInfo kpInfo = CreateCnls.KPInfo.Create(rowKP, tblKPType); if (kpInfo.DllFileName != "") { Type kpViewType; if (kpViewTypes.TryGetValue(kpInfo.DllFileName, out kpViewType)) { if (kpViewType == null) { kpInfo.Color = Color.Red; kpInfo.DllState = CreateCnls.DllStates.Error; } else { kpInfo.Enabled = true; kpInfo.Color = Color.Black; kpInfo.DllState = CreateCnls.DllStates.Loaded; } } else { kpInfo.DllState = CreateCnls.DllStates.NotFound; } } kpInfoList.Add(kpInfo); } gvKPSel.DataSource = kpInfoList; } catch (Exception ex) { AppUtils.ProcError(AppPhrases.FillKPGridError + ":\r\n" + ex.Message); } }
private void miDbBackup_Click(object sender, EventArgs e) { // резервное копирование файла базы конфигурации try { string workFileName = settings.AppSett.BaseSDFFile; string backupDir = settings.AppSett.BackupDir; if (File.Exists(workFileName)) { if (Directory.Exists(backupDir)) { bool wasConnected = AppData.Connected; string backupFileName = backupDir + Path.GetFileNameWithoutExtension(workFileName) + DateTime.Now.ToString(" yyyy-MM-dd HH-mm-ss") + ".sdf"; try { if (wasConnected) { AppData.Conn.Close(); // для сохранения изменений } File.Copy(workFileName, backupFileName, true); } finally { if (wasConnected) { AppData.Conn.Open(); } } ScadaUtils.ShowInfo(string.Format(AppPhrases.BackupCompleted, backupFileName)); } else { ScadaUtils.ShowError(AppPhrases.BackupDirNotExists); } } else { ScadaUtils.ShowError(AppPhrases.BaseSDFFileNotExists); } } catch (Exception ex) { AppUtils.ProcError(AppPhrases.BackupError + ":\r\n" + ex.Message); } }
private void bindingNavigatorRefreshItem_Click(object sender, EventArgs e) { if (UpdateTable()) { Table.RowChanged -= dataTable_RowChanged; Table.RowDeleted -= dataTable_RowDeleted; bindingSource.DataSource = null; // to speed up data changes in the table try { // update editable table Table.Clear(); var adapter = Table.ExtendedProperties["DataAdapter"] as SqlCeDataAdapter; adapter.Fill(Table); Table.BeginLoadData(); // updating tables that are data sources for cell values foreach (DataGridViewColumn col in dataGridView.Columns) { var cbCol = col as DataGridViewComboBoxColumn; if (cbCol != null) { var tbl = cbCol.DataSource as DataTable; if (tbl != null) { bool emtyRowExists = tbl.DefaultView.Find(DBNull.Value) >= 0; tbl.Clear(); adapter = tbl.ExtendedProperties["DataAdapter"] as SqlCeDataAdapter; adapter.Fill(tbl); if (emtyRowExists) { tbl.BeginLoadData(); tbl.Rows.Add(DBNull.Value, " "); } } } } } catch (Exception ex) { AppUtils.ProcError(AppPhrases.RefreshDataError + ":\r\n" + ex.Message); } Table.RowChanged += dataTable_RowChanged; Table.RowDeleted += dataTable_RowDeleted; bindingSource.DataSource = Table; bindingSource.ResetBindings(false); SetModified(ChildFormTag.Modified); // setting the availability of buttons } }
/// <summary> /// Disconnect from DB /// </summary> private void Disconnect() { try { if (AppData.Connected) { AppData.Disconnect(); nodDB.ImageKey = nodDB.SelectedImageKey = "db_gray.gif"; treeView.CollapseAll(); SetItemsEnabledOnConnect(); } } catch (Exception ex) { AppUtils.ProcError(AppPhrases.DisconnectError + ":\r\n" + ex.Message); } }
private void miDbCompact_Click(object sender, EventArgs e) { // packaging configuration database file try { if (AppData.Compact()) { ScadaUiUtils.ShowInfo(AppPhrases.CompactCompleted); } else { ScadaUiUtils.ShowError(AppPhrases.ConnectionUndefined); } } catch (Exception ex) { AppUtils.ProcError(AppPhrases.CompactError + ":\r\n" + ex.Message); } }
/// <summary> /// Сохранить изменения в БД /// </summary> public void Save() { string errMsg; saveOk = Tables.UpdateData(Table, out errMsg); if (saveOk) { SetModified(false); } else { SetModified(true); AppUtils.ProcError(errMsg); } saveOccured = true; }
/// <summary> /// Fill filter KP on communication line /// </summary> private void FillKPFilter() { try { var tblCommLine = Tables.GetCommLineTable(); var noFilterRow = tblCommLine.NewRow(); noFilterRow["CommLineNum"] = 0; noFilterRow["Name"] = cbKPFilter.Items[0]; tblCommLine.Rows.InsertAt(noFilterRow, 0); cbKPFilter.DataSource = tblCommLine; cbKPFilter.SelectedIndexChanged += cbKPFilter_SelectedIndexChanged; } catch (Exception ex) { AppUtils.ProcError(AppPhrases.FillKPFilterError + ":\r\n" + ex.Message); } }
/// <summary> /// Соединиться с БД /// </summary> private bool Connect(bool expandTree) { bool result; bool connectNeeded = !AppData.Connected; try { // соединение с БД if (connectNeeded) { AppData.Connect(); nodDB.ImageKey = nodDB.SelectedImageKey = "db.gif"; nodSystem.Expand(); nodDict.Expand(); SetItemsEnabledOnConnect(); } result = true; } catch (Exception ex) { AppUtils.ProcError(AppPhrases.ConnectError + ":\r\n" + ex.Message); result = false; } if (result) { // раскрытие дерева проводника if (expandTree) { treeView.BeforeExpand -= treeView_BeforeExpand; nodDB.Expand(); treeView.BeforeExpand += treeView_BeforeExpand; } // группировка каналов if (connectNeeded) { GroupCnls(); } } return(result); }
private void btnImport_Click(object sender, EventArgs e) { // импорт выбранной таблицы из формата DAT Tables.TableInfo tableInfo = cbTable.SelectedItem as Tables.TableInfo; if (AppData.Connected) { string logFileName = chkImportLog.Checked ? AppData.ExeDir + "ScadaAdminImport.txt" : ""; bool importOK; bool logCreated; string msg; if (tableInfo == null) { // импорт архива importOK = ImportExport.ImportArchive(txtFileName.Text, Tables.TableInfoList, logFileName, out logCreated, out msg); } else { // импорт таблицы int minID = gbIDs.Enabled && chkStartID.Checked ? Convert.ToInt32(numStartID.Value) : 0; int maxID = gbIDs.Enabled && chkFinalID.Checked ? Convert.ToInt32(numFinalID.Value) : int.MaxValue; int newMinID = gbIDs.Enabled && chkNewStartID.Checked ? Convert.ToInt32(numNewStartID.Value) : 0; importOK = ImportExport.ImportTable(txtFileName.Text, tableInfo, minID, maxID, newMinID, logFileName, out logCreated, out msg); } // отображение сообщения о результате импорта if (importOK) { ScadaUtils.ShowInfo(msg); } else { AppUtils.ProcError(msg); } // отображение журанала в блокноте if (logCreated) { Process.Start(logFileName); } } }
private void miDbPassToServer_Click(object sender, EventArgs e) { // перевод базы конфигурации в формат DAT try { if (AppData.Connected) { string baseDatDir = settings.AppSett.BaseDATDir; if (Directory.Exists(baseDatDir)) { // создание файла блокировки базы конфигурации string baseLockPath = baseDatDir + "baselock"; FileStream baseLockStream = new FileStream(baseLockPath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite); baseLockStream.Close(); try { // сохранение таблиц базы конфигурации в формате DAT BaseAdapter adapter = new BaseAdapter(); foreach (Tables.TableInfo tableInfo in Tables.TablesInfo) { DataTable table = tableInfo.GetTable(); adapter.FileName = baseDatDir + tableInfo.FileName; adapter.Update(table); } } finally { // удаление файла блокировки базы конфигурации File.Delete(baseLockPath); } ScadaUtils.ShowInfo(AppPhrases.DbPassCompleted); } else { ScadaUtils.ShowError(CommonPhrases.BaseDATDirNotExists); } } } catch (Exception ex) { AppUtils.ProcError(AppPhrases.DbPassError + ":\r\n" + ex.Message); } }
private void miServiceRestart_Click(object sender, EventArgs e) { // перезапуск или запуск службы try { Cursor = Cursors.WaitCursor; // получение контроллера службы string serviceName = sender == miServiceRestartServer || sender == btnRestartServer ? "ScadaServerService" : "ScadaCommService"; ServiceController svcContr = new ServiceController(serviceName); // ожидание завершения запуска или оставновки службы if (svcContr.Status == ServiceControllerStatus.StartPending) { svcContr.WaitForStatus(ServiceControllerStatus.Running, ServiceWait); } else if (svcContr.Status == ServiceControllerStatus.StopPending) { svcContr.WaitForStatus(ServiceControllerStatus.Stopped, ServiceWait); } if (svcContr.Status == ServiceControllerStatus.Running) { // перезапуск службы svcContr.Stop(); svcContr.WaitForStatus(ServiceControllerStatus.Stopped, ServiceWait); svcContr.Start(); } else if (svcContr.Status == ServiceControllerStatus.Stopped) { // запуск службы svcContr.Start(); } } catch (Exception ex) { AppUtils.ProcError(AppPhrases.ServiceRestartError + ":\r\n" + ex.Message); } finally { Cursor = Cursors.Default; } }
/// <summary> /// Initialize the form /// </summary> private void Init() { // form initialization if (!inited) { inited = true; // setting controls depending on localization PictureBox activePictureBox; if (Localization.UseRussian) { activePictureBox = pbAboutRu; pbAboutEn.Visible = false; lblVersionEn.Visible = false; lblVersionRu.Text = "Версия " + Version; } else { activePictureBox = pbAboutEn; pbAboutRu.Visible = false; lblVersionRu.Visible = false; lblVersionEn.Text = "Version " + Version; } // download images and hyperlinks from files if they exist bool imgLoaded; string errMsg; if (ScadaUiUtils.LoadAboutForm(AppData.AppDirs.ExeDir, this, activePictureBox, lblWebsite, out imgLoaded, out linkUrl, out errMsg)) { if (imgLoaded) { lblVersionRu.Visible = false; lblVersionEn.Visible = false; } } else { AppUtils.ProcError(errMsg); } } }
/// <summary> /// Инициализировать форму /// </summary> private void Init() { // инициализация формы if (!inited) { inited = true; // настройка элементов управления в зависимости от локализации PictureBox activePictureBox; if (Localization.UseRussian) { activePictureBox = pbAboutRu; pbAboutEn.Visible = false; lblVersionEn.Visible = false; lblVersionRu.Text = "Версия " + Version; } else { activePictureBox = pbAboutEn; pbAboutRu.Visible = false; lblVersionRu.Visible = false; lblVersionEn.Text = "Version " + Version; } // загрузка изображения и гиперссылки из файлов, если они существуют bool imgLoaded; string errMsg; if (ScadaUiUtils.LoadAboutForm(AppData.ExeDir, this, activePictureBox, lblWebsite, out imgLoaded, out linkUrl, out errMsg)) { if (imgLoaded) { lblVersionRu.Visible = false; lblVersionEn.Visible = false; } } else { AppUtils.ProcError(errMsg); } } }
private void miDbCompact_Click(object sender, EventArgs e) { // упаковка файла базы конфигурации try { if (AppData.Compact()) { ScadaUiUtils.ShowInfo(AppPhrases.CompactCompleted); } else { ScadaUiUtils.ShowError(AppPhrases.ConnectionUndefined); } } catch (Exception ex) { AppUtils.ProcError(AppPhrases.CompactError + ":\r\n" + ex.Message); } }
/// <summary> /// Calculate and display channel numbers /// </summary> private void CalcAndShowCnlNums(bool showError) { // getting numbers of existing channels if (inCnlNums == null) { inCnlNums = Tables.GetInCnlNums(); } if (ctrlCnlNums == null) { ctrlCnlNums = Tables.GetCtrlCnlNums(); } // getting numbering parameters var inCnlNumParams = new CreateCnls.CnlNumParams() { Start = decimal.ToInt32(numInCnlsStart.Value), Multiple = decimal.ToInt32(numInCnlsMultiple.Value), Shift = decimal.ToInt32(numInCnlsShift.Value), Space = decimal.ToInt32(numInCnlsSpace.Value) }; var ctrlCnlNumParams = new CreateCnls.CnlNumParams() { Start = decimal.ToInt32(numCtrlCnlsStart.Value), Multiple = decimal.ToInt32(numCtrlCnlsMultiple.Value), Shift = decimal.ToInt32(numCtrlCnlsShift.Value), Space = decimal.ToInt32(numCtrlCnlsSpace.Value) }; // calculation of channel numbers string errMsg; bool calcOk = CreateCnls.CalcCnlNums(kpViewTypes, kpInfoList, commDirs, inCnlNums, inCnlNumParams, ctrlCnlNums, ctrlCnlNumParams, out errMsg); // output to form SwitchCalcCreateEnabled(!calcOk); gvKPSel.Invalidate(); if (showError && errMsg != "") { AppUtils.ProcError(errMsg); } }
/// <summary> /// Рассчитать и отобразить номера каналов /// </summary> private void CalcAndShowCnlNums(bool showError) { // получение номеров существующих каналов if (inCnlNums == null) { inCnlNums = Tables.GetInCnlNums(); } if (ctrlCnlNums == null) { ctrlCnlNums = Tables.GetCtrlCnlNums(); } // получение параметров нумерации CreateCnls.CnlNumParams inCnlNumParams = new CreateCnls.CnlNumParams() { Start = decimal.ToInt32(numInCnlsStart.Value), Multiple = decimal.ToInt32(numInCnlsMultiple.Value), Shift = decimal.ToInt32(numInCnlsShift.Value), Space = decimal.ToInt32(numInCnlsSpace.Value) }; CreateCnls.CnlNumParams ctrlCnlNumParams = new CreateCnls.CnlNumParams() { Start = decimal.ToInt32(numCtrlCnlsStart.Value), Multiple = decimal.ToInt32(numCtrlCnlsMultiple.Value), Shift = decimal.ToInt32(numCtrlCnlsShift.Value), Space = decimal.ToInt32(numCtrlCnlsSpace.Value) }; // рассчёт номеров каналов string errMsg; bool calcOk = CreateCnls.CalcCnlNums(kpViewTypes, kpInfoList, commDirs, inCnlNums, inCnlNumParams, ctrlCnlNums, ctrlCnlNumParams, out errMsg); // вывод на форму SwitchCalcCreateEnabled(!calcOk); gvKPSel.Invalidate(); if (showError && errMsg != "") { AppUtils.ProcError(errMsg); } }
/// <summary> /// Connect to DB /// </summary> private bool Connect(bool expandTree) { bool result; bool connectNeeded = !AppData.Connected; try { // database connection if (connectNeeded) { AppData.Connect(); nodDB.ImageKey = nodDB.SelectedImageKey = @"db.gif"; nodSystem.Expand(); nodDict.Expand(); SetItemsEnabledOnConnect(); } result = true; } catch (Exception ex) { AppUtils.ProcError(AppPhrases.ConnectError + ":\r\n" + ex.Message); result = false; } if (result) { // opening the conductor tree if (expandTree) { treeView.BeforeExpand -= treeView_BeforeExpand; nodDB.Expand(); treeView.BeforeExpand += treeView_BeforeExpand; } // channel grouping if (connectNeeded) { GroupCnls(); } } return(result); }
private void btnExport_Click(object sender, EventArgs e) { // экспорт выбранной таблицы в формат DAT Tables.TableInfo tableInfo = cbTable.SelectedItem as Tables.TableInfo; if (tableInfo != null && AppData.Connected) { int minID = gbIDs.Enabled && chkStartID.Checked ? Convert.ToInt32(numStartID.Value) : 0; int maxID = gbIDs.Enabled && chkFinalID.Checked ? Convert.ToInt32(numFinalID.Value) : int.MaxValue; string msg; if (ImportExport.ExportTable(tableInfo, txtFileName.Text, minID, maxID, out msg)) { ScadaUiUtils.ShowInfo(msg); } else { AppUtils.ProcError(msg); } } }
private void miSettingsLanguage_Click(object sender, EventArgs e) { // создание и отображение формы выбора языка string prevCultureName = FrmLanguage.CultureName; FrmLanguage frmLanguage = new FrmLanguage(); if (frmLanguage.ShowDialog() == DialogResult.OK && prevCultureName != FrmLanguage.CultureName) { // запись культуры для выбранного языка в реестр string errMsg; if (Localization.WriteCulture(FrmLanguage.CultureName, out errMsg)) { ScadaUiUtils.ShowInfo(AppPhrases.LanguageChanged); } else { AppUtils.ProcError(errMsg); } } }
private void miSettingsLanguage_Click(object sender, EventArgs e) { // creating and displaying a language selection form string prevCultureName = FrmLanguage.CultureName; var frmLanguage = new FrmLanguage(); if (frmLanguage.ShowDialog() == DialogResult.OK && prevCultureName != FrmLanguage.CultureName) { // recording culture for the selected language in the registry string errMsg; if (Localization.WriteCulture(FrmLanguage.CultureName, out errMsg)) { ScadaUiUtils.ShowInfo(AppPhrases.LanguageChanged); } else { AppUtils.ProcError(errMsg); } } }