private void txt_CT_TextChanged(object sender, EventArgs e) { ManageInputs M = new ManageInputs(); if (txt_CT.Text != "" || txt_CT.Text != null) { string text = txt_CT.Text; M.AccesSpecificComponentValue(txt_CT.Text, cb_V); } if (txt_CT.Text == string.Empty) {//if text is deleted, the value combo box should also be be empty as it has no dataSource cb_V.DataSource = null; } }
private void Form2_FormClosed(object sender, FormClosedEventArgs e) { if (CancelledClicked == false) { //This event will Add components to the Buffer dataTAble in the main form(form1) ECDataGridViewClass ECD = new ECDataGridViewClass(); Components C = new Components(); //Clears previous list so the new changes can be loaded Components.AllComponentsListBuffer.Clear(); ECD.AddRow((DataTable)Form1.dataGRid.DataSource); //After a row has been added, this updates the static list in the components class to record the change C.InitializeComponents((DataTable)Form1.dataGRid.DataSource); ManageInputs M = new ManageInputs(); form1.comboBox.DataSource = M.Form1ComboBoxDataSource(form1.comboBox); } else { ECDataGridViewClass EC = new ECDataGridViewClass(); ECDataGridViewClass.PartNo = ""; ECDataGridViewClass.ManufacturerNo = ""; ECDataGridViewClass.ComponentType = ""; ECDataGridViewClass.Package = ""; ECDataGridViewClass.Value = ""; ECDataGridViewClass.UnitPrice = ""; try { ECDataGridViewClass.Stock = 0; } catch (FormatException) { ECDataGridViewClass.Stock = 0; } ECDataGridViewClass.NACP1 = null; ECDataGridViewClass.NACP2 = null; ECDataGridViewClass.NACP3 = null; CancelledClicked = false; } }
private void btn_AddComponent_Click(object sender, EventArgs e) { //sets the values in the ECDataGridView Class to the text box texts in this form ECDataGridViewClass EC = new ECDataGridViewClass(); try { ECDataGridViewClass.PartNo = txt_PN.Text; } catch (FormatException) { ECDataGridViewClass.PartNo = ""; } try { ECDataGridViewClass.ManufacturerNo = txt_MN.Text; } catch (FormatException) { ECDataGridViewClass.ManufacturerNo = ""; } try { ECDataGridViewClass.ComponentType = txt_CT.Text; } catch (FormatException) { ECDataGridViewClass.ComponentType = ""; } try { ECDataGridViewClass.Package = txt_P.Text; } catch (FormatException) { ECDataGridViewClass.Package = ""; } try { ECDataGridViewClass.Value = txt_V.Text; } catch (FormatException) { ECDataGridViewClass.Value = ""; } try { ECDataGridViewClass.ManufacturerNo = txt_MN.Text; } catch (FormatException) { ECDataGridViewClass.ManufacturerNo = ""; } try { ECDataGridViewClass.UnitPrice = txt_UP.Text; } catch (FormatException) { ECDataGridViewClass.UnitPrice = ""; } try { ECDataGridViewClass.Stock = int.Parse(txt_S.Text.ToString()); } catch (FormatException) { ECDataGridViewClass.Stock = 0; } ECDataGridViewClass.NACP1 = txt_NACP1.Text; ECDataGridViewClass.NACP2 = txt_NACP2.Text; ECDataGridViewClass.NACP3 = txt_NACP3.Text; // //Sets the component names and values in the ManageInputs class ManageInputs M = new ManageInputs(); M.AddComponentToList(txt_CT.Text, txt_V); //The lists set by this method will be used to populate combobox this.Close(); }