public FormMain() { //Проверка на дурака (чего то не хватает в setting.designer.cs для работы свойства подключения) WindowsFormsTeachingLoadAdmin.Properties.Settings.Default.workload_of_teachersConnectionString = WindowsFormsTeachingLoadAdmin.Properties.Settings.Default.workload_of_teachersConnectionString; SqlConnection MyConnection = new SqlConnection(WindowsFormsTeachingLoadAdmin.Properties.Settings.Default.workload_of_teachersConnectionString); try { MyConnection.Open(); } catch { } if (MyConnection.State == ConnectionState.Closed) { if (MessageBox.Show("Подключение к базе данных отсутствует! Изменить свойства подключения?", "Ошибка подключения к базе данных", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes) { FormConnectString form = new FormConnectString(); if (form.ShowDialog() != DialogResult.OK) { Environment.Exit(0); } } else { Environment.Exit(0); } } MyConnection.Close(); InitializeComponent(); this.Icon = WindowsFormsTeachingLoadAdmin.Properties.Resources.iconAdmin; ab = new AboutBox(); }
private void toolStripMenuItem4_Click(object sender, EventArgs e) { FormConnectString form = new FormConnectString(); if (form.ShowDialog() == DialogResult.OK) { prepodTableAdapter.Connection = null; prepodTableAdapter.Connection = prepodTableAdapter.Connection; cKTableAdapter.Connection = null; cKTableAdapter.Connection = cKTableAdapter.Connection; this.prepodTableAdapter.FillBySearch(this.workload_of_teachersDataSet.Prepod, comboBoxSearchFIO.Text, (checkBoxGroupingCK.Checked) ? (comboBoxGroupingCK.SelectedValue != null) ? (int)comboBoxGroupingCK.SelectedValue : -1 : -1, (checkBoxGroupingRol.Checked) ? comboBoxGroupingRol.SelectedIndex : -1); } }