Exemple #1
0
        /// <summary>
        /// Handles the Click event of the ok button.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void Ok_Click(object sender, EventArgs e)
        {
            // Get the port
            uint portNumber;

            if (!uint.TryParse(this.port.Text, out portNumber))
            {
                portNumber = 3306;
            }

            // Create a new server object
            this.Server          = new MySqlServer();
            this.Server.Host     = this.host.Text;
            this.Server.Port     = portNumber;
            this.Server.UserName = this.userName.Text;
            this.Server.Password = this.password.Text;
            this.Server.Open();

            // Check for errors
            if (!string.IsNullOrEmpty(this.Server.LastError))
            {
                this.WindowState = FormWindowState.Normal;
                MessageBox.Show(this.Server.LastError, "Error connecting to server", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0);
            }
            else
            {
                // Close this dialog
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Exemple #2
0
 /// <summary>
 /// Initialises a new instance of the <see cref="FormMain"/> class.
 /// </summary>
 /// <param name="server">The server.</param>
 public FormMain(MySqlServer server)
     : this()
 {
     this.Server = server;
 }
Exemple #3
0
 /// <summary>
 /// Opens the main form.
 /// </summary>
 /// <param name="server">The server.</param>
 public static void OpenMainForm(MySqlServer server)
 {
     Application.Run(new FormMain(server));
 }