public DBConnectForm(Hashtable attributes) { InitializeComponent(); this.attributes = attributes; if (attributes["databaseType"] != null) { this.setDatabaseType((string)attributes["databaseType"]); } if (attributes["server"] != null) { this.server.Text = (string)attributes["server"]; } if (attributes["userid"] != null) { this.userid.Text = (string)attributes["userid"]; } if (attributes["password"] != null) { this.password.Text = (string)attributes["password"]; } if (attributes["port"] != null) { this.port.Text = (string)attributes["port"]; } if (attributes["database"] != null) { this.database.Text = (string)attributes["database"]; } try { conn = DBConnector.getDBConnection(); if (conn != null) { tables.Items.Clear(); tables.Items.AddRange(DBConnector.getTables()); connectStatus.Text = "connected to: " + String.Format("server={0};user id={1}; password={2}; port={3}; database={4}; pooling=false", server.Text, userid.Text, password.Text, port.Text, database.Text); } } catch (Exception ex) { MessageBox.Show(ex.Message); connectStatus.Text = "database connection error"; } }
private void splitContainer1_Panel2_MouseDoubleClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { selectedItem = selectItem(new Point((e.X - x) * scale, (e.Y - y) * scale)); if (selectedItem != null) { if (DBConnector.getDBConnection() != null) { if (selectedItem["type"].Equals("start")) { StartEditForm itemEditForm = new StartEditForm(selectedItem, items); itemEditForm.ShowDialog(); } else if (selectedItem["type"].Equals("node")) { NodeEditForm itemEditForm = new NodeEditForm(selectedItem, items); itemEditForm.ShowDialog(); } else if (selectedItem["type"].Equals("route")) { RouteEditForm itemEditForm = new RouteEditForm(selectedItem, items); itemEditForm.ShowDialog(); } else if (selectedItem["type"].Equals("end")) { EndEditForm itemEditForm = new EndEditForm(selectedItem, items); itemEditForm.ShowDialog(); } } else { MessageBox.Show("no database connection"); } } } }