void addCharac() { using (LCWContext lcw = new LCWContext()) { //Characteristic cg = new Characteristic { CHARA_NAME = textBox1.Text }; //lcw.Characteristics.Add(cg); //lcw.SaveChanges(); } }
public void addComponents() { using (LCWContext lcw = new LCWContext()) { Component cg = new Component { }; cg.COMPANY = enterCompany.Text; cg.MODEL = enterModel.Text; cg.TYPE_COMPONENTS = enterTypeComponents.Text; lcw.Components.Add(cg); lcw.SaveChanges(); } MessageBox.Show("Success", "Add result"); }
public void delete() { using (LCWContext lcw = new LCWContext()) { int deletechar = int.Parse(textBox4.Text); CharacteristicComp cg = lcw.CharacteristicsComps .Where(o => o.ID_CHAR == deletechar) .FirstOrDefault(); lcw.CharacteristicsComps.Remove(cg); lcw.SaveChanges(); } MessageBox.Show("Success", "Delete result"); }
public void addCharacteristicsComp() { using (LCWContext lcw = new LCWContext()) { CharacteristicComp CP; CP = new CharacteristicComp { ID_COMPONENT = Int32.Parse(textBox1.Text) }; CP.ID_CHARACTERISTIC = Int32.Parse(textBox2.Text); CP.CC_VALUE = textBox3.Text; lcw.CharacteristicsComps.Add(CP); lcw.SaveChanges(); } MessageBox.Show("Success", "Add result"); }
public void loadComponents() { using (LCWContext lcw = new LCWContext()) { foreach (Component component in lcw.Components.Where(c => c.TYPE_COMPONENTS.Contains("Processor"))) { comboBox1.Items.Add(component.COMPANY + " " + component.MODEL); } foreach (Component component in lcw.Components.Where(c => c.TYPE_COMPONENTS.Contains("Videocard"))) { comboBox3.Items.Add(component.COMPANY + " " + component.MODEL); } foreach (Component component in lcw.Components.Where(c => c.TYPE_COMPONENTS.Contains("RAM"))) { comboBox5.Items.Add(component.COMPANY + " " + component.MODEL); } foreach (Component component in lcw.Components.Where(c => c.TYPE_COMPONENTS.Contains("Motherboard"))) { comboBox2.Items.Add(component.COMPANY + " " + component.MODEL); } foreach (Component component in lcw.Components.Where(c => c.TYPE_COMPONENTS.Contains("Power"))) { comboBox4.Items.Add(component.COMPANY + " " + component.MODEL); } } }
public void check(string ressplit, ComboBox cbname, string componentname) { try { //comboBox1.Items.Clear(); bool flagP = true; string result = "", resultProc = ""; string reason = ""; int idmother = 0, idproc = 0; int resCountP = 0; using (LCWContext lcw = new LCWContext()) { foreach (Component charka2 in lcw.Components) { if (charka2.MODEL == ressplit) { idmother = charka2.ID_COMPONENT; } } for (int i = 0; i < lcw.Components.Where(c => c.TYPE_COMPONENTS.Contains(componentname)).Count(); i++) { result = ""; resultProc = ""; reason = ""; flagP = true; foreach (Component component in lcw.Components.Where(c => c.TYPE_COMPONENTS.Contains(componentname))) { if (idproc < component.ID_COMPONENT) { idproc = component.ID_COMPONENT; break; } else { continue; } } foreach (CharacteristicComp charka1 in lcw.CharacteristicsComps) { if (charka1.ID_COMPONENT == idmother) { result += charka1.CC_VALUE + ';' + charka1.ID_CHARACTERISTIC + ' '; } else if (charka1.ID_COMPONENT == idproc) { resultProc += charka1.CC_VALUE + ";" + charka1.ID_CHARACTERISTIC + " "; } } result = result.TrimEnd(' '); resultProc = resultProc.TrimEnd(' '); for (int g = 0; g < result.Split(' ').Count(); g++) { for (int j = 0; j < resultProc.Split(' ').Count(); j++) { if (flagP == true) { if (result.Split(' ')[g].Split(';')[1] == resultProc.Split(' ')[j].Split(';')[1]) { if (result.Split(' ')[g] == resultProc.Split(' ')[j]) { resCountP++; continue; } else { reason += resultProc.Split(' ')[j].ToString(); flagP = false; break; //reason = reason[0]; } } } } } if (reason == "") { foreach (Component charka2 in lcw.Components) { if (charka2.ID_COMPONENT == idproc) { cbname.Items.Add(charka2.COMPANY + " " + charka2.MODEL); break; } } } else { continue; } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void writes(ComboBox cbname, string componentname) { try { if (cbname.Items[cbname.SelectedIndex].ToString() != "-1") { int rowi = 0; //dataGridView1.Columns.Add(componentname, componentname); string mother = cbname.Items[cbname.SelectedIndex].ToString(); string ressplit = mother.Substring(mother.IndexOf(" ", 0) + 1); string result = "", resultProc = ""; int idmother = 0; using (LCWContext lcw = new LCWContext()) { foreach (Component charka2 in lcw.Components) { if (charka2.MODEL == ressplit) { idmother = charka2.ID_COMPONENT; } } foreach (CharacteristicComp charka1 in lcw.CharacteristicsComps) { if (charka1.ID_COMPONENT == idmother) { resultProc += charka1.CC_VALUE + ";" + charka1.ID_CHARACTERISTIC + " "; } } result = result.TrimEnd(' '); resultProc = resultProc.TrimEnd(' '); char[] charr = resultProc.ToCharArray(); for (int g = 0; g < resultProc.Split(' ').Count(); g++) { string str = resultProc.Split(' ')[g].Split(';')[1]; int digit = Convert.ToInt32(str); foreach (Characteristic charka1 in lcw.Characteristics) { if (digit == charka1.ID_CHARACTERISTIC) { string rg = ""; string rt = ""; rt = resultProc.Split(' ')[g].Replace(resultProc.Split(' ')[g].Split(';')[1], charka1.CHARA_NAME); rt = rt.Replace(';', ' '); rg = String.Join(" ", rt.Split(' ').Reverse()); rg = rg.Replace(" ", ": "); dataGridView1.Rows.Add(); dataGridView1[place, rowi].Value = rg.ToString(); rowi++; break; } } } } if (place < 4) { place++; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }