예제 #1
0
        public CheckingClassHomework(string homeworkTitle, string description, string teacherSpecId, string teacherName, string classSpecId, string className, string pgfile)
        {
            //生成基本信息
            InitializeComponent();
            this.pngfile = pgfile;

            //设置该img控件的Source
            headImage.Source = new BitmapImage(new Uri(System.IO.Path.GetFullPath(System.IO.Path.Combine(System.Environment.CurrentDirectory, @pngfile))));
            // int sex = int.Parse(td.getSexByTeaSpecId(tbTeacherInfo.Text.ToString()).Rows[0][0].ToString());   //有问题


            lbNotTitle.Content              = homeworkTitle;
            textBlockDescription.Text       = description;
            textBlockDescription.IsReadOnly = true;
            tbTeacherInfo.Text              = teacherSpecId;
            tbTeacherInfo1.Text             = teacherName;
            tbClassInfo.Text  = classSpecId;
            tbClassInfo1.Text = className;
            labelHomeworkArrangeTime.Content = "发布时间:" + ts.pasteSubmitTimeInForm(classSpecId, homeworkTitle);
            //加载已批改的动态控件

            loadCorrected(classSpecId, homeworkTitle);
            //加载待批改的动态控件

            loadNeedCorrect(classSpecId, homeworkTitle);
            //加载未完成的动态控件

            loadUnfinished(classSpecId, homeworkTitle);


            //获得notid
            DataTable tableClassId = ts.getClassId(classSpecId);
            DataTable tableNotId   = ts.getNotIdByClassIdAndNotTitle(homeworkTitle, Convert.ToInt32(tableClassId.Rows[0][0]));

            notId = tableNotId.Rows[0][0].ToString();
            //对查看相关附件按钮进行初始化:能够实现鼠标放上去之后显示作业附件的名称
            //根据notId获得notURLName

            string notURLName = ts.getNotURLNameByNotId(int.Parse(notId)).Rows[0][0].ToString();

            //加载作业附件名
            if (notURLName == "")
            {
                labelAccessoryName1.ToolTip = "该作业公告无作业附件";
            }
            else
            {
                labelAccessoryName1.ToolTip = notURLName;
            }
            btnRefresh.ToolTip = "刷新,查看该作业公告最新作业完成情况";
        }
예제 #2
0
        //删除作业公告按钮点击事件
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            //删除服务器上的作业附件
            //需要把所有学生表里的作业都删掉
            //首先根据课堂具体工号找到classId
            //然后找到该classId下title对应的notId
            //然后执行删除公告操作(业务层),在该业务层需要先删除作业附件,再调用删除作业表上的所有作业,再删除所有作业公告


            MessageBoxResult dr = System.Windows.MessageBox.Show("此操作将会导致该公告所有已交作业被删除,是否确定删除该作业?", "", MessageBoxButton.OKCancel, MessageBoxImage.Question);

            if (dr == MessageBoxResult.OK)
            {
                System.Windows.Controls.Button sonBtn = (System.Windows.Controls.Button)sender;  //获取当前点击的那个具体作业
                //获取父级元素,找到要删除的公告
                Grid          sonGrid         = (Grid)sonBtn.Parent;
                BreifHomework clickTeachClass = (BreifHomework)sonGrid.Parent;
                DataTable     tableClassId    = ts.getClassId(labelCourseNumber.Content.ToString());
                DataTable     tableNotId      = ts.getNotIdByClassIdAndNotTitle(clickTeachClass.title.Content.ToString(), Convert.ToInt32(tableClassId.Rows[0][0]));
                int           stuNum          = int.Parse(ts.getStuNum(tableClassId.Rows[0][0].ToString()));
                if (stuNum == 0)
                {
                    bool flag0 = ts.deleteNotice(tableNotId.Rows[0][0].ToString());   //学生人数为0,可以直接删除
                    if (flag0 == true)
                    {
                        System.Windows.MessageBox.Show("删除成功");
                        homeworkListView.Items.Remove(clickTeachClass);
                    }
                    else
                    {
                        System.Windows.MessageBox.Show("删除失败");
                    }
                }
                else
                {
                    String ifDelete = ts.deleteHomeworkNotice(labelCourseNumber.Content.ToString(), clickTeachClass.title.Content.ToString());  //删除时要考虑到与作业表级联删除的情况

                    if (ifDelete == "删除该作业公告成功")
                    {
                        System.Windows.MessageBox.Show("删除该作业公告成功");
                        homeworkListView.Items.Remove(clickTeachClass);
                    }
                    else
                    {
                        System.Windows.MessageBox.Show(ifDelete);
                    }
                }
            }
        }