コード例 #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int i = 0;

            if (tbCourseNo.Text.Trim().Equals(""))
            {
                MessageBox.Show("不能为空", "提示");
                tbCourseNo.Focus();
                return;
            }
            Course             course = new Course(tbCourseNo.Text, tbCourseName.Text, float.Parse(tbPoint.Text));
            CourseManageAction cma    = new CourseManageAction();

            cma.setCourse(course);
            if (isUpdate == false)
            {
                i = cma.addCourse();
                if (i > 0)
                {
                    cma.updateDept(course, dept);
                    MessageBox.Show(string.Format("增加了{0}条记录", i));
                    foreach (Control ctrl in groupBox2.Controls)
                    {
                        if (!(ctrl is Label))
                        {
                            ctrl.Text = "";
                        }
                    }
                }
                else
                {
                    MessageBox.Show("添加不成功");
                }
            }
            else
            {
                i = cma.updateCourse();
                if (i > 0)
                {
                    MessageBox.Show(string.Format("更新了{0}条记录", i));
                    this.Close();
                }
                else
                {
                    MessageBox.Show("更新不成功");
                }
            }
            faculty.Close();
            this.Close();
        }