예제 #1
0
 public void BindClass(ClassType ct)
 {
     switch (ct)
     {
         case ClassType.LabClass:
             LabClassBLL lcb = new LabClassBLL();
             cmbClass.DataSource = null;
             cmbClass.DataSource = lcb.GetAllLabClass();
             cmbClass.DisplayMember = "LabClassID";
             cmbClass.ValueMember = "LabClassID";
             break;
         case ClassType.TheoryClass:
             TheoryClassBLL tcb = new TheoryClassBLL();
             cmbClass.DataSource = null;
             cmbClass.DataSource = tcb.GetAllTheoryClass();
             cmbClass.DisplayMember = "TheoryClassID";
             cmbClass.ValueMember = "TheoryClassID";
             break;
     }
 }
예제 #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (rdbLab.Checked)
            {
                 LabClass classinfo = new LabClass()
                {
                    LabClassID = txtClassID.Text,
                    LabClassRoom = txtClassRoom.Text,
                    Date = txtDate.Text,
                    TheoryClassID=cmbTheroyClass.ClassID
                };

                LabClassBLL bclass = new LabClassBLL();
                try
                {
                    if (bclass.AddClass(classinfo))
                        MessageBox.Show("��ӳɹ�");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else if(rdbTheroy.Checked)
            {
                TheoryClass classinfo = new TheoryClass()
                {
                    TheoryClassID = txtClassID.Text,
                    TheoryClassRoom = txtClassRoom.Text,
                    Date = txtDate.Text
                };
                TheoryClassBLL bclass = new TheoryClassBLL();
                try
                {
                    if (bclass.AddClass(classinfo))
                        MessageBox.Show("��ӳɹ�");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                LabClass classinfo = new LabClass()
                {
                    LabClassID = txtClassID.Text,
                    LabClassRoom = txtClassRoom.Text,
                    Date = txtDate.Text
                };

                LabClassBLL bclass = new LabClassBLL();
                try
                {
                    if (bclass.AddClass(classinfo))
                        MessageBox.Show("��ӳɹ�");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }