public frmDatabase(Server server) { // Information that is used to connect to the MySql Database string dbhost = "localhost"; string dbuser = "******"; string dbpass = "******"; string dbdatabase = "dataman"; // The server connection that is used to connect to the database. this.server = server; // Creates all the controls for the form. InitializeComponent(); // Checks to make sure the connection to the server is still active and then // attempts to connect to the database. if (server.isJschConnected()) { this.statLbl1.Text = "Connected To Server"; server.setPortForwarding("131-server.ecs.csus.edu"); mySqlConn = new SqlDatabase(dbhost, dbuser, dbpass, dbdatabase); data = new DataTable(); data = mySqlConn.queryDatabase("show tables;"); fillDataGrid(data); } }
static void Main(string[] args) { try { server = BackEnd.Server.Instance; Thread listenThread = new Thread(server.BeginListen); listenThread.Start(); } catch (Exception ex) { server.EndListen(); Console.WriteLine(ex.Message); } }
public frmController(Server server) { // Information that is used to connect to the MySql Database string dbhost = "localhost"; string dbuser = "******"; string dbpass = "******"; string dbdatabase = "dataman"; // The server connection that is used to connect to the database. this.server = server; // Creates all the controls for the form. InitializeComponent(); // Checks to make sure the connection to the server is still active and then // attempts to connect to the database. if (server.isJschConnected()) { this.statLbl1.Text = "Connected To Server"; server.setPortForwarding("131-server.ecs.csus.edu"); mySqlConn = new SqlDatabase(dbhost, dbuser, dbpass, dbdatabase); // Will return the result of trying to connect to the database. Will have // a null string if it was able to connect. string result = mySqlConn.connectDatabase(); if (result == null) { if ( rdoDatabase.Checked ) { loadDatabaseAccounts(); } else if ( rdoProject.Checked ) { loadProjectAccounts(); } } else { MessageBox.Show(result, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } // Defaults the combo box to unsynced. this.cmboAcctStatus.SelectedIndex = 0; } }
public frmDatabase(Server server) { // Information that is used to connect to the MySql Database string dbhost = "131-server.ecs.csus.edu"; string dbuser = "******"; string dbpass = "******"; string dbdatabase = "dataman"; // The server connection that is used to connect to the database. this.server = server; // Creates all the controls for the form. InitializeComponent(); // Checks to make sure the connection to the server is still active and then // attempts to connect to the database. if (server.isJschConnected()) { this.statLbl1.Text = "Connected To Server"; server.setPortForwarding(dbhost); mySqlConn = new SqlDatabase(dbhost, dbuser, dbpass, dbdatabase); // Will return the result of trying to connect to the database. Will have // a null string if it was able to connect. string result = mySqlConn.connectDatabase(); if (result == null) { data = new DataTable(); data = mySqlConn.queryDatabase("show tables;"); fillDataGrid(data); } else { MessageBox.Show(result, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } } }
private void btnLogIn_Click(object sender, EventArgs e) { Boolean process = true; host = txtHost.Text; username = txtUsername.Text; password = txtPassword.Text; // Checks to make sure that values are entered into each textbox. if (host.Trim() == "") { lblHostError.Text = "*Need to enter a valid server name."; lblHostError.Visible = true; txtHost.Focus(); process = false; } else { lblHostError.Visible = false; } if (username.Trim() == "") { lblUserError.Text = "*Need to enter a valid username."; lblUserError.Visible = true; txtUsername.Focus(); process = false; } else { lblUserError.Visible = false; } if (password.Trim() == "") { lblPassError.Text = "*Need to enter a password."; lblPassError.Visible = true; txtPassword.Focus(); process = false; } else { lblPassError.Visible = false; } // Checks to see whether to proceed or not if (process == false) { return; } server = new Server(); string result = server.jschServer(host, username, password); // If an error was not encountered when logging into server then it will skip this block. if (result != null) { // Throws an excpetion that username and/or password is incorrect if (result == "Auth cancel") { MessageBox.Show("Username and/or Password is incorrect!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPassword.Focus(); return; } // Throws an exception that program cannot connect to host. else { MessageBox.Show("Cannot connect to server. Is host name entered correctly?", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtHost.Focus(); return; } } // If successively connects, will attempt to connect to database. frmController databaseWindow = new frmController(server); this.Hide(); databaseWindow.ShowDialog(); this.Close(); }
public frmCreateUser(Server server) { InitializeComponent(); this.server = server; }