Example #1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (tbStudentNo.Text == "")
     {
         MessageBox.Show("学号不能为空!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         StudentManagerAction sma = new StudentManagerAction();
         Student student          = new Student(tbStudentNo.Text, tbStudentName.Text, cbSex.Text, tbBirthday.Text, (String)htDept[cbDept.Text]);
         sma.setStudent(student);
         if (sma.save())
         {
             ListViewItem li = new ListViewItem();
             li.SubItems.Clear();
             li.SubItems[0].Text = tbStudentNo.Text;
             li.SubItems.Add(tbStudentName.Text);
             li.SubItems.Add(cbSex.Text);
             li.SubItems.Add(tbBirthday.Text);
             li.SubItems.Add(cbDept.Text);
             lvStudentList.Items.Add(li);
             MessageBox.Show("添加成功!", "提示信息", MessageBoxButtons.OK);
         }
         tbStudentNo.Clear();
         tbStudentName.Clear();
         tbBirthday.Clear();
         cbSex.Text  = "";
         cbDept.Text = "";
     }
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string  deptId           = (string)ht[cbDept.Text];
            Student st               = new Student(tbStudentNo.Text, tbStudentName.Text, cbSex.Text, tbBirthday.Text, deptId);
            StudentManagerAction sma = new StudentManagerAction();

            sma.setStudent(st);
            if (sma.update())
            {
                MessageBox.Show("修改成功!", "提示信息", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("修改失败!", "提示信息", MessageBoxButtons.OK);
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            StudentManagerAction sma = new StudentManagerAction();
            Student student          = new Student(tbStudentNo.Text, tbStudentName.Text,
                                                   cbSex.Text, tbBirthday.Text, cbDept.Text);

            sma.setStudent(student);
            if (sma.save())
            {
                ListViewItem li = new ListViewItem();
                li.SubItems.Clear();
                li.SubItems[0].Text = tbStudentNo.Text;
                li.SubItems.Add(tbStudentName.Text);
                li.SubItems.Add(cbSex.Text);
                li.SubItems.Add(tbBirthday.Text);
                li.SubItems.Add(cbDept.Text);
                lvStudentList.Items.Add(li);
            }
        }
 private void button2_Click(object sender, EventArgs e)
 {
     if (lvStudentList.SelectedItems.Count == 0)
     {
         MessageBox.Show("请选择一条信息", "Error", MessageBoxButtons.OK);
         return;
     }
     else
     {
         this.ClientSize = new System.Drawing.Size(548, 540);
         string studentNo = lvStudentList.SelectedItems[0].Text.ToString();
         textBox1.Text = "学生姓名:" + lvStudentList.SelectedItems[0].SubItems[1].Text;
         Student st = new Student(studentNo, "", "", "", "");
         StudentManagerAction sma = new StudentManagerAction();
         sma.setStudent(st);
         sma.loadSelectedCourse(lvSelectedCourse);
         sma.loadUnselectedCourse(lvUnselectedCourse);
         lvStudentList.SelectedItems[0].Selected = false;
     }
 }
        private void button2_Click(object sender, EventArgs e)
        {
            if (lvStudentList.SelectedItems.Count == 0)
            {
                MessageBox.Show("请选择一条信息", "Error", MessageBoxButtons.OK);
                return;
            }
            string  studentNo        = lvStudentList.SelectedItems[0].Text.ToString();
            Student st               = new Student(studentNo, "", "", "", "");
            StudentManagerAction sma = new StudentManagerAction();

            sma.setStudent(st);
            if (sma.delete())
            {
                MessageBox.Show("该学生记录已删除!", "提示信息", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("删除失败!", "提示信息", MessageBoxButtons.OK);
            }
        }