44 lines
2.1 KiB
C#
44 lines
2.1 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
|
|
namespace RCM {
|
|
public partial class MySQLControl : UserControl {
|
|
private MySQL _mySQL;
|
|
|
|
public MySQLControl(MySQL mySQL) {
|
|
InitializeComponent();
|
|
_mySQL = mySQL;
|
|
textBoxHostAddress.Text = mySQL.Host;
|
|
textBoxUsername.Text = mySQL.Username;
|
|
textBoxPassword.Text = mySQL.Password;
|
|
textBoxDatabase.Text = mySQL.Database;
|
|
textBoxEncPassword.Text = mySQL.AESPassword;
|
|
}
|
|
|
|
private void ButtonUnmaskPassword_Click(object sender, EventArgs e) {
|
|
textBoxPassword.UseSystemPasswordChar = !textBoxPassword.UseSystemPasswordChar;
|
|
}
|
|
|
|
private void ButtonTestConnection_Click(object sender, EventArgs e) {
|
|
try {
|
|
string version = _mySQL.TestConnection(textBoxHostAddress.Text, textBoxUsername.Text, textBoxPassword.Text, textBoxDatabase.Text);
|
|
MessageBox.Show(version, "Test successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
} catch (Exception ex) {
|
|
MessageBox.Show(ex.Message, "Test failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void ButtonCreateSchema_Click(object sender, EventArgs e) {
|
|
bool schemaExists = _mySQL.SchemaExists(textBoxHostAddress.Text, textBoxUsername.Text, textBoxPassword.Text, textBoxDatabase.Text);
|
|
if (!schemaExists || MessageBox.Show("Do you want to drop existing schema and create a new one?", "Schema already exists", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) {
|
|
_mySQL.CreateSchema(textBoxHostAddress.Text, textBoxUsername.Text, textBoxPassword.Text, textBoxDatabase.Text);
|
|
MessageBox.Show("New schema successfully created", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
}
|
|
|
|
private void ButtonUnmaskEncPassword_Click(object sender, EventArgs e) {
|
|
textBoxEncPassword.UseSystemPasswordChar = !textBoxEncPassword.UseSystemPasswordChar;
|
|
}
|
|
}
|
|
}
|