private void btnAdd_Click(object sender, EventArgs e)
        {
            int i = 0;

            if (tbTeachCourseNo.Text.Trim().Equals(""))
            {
                MessageBox.Show("开课号不能为空", "提示");
                tbTeachCourseNo.Focus();
                return;
            }
            if (tbAmount.Text.Trim().Equals(""))
            {
                MessageBox.Show("学分不能为空", "提示");
                tbAmount.Focus();
                return;
            }
            if (tbTeacher.Text.Trim().Equals(""))
            {
                MessageBox.Show("学分不能为空", "提示");
                tbTeacher.Focus();
                return;
            }
            OpenCourse         oc  = new OpenCourse(tbTeachCourseNo.Text, cbCourseName.Text, tbTeacher.Text, int.Parse(tbAmount.Text), int.Parse(cbStartWeek.Text), int.Parse(cbEndWeek.Text));
            CourseManageAction cma = new CourseManageAction();

            cma.setOpenCourse(oc);
            if (isUpdate == false)
            {
                i = cma.addOpenCourse();
                if (i > 0)
                {
                    MessageBox.Show(string.Format("增加了{0}条记录", i));
                    foreach (Control ctrl in groupBox2.Controls)
                    {
                        if (!(ctrl is Label))
                        {
                            ctrl.Text = "";
                        }
                    }
                }
                else
                {
                    MessageBox.Show("添加不成功");
                }
            }
            else
            {
                i = cma.updateOpenCourse();
                if (i > 0)
                {
                    MessageBox.Show(string.Format("更新了{0}条记录", i));
                    this.Close();
                }
                else
                {
                    MessageBox.Show("更新不成功");
                }
            }
            this.Close();
        }
        //添加一条课程记录到teachcourse表
        public static int addOpenCourse(OpenCourse oc)
        {
            string wn  = QueryWorkerNo(oc.teacher);
            string cn  = QuerycourseNo(oc.courseName);
            string sql = " insert into teachcourse(teachcourseNo,courseNo,workerNo,amount,startWeek,endWeek) "
                         + "values('" + oc.teachCourseNo + "','" + cn + "','" + wn + "','" + oc.amount + "','" + oc.startWeek + "','" + oc.endWeek + "')";

            return(execNonQuery(sql));
        }
Exemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (lvLessons.SelectedItems.Count == 0)
            {
                return;
            }
            OpenCourse     oc  = CourseManageAction.QueryOpenCourseInfo(lvLessons.SelectedItems[0].SubItems[0].Text);
            studentInClass SIC = new studentInClass(oc);

            SIC.MdiParent = this.MdiParent;
            SIC.Show();
        }
Exemplo n.º 4
0
        private void btoRevise_Click(object sender, EventArgs e)
        {
            if (lvLessons.SelectedItems.Count == 0)
            {
                return;
            }
            OpenCourse oc = CourseManageAction.QueryOpenCourseInfo(lvLessons.SelectedItems[0].SubItems[0].Text);

            CourseManager.OpenCourseForm ocf = new OpenCourseForm(oc);
            ocf.MdiParent = this.MdiParent;
            ocf.Show();
        }
 public studentInClass(OpenCourse oc, string role = "教务员")
 {
     InitializeComponent();
     label5.Text = oc.teachCourseNo;
     label6.Text = oc.courseName;
     label7.Text = oc.teacher;
     label8.Text = CourseManageAction.NumberInClass(oc.teachCourseNo).ToString() + "/" + CourseManageAction.getAmount(oc.teachCourseNo).ToString();
     CourseManageAction.loadStudentInClass(lvSIC, oc.teachCourseNo);
     if (role == "教师")
     {
         button1.Visible = false;
     }
 }
        //更新一条记录到teachcourse表
        public static int updateOpenCourse(OpenCourse oc)
        {
            string wn  = QueryWorkerNo(oc.teacher);
            string cn  = QuerycourseNo(oc.courseName);
            string sql = "update teachcourse set "
                         + "amount='" + oc.amount
                         + "',courseNo='" + cn
                         + "',startWeek='" + oc.startWeek
                         + "',endWeek='" + oc.endWeek
                         + "',workerNo='" + wn + "'"
                         + " where teachCourseNo='" + oc.teachCourseNo + "'";

            return(execNonQuery(sql));
        }
 public OpenCourseForm(OpenCourse oc)
 {
     InitializeComponent();
     this.Text = "修改开课";
     tbTeachCourseNo.Enabled = false;
     tbTeachCourseNo.Text    = oc.teachCourseNo;
     cbCourseName.Text       = oc.courseName;
     tbTeacher.Text          = oc.teacher;
     tbAmount.Text           = oc.amount.ToString();
     cbStartWeek.Text        = oc.startWeek.ToString();
     cbEndWeek.Text          = oc.endWeek.ToString();
     isUpdate        = true;
     btnAdd.Text     = "保存修改";;
     tbCourseNo.Text = CourseManageAction.QuerycourseNo(oc.courseName);
 }
        //根据开课号查询开课信息
        public static OpenCourse QueryOpenCourseInfo(string tcNo)
        {
            string sql = "select teachCourseNo,courseName,workerName,amount,startWeek,endWeek from (teachcourse tc"
                         + " inner join teacher t on tc.workerNo=t.workerNo)"
                         + " inner join course c on c.courseNo=tc.courseNo"
                         + " where teachCourseNo='" + tcNo + "'";
            ArrayList ll = execQuery(sql);  //调用父类方法

            if (ll.Count == 0)
            {
                return(null);
            }
            object[]   o  = (object[])ll[0];
            OpenCourse oc = new OpenCourse(o[0].ToString(), o[1].ToString(), o[2].ToString(), int.Parse(o[3].ToString()), int.Parse(o[4].ToString()), int.Parse(o[5].ToString()));

            return(oc);
        }
 public void setOpenCourse(OpenCourse oc)
 {
     this.oc = oc;
 }