Beispiel #1
0
        private void OK_Click(object sender, System.EventArgs e)
        {
            try
            {
                //make sure connection is closed
                connection.Close();

                //Generate connection string
                connection.ConnectionString = GetConnectionStr(
                    dbms,
                    userName.Text,
                    password.Text,
                    server.Text,
                    database.Text);

                //Open the connection - if unsuccessful, raises exception, caught below
                connection.Open();

                //If successful, add login information to history
                history.AddLogin(userName.Text, server.Text, database.Text);                   //only if login is successful

                //result returned to Execute is "successful"
                loginResult = LoginResult.Successful;
            }
            catch (Exception error)
            {
                failedLoginAttempts++;
                loginResult = LoginResult.Unsuccessful;

                //string errorText =
                //    "Login attempt failed:\n" +
                //    error.Message +
                //    "\nAttempt " + failedLoginAttempts.ToString() + "/" + maxLoginAttempts.ToString();

                //MessageBox.Show(
                //    errorText,
                //    "Login failed",
                //    MessageBoxButtons.OK,
                //    MessageBoxIcon.Error );

                XtraMessageBox.Show("Login failed. Attempt: " + failedLoginAttempts.ToString() + " / " + maxLoginAttempts.ToString() + Environment.NewLine +
                                    "Error CNF-401 in " + FORM_NAME + ".OK_Click(): " + error.Message,
                                    FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        private void OK_Click(object sender, System.EventArgs e)
        {
            try
            {
                //make sure connection is closed
                connection.Close();

                //Generate connection string
                connection.ConnectionString = Sempra.Ops.GetConnectionStr(
                    dbms,
                    userName.Text,
                    password.Text,
                    server.Text);

                //Open the connection - if unsuccessful, raises exception, caught below
                connection.Open();

                //If successful, add login information to history
                history.AddLogin(userName.Text, server.Text);                   //only if login is successful

                //result returned to Execute is "successful"
                loginResult = LoginResult.Successful;
            }
            catch (Exception error)
            {
                failedLoginAttempts++;
                loginResult = LoginResult.Unsuccessful;

                string errorText =
                    "Login attempt failed:\n" +
                    error.Message +
                    "\nAttempt " + failedLoginAttempts.ToString() + "/" + maxLoginAttempts.ToString();

                MessageBox.Show(
                    errorText,
                    "Login failed",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
        }