Ejemplo n.º 1
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     if ((cbAddressServer.SelectedIndex == -1) || (cbNameServer.SelectedIndex == -1) || (tbUserServer.Text == String.Empty) || (tbPasswordServer.Text == String.Empty) || (cbListDataBase.SelectedIndex == -1))
     {
         MessageBox.Show(MessageUser.AllMargin, MessageUser.TitleApp, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         Registry_Class registryData = new Registry_Class();
         registryData.SetRegistry(cbAddressServer.Text, cbNameServer.Text, cbListDataBase.Text, tbUserServer.Text, tbPasswordServer.Text);
         DBConnection.LogConnection = true;
         AuthorizationForm authorizationForm = new AuthorizationForm();
         authorizationForm.ShowDialog();
         Close();
     }
 }
Ejemplo n.º 2
0
        private void InformationConnection(bool value)  //проверка подключения к базе данных
        {
            try
            {
                Action action = () =>
                {
                    switch (value)
                    {
                    case (true):
                        mainWindow.lbsstConnection.Text = Registry_Class.DataSource + "\\" + Registry_Class.DSServerName + " - " + Registry_Class.InitialCatalog;
                        AuthorizationForm authorizationForm = new AuthorizationForm();
                        authorizationForm.Show();
                        break;

                    case (false):
                        mainWindow.lbsstConnection.Text = MessageUser.NoConnection;

                        foreach (Form f in Application.OpenForms)
                        {
                            if (f.Name == "ConnectionForm")
                            {
                                return;
                            }
                        }

                        ConnectionForm connectionForm = new ConnectionForm();
                        connectionForm.Show(this);
                        break;
                    }
                };
                Invoke(action);
            }
            catch
            {
                threadConnection.Abort();
            }
        }