private void toolStrip_BtnDGView_Click(object sender, EventArgs e) { try { if (toolStripCmbBox.SelectedIndex == 0) { DataTable dt = db.GetTable("Compound_Data"); dg.PreferredColumnWidth = columnWidth * 2; dg.DataSource = dt; dg.Refresh(); } else if (toolStripCmbBox.SelectedIndex == 1) { DataTable dt = db.GetTable("Reagent_Data"); dg.PreferredColumnWidth = columnWidth * 2; dg.DataSource = dt; dg.Refresh(); } else if (toolStripCmbBox.SelectedIndex == 2) { DataTable dt = db.GetTable("Operation_Data"); dg.PreferredColumnWidth = columnWidth * 2; dg.DataSource = dt; dg.Refresh(); } else if (toolStripCmbBox.SelectedIndex == 3) { DataTable dt = db.GetTable("Chemical_Compounds"); dg.PreferredColumnWidth = columnWidth; dg.DataSource = dt; dg.Refresh(); } else if (toolStripCmbBox.SelectedIndex == 4) { DataTable dt = db.GetTable("Physical_Properties"); dg.PreferredColumnWidth = columnWidth * 2; dg.DataSource = dt; dg.Refresh(); } } catch { } }
private void PopulateSelector() { cmbBoxSelector.Items.Clear(); DataTable dt = dbo.GetTable("Compound_Data"); for (int i = 0; i < dt.Rows.Count; i++) { cmbBoxSelector.Items.Add(dt.Rows[i].ItemArray[1]); } grpBoxAddChemicalCompound.Hide(); btnSave.Hide(); this.Size = new Size(511, 147); }
private void LoadControls() { DB_Operator dbo = new DB_Operator(); DataTable dt1 = dbo.GetTable("Reagent_Data"); DataTable dt2 = dbo.GetTable("Operation_Data"); DataTable dt3 = dbo.GetTable("Compound_Data"); foreach (DataRow dr in dt1.Rows) { lstColumnCodes.Add(dr.ItemArray[1] as string); lstColumnNames.Add(dr.ItemArray[2] as string); } foreach (DataRow dr in dt2.Rows) { lstColumnCodes.Add(dr.ItemArray[1] as string); lstColumnNames.Add(dr.ItemArray[2] as string); } Point lblPosition = new Point(40, 63); Point txtBoxPosition = new Point(237, 60); for (int i = 0; i < lstColumnCodes.Count; i++) { Label lblReagent = new Label(); lblReagent.Size = new System.Drawing.Size(194, 15); lblReagent.Name = "lblReagent_" + i.ToString(); lblReagent.Location = lblPosition; this.pnlChemicalCompound.Controls.Add(lblReagent); lblReagent.Text = lstColumnNames[i]; ComboBox cmbBoxCompound = new ComboBox(); cmbBoxCompound.Name = i.ToString(); cmbBoxCompound.Location = txtBoxPosition; this.pnlChemicalCompound.Controls.Add(cmbBoxCompound); for (int j = 0; j < dt3.Rows.Count; j++) { cmbBoxCompound.Items.Add(dt3.Rows[j].ItemArray[1]); } lblPosition.Y += 37; txtBoxPosition.Y += 37; } }
private List <int> CreateCompoundIDList() { List <int> lstCompoundsOnReagentID = new List <int>(); DB_Operator dbo = new DB_Operator(); DataTable dt3 = dbo.GetTable("Compound_Data"); List <int> lstCompoundCodes = new List <int>(); List <string> lstCompoundNames = new List <string>(); for (int i = 0; i < dt3.Rows.Count; i++) { lstCompoundCodes.Add(Convert.ToInt32(dt3.Rows[i].ItemArray[0])); lstCompoundNames.Add(Convert.ToString(dt3.Rows[i].ItemArray[1])); } for (int i = 0; i < lstCompoundsOnReagent.Count; i++) { if (lstCompoundsOnReagent[i].Trim() == "") { lstCompoundsOnReagentID.Add(0000); } else { int index = lstCompoundNames.IndexOf(lstCompoundsOnReagent[i]); lstCompoundsOnReagentID.Add(lstCompoundCodes[index]); } } return(lstCompoundsOnReagentID); }
private void LoadOperationData() { if (lstBoxOperations.Items.Count != 0) { lstBoxOperations.Items.Clear(); lstOperationCodes.Clear(); lstImageLinks.Clear(); } lstBoxOperations.Refresh(); DB_Operator dbo = new DB_Operator(); DataTable dt = dbo.GetTable("Operation_Data"); for (int i = 0; i < dt.Rows.Count; i++) { lstBoxOperations.Items.Add(dt.Rows[i].ItemArray[2] as string); lstOperationCodes.Add(dt.Rows[i].ItemArray[1] as string); lstImageLinks.Add(dt.Rows[i].ItemArray[3] as string); } lstBoxOperations.Refresh(); }
private void LoadReagentData() { if (lstBoxReagents.Items.Count != 0) { for (int i = 0; i < lstBoxReagents.Items.Count; i++) { lstBoxReagents.Items.RemoveAt(i); } lstReagentCodes.Clear(); } DataTable dt = dbo.GetTable("Reagent_Data"); for (int i = 0; i < dt.Rows.Count; i++) { lstBoxReagents.Items.Add(dt.Rows[i].ItemArray[2]); lstReagentCodes.Add(dt.Rows[i].ItemArray[1] as string); } lstBoxReagents.Refresh(); }