private void comboBox3_SelectionChanged(object sender, SelectionChangedEventArgs e) { int index = comboBox1.SelectedIndex; switch (index) { case 0: { if (comboBox2.SelectedValue.ToString() == "One") { try { richTextBox.Document.Blocks.Clear(); chemistryController = new ChemistryElementController(); int id = int.Parse(comboBox3.SelectedValue.ToString()); string block = "---------------------------------------------\n"; richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + chemistryController.findOne(id).ToString() + "\n" + block))); chemistryController.close(); } catch (Exception ex) { MessageBox.Show("Firstly select id of element!!!"); } } } break; case 1: { if (comboBox2.SelectedValue.ToString() == "One") { try { richTextBox.Document.Blocks.Clear(); organicController = new OrganicController(); int id = int.Parse(comboBox3.SelectedValue.ToString()); string block = "---------------------------------------------\n"; richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + organicController.finOne(id).ToString() + "\n" + block))); organicController.close(); } catch (Exception ex) { MessageBox.Show("Firstly select id of element!!!"); } } } break; case 2: { if (comboBox2.SelectedValue.ToString() == "One") { try { richTextBox.Document.Blocks.Clear(); pageController = new PageController(); int id = int.Parse(comboBox3.SelectedValue.ToString()); string block = "---------------------------------------------\n"; richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + pageController.findOne(id).ToString() + "\n" + block))); pageController.close(); } catch (Exception ex) { MessageBox.Show("Firstly select id of element!!!"); } } } break; case 3: { if (comboBox2.SelectedValue.ToString() == "One") { try { richTextBox.Document.Blocks.Clear(); imageController = new ImageController(); int id = int.Parse(comboBox3.SelectedValue.ToString()); string block = "---------------------------------------------\n"; richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + imageController.findOne(id).ToString() + "\n" + block))); imageController.close(); } catch (Exception ex) { MessageBox.Show("Firstly select id of element!!!"); } } } break; } }
private void comboBox2_SelectionChanged(object sender, SelectionChangedEventArgs e) { int index = comboBox1.SelectedIndex; switch (index) { case 0: { richTextBox.Document.Blocks.Clear(); chemistryController = new ChemistryElementController(); if (comboBox2.SelectedIndex == 0) { List <ChemistryElement> elements = chemistryController.findAll(); foreach (ChemistryElement element in elements) { richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + element.ToString() + "\n" + block))); } } else { richTextBox.Document.Blocks.Clear(); try { if (comboBox3.SelectedValue.ToString() != "") { int id = int.Parse(comboBox3.SelectedValue.ToString()); richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + chemistryController.findOne(id).ToString() + "\n" + block))); } } catch (Exception ex) { MessageBox.Show("Firstly select id of element!!!"); } } chemistryController.close(); } break; case 1: { richTextBox.Document.Blocks.Clear(); organicController = new OrganicController(); if (comboBox2.SelectedIndex == 0) { List <OrganicElement> elements = organicController.findAll(); foreach (OrganicElement element in elements) { richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + element.ToString() + "\n" + block))); } } else { richTextBox.Document.Blocks.Clear(); try { if (comboBox3.SelectedValue.ToString() != "") { int id = int.Parse(comboBox3.SelectedValue.ToString()); richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + organicController.finOne(id).ToString() + "\n" + block))); } } catch (Exception ex) { MessageBox.Show("Firstly select id of element!!!"); } } organicController.close(); } break; case 2: { richTextBox.Document.Blocks.Clear(); pageController = new PageController(); if (comboBox2.SelectedIndex == 0) { List <PageWithTextAndImage> elements = pageController.findAll(); foreach (PageWithTextAndImage element in elements) { richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + element.ToString() + "\n" + block))); } } else { richTextBox.Document.Blocks.Clear(); try { if (comboBox3.SelectedValue.ToString() != "") { int id = int.Parse(comboBox3.SelectedValue.ToString()); richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + pageController.findOne(id).ToString() + "\n" + block))); } } catch (Exception ex) { MessageBox.Show("Firstly select id of element!!!"); } } pageController.close(); } break; case 3: { richTextBox.Document.Blocks.Clear(); imageController = new ImageController(); if (comboBox2.SelectedIndex == 0) { List <Picture> elements = imageController.findAll(); foreach (Picture element in elements) { richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + element.ToString() + "\n" + block))); } } else { richTextBox.Document.Blocks.Clear(); try { if (comboBox3.SelectedValue.ToString() != "") { int id = int.Parse(comboBox3.SelectedValue.ToString()); richTextBox.Document.Blocks.Add(new Paragraph(new Run(block + imageController.findOne(id).ToString() + "\n" + block))); } } catch (Exception ex) { MessageBox.Show("Firstly select id of element!!!"); } } imageController.close(); } break; } }