private void toolStripMenuItemconnect_Click(object sender, EventArgs e)
{
if (labelselectedproj.Text != "")
{
greenapple.Properties.Settings.Default.server = toolStripTextBoxserver.Text;
greenapple.Properties.Settings.Default.database = toolStripTextBoxdatabase.Text;
greenapple.Properties.Settings.Default.user = toolStripTextBoxuser.Text;
greenapple.Properties.Settings.Default.password = toolStripTextBoxpassword.Text;
greenapple.Properties.Settings.Default.Save();
//get the names of all the tables of the database into a Datatable
DataTable dat = new Connectoperations().showDatabaseTables();
//a loop to put items in the table into the listview
int i = 1;
listView1.Items.Clear();
foreach (DataRow row in dat.Rows)
{
//an instance of a lisviewitem
ListViewItem lv = new ListViewItem((i++).ToString());
lv.SubItems.Add(row[0].ToString());
//add the lisviewitem to listview1
listView1.Items.Add(lv);
//table controls
}
loadRelations();
}
else
{
MessageBox.Show("Select a Project");
}
string path = "";
path = Directory.GetCurrentDirectory() + "\\" + myproject.selectedProject + "\\" + myproject.selectedProject + "\\controls.xml";
DataSet ds = new DataSet();
try
{
tableControls.Clear();
ds.ReadXml(path);
foreach (DataTable tab in ds.Tables)
{
ClassTableControls ctc = new ClassTableControls();
ctc.controls = new List<string>();
foreach (DataRow row in tab.Rows)
{
string controlName = row[0].ToString();
ctc.controls.Add(controlName);
ctc.tablename = tab.TableName;
}
tableControls.Add(ctc);
}
}
catch
{
}
}