Пример #1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex != 0)
            {
                selectedSpecialty  = db.Specialties.FirstOrDefault(d => d.Name == comboBox1.SelectedItem.ToString());
                textBox1.Text      = selectedSpecialty.Name;
                selectedDepartment = db.Departments.FirstOrDefault(d => d.Name == selectedSpecialty.Department.Name);
                for (int i = 1; i < comboBox2.Items.Count; i++)
                {
                    if (comboBox2.Items[i].ToString() == selectedDepartment.Name)
                    {
                        comboBox2.SelectedIndex = i;
                        break;
                    }
                }

                button1.Enabled = true;
            }
            else
            {
                button1.Enabled = false;
            }
        }
Пример #2
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex != 0)
            {
                var num = Convert.ToInt32(comboBox1.SelectedItem);
                selectedGroup     = db.Groups.FirstOrDefault(d => d.Number == num);
                textBox1.Text     = selectedGroup.Number.ToString();
                selectedSpecialty = db.Specialties.FirstOrDefault(d => d.Name == selectedGroup.Specialty.Name);
                for (int i = 1; i < comboBox2.Items.Count; i++)
                {
                    if (comboBox2.Items[i].ToString() == selectedSpecialty.Name)
                    {
                        comboBox2.SelectedIndex = i;
                        break;
                    }
                }

                button1.Enabled = true;
            }
            else
            {
                button1.Enabled = false;
            }
        }