Exemplo n.º 1
0
        // button: Connect
        private void button1_Click(object sender, EventArgs e)
        {
            //проверка заполненых полей с именем входа
            if (label4.Visible)
            {
                label4.Visible = false;
            }

            if (!checkBox1.Checked &&
                (String.IsNullOrEmpty(textBox2.Text) || String.IsNullOrWhiteSpace(textBox2.Text) ||
                 String.IsNullOrEmpty(textBox3.Text) || String.IsNullOrWhiteSpace(textBox3.Text)))
            {
                label4.Visible = true;
                label4.Text    = "Fill the fields 'Login' and 'Password' or use 'Trusted connection'";
            }
            else
            {
                obj_sqlConnection = new mssqlConnection(textBox1.Text, textBox4.Text, textBox2.Text, textBox3.Text, checkBox1.Checked);

                obj_sqlConnection.openConnection();
                if (obj_sqlConnection.sqlConnection.State == ConnectionState.Open)
                {
                    Form1.serverName    = textBox1.Text;
                    Form1.databaseName  = textBox4.Text;
                    Form1.loginName     = textBox2.Text;
                    Form1.loginPassword = textBox3.Text;
                    Form1.loginTrusted  = checkBox1.Checked;

                    Close();
                }
            }
        }
Exemplo n.º 2
0
        // menu: Подключение
        private void подключениеToolStripMenuItem_Click(object sender, EventArgs e)
        {
            loginForm.ShowDialog();

            form1_mssqlConnection = new mssqlConnection(serverName, databaseName, loginName, loginPassword, loginTrusted);
            form1_mssqlConnection.openConnection();

            loadData();
        }
Exemplo n.º 3
0
        // menu: Обновить
        private void обновитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (form1_mssqlConnection == null)
            {
                loginForm.ShowDialog();

                form1_mssqlConnection = new mssqlConnection(serverName, databaseName, loginName, loginPassword, loginTrusted);
            }

            if (form1_mssqlConnection.sqlConnection.State != ConnectionState.Open)
            {
                form1_mssqlConnection.openConnection();
            }

            loadData();
        }