示例#1
0
 private void ButtonChoose_Click(object sender, EventArgs e)
 {
     if ((Type)ComboBoxMain.SelectedItem == typeof(Faculty))
     {
         ActiveForm.Hide();
         FormAddFaculty f = new FormAddFaculty(null);
         f.Show();
     }
     if ((Type)ComboBoxMain.SelectedItem == typeof(Chair))
     {
         ActiveForm.Hide();
         FormAddChair f = new FormAddChair(null);
         f.Show();
     }
     if ((Type)ComboBoxMain.SelectedItem == typeof(Teacher))
     {
         ActiveForm.Hide();
         FormAddTeacher f = new FormAddTeacher(null);
         f.Show();
     }
     if ((Type)ComboBoxMain.SelectedItem == typeof(Discipline))
     {
         ActiveForm.Hide();
         FormAddDiscipline f = new FormAddDiscipline(null);
         f.Show();
     }
 }
示例#2
0
        private void ButtonUpdate_Click(object sender, EventArgs e)
        {
            if (TreeViewMain.SelectedNode == null)
            {
                MessageBox.Show("Please select the node to update.");
                return;
            }
            if (TreeViewMain.SelectedNode.Level != 1)
            {
                MessageBox.Show("Cannot update entity.");
                return;
            }
            Type    recordType = (Type)TreeViewMain.SelectedNode.Parent.Tag;
            dynamic channel    = Connector.Channels[recordType];
            dynamic item       = channel.Read((int)TreeViewMain.SelectedNode.Tag);

            ActiveForm.Hide();
            Form newForm = null;

            if (recordType == typeof(Faculty))
            {
                newForm = new FormAddFaculty(item);
            }
            if (recordType == typeof(Chair))
            {
                newForm = new FormAddChair(item);
            }
            if (recordType == typeof(Teacher))
            {
                newForm = new FormAddTeacher(item);
            }
            if (recordType == typeof(Discipline))
            {
                newForm = new FormAddDiscipline(item);
            }
            newForm.Show();
        }