Beispiel #1
0
        //点击近期作业公告事件
        private void btnRecntNo1_Click(object sender, RoutedEventArgs e)
        {
            //有一个按钮还是有问题,就一个
            Button sonBtn = (Button)sender;  //获取当前点击的那个button
            RecentNoticeControll clickRectNotice = (RecentNoticeControll)sonBtn.Parent;
            string homeworkTitle = clickRectNotice.labelNotName.Content.ToString();
            string description   = clickRectNotice.desrciption;
            string teacherSpecId = tbTeacherInfo.Text;
            string teacherName   = tbTeacherInfo1.Text;
            string classSpecId   = clickRectNotice.classSpecId;
            string className     = clickRectNotice.className;
            CheckingClassHomework newCheckingClassHomework = new CheckingClassHomework(homeworkTitle, description, teacherSpecId, teacherName, classSpecId, className, this.pngfile);

            newCheckingClassHomework.pngfile = this.pngfile;
            newCheckingClassHomework.Show();
            this.Visibility = System.Windows.Visibility.Hidden;
        }
Beispiel #2
0
        //构造函数,其中包括加载用户自定义控件
        public TeacherMainForm(string session, string tname, 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))));
            try
            {
                if (session != null)
                {
                    tbTeacherInfo.Text  = session;
                    tbTeacherInfo1.Text = tname;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("界面间传值发生异常" + ex.Message);
            }

            //AnnounceNoticeDao temp = new AnnounceNoticeDao();
            //两个方法类
            DataTable tableTeacherId = ts.getTeacherId(session);
            DataTable table          = ts.loadMainFormLeft(tbTeacherInfo.Text);

            TeachClass[] arrayTeachClass = new TeachClass[10];
            //给自定义控件的子控件加属性
            for (int i = 0; i < table.Rows.Count; i++)
            {
                arrayTeachClass[i]      = new TeachClass();
                arrayTeachClass[i].Name = "array" + i.ToString();
                arrayTeachClass[i].labelClassId1.Content      = table.Rows[i][5];
                arrayTeachClass[i].labelNoticeNumber.Content  = "已发布公告数:" + ts.getNoticeNum(table.Rows[i][0].ToString());
                arrayTeachClass[i].labelStudentNumber.Content = "当前课堂人数:" + ts.getStuNum(table.Rows[i][0].ToString());
                arrayTeachClass[i].labelClassName1.Content    = table.Rows[i][1].ToString();
                listViewTeacherClass.Items.Add(arrayTeachClass[i]);
                //arrayBreifHomework[i].btnModify.Click += new RoutedEventHandler(btnModify_Click);
                arrayTeachClass[i].MouseDown += new System.Windows.Input.MouseButtonEventHandler(mousedown);
                //arrayTeachClass[i].btnEnterClass.Click += new RoutedEventHandler(btnModify_Click);
            }
            //查到老师当前教的课程的id


            DataTable tableclassId = ts.getClassIdByTId(tableTeacherId.Rows[0][0].ToString());

            RecentNoticeControll[] arrayRecentNotice = new RecentNoticeControll[20];
            //动态生成控件
            DataTable tableRecentNotice;


            for (int j = 0; j < tableclassId.Rows.Count; j++)
            {
                tableRecentNotice = ts.getRecentNoticeByClassId(tableclassId.Rows[j][0].ToString());     //获得对应classId在notice表中的内容
                DataTable tableclassInfo = ts.getClassInfoByClassID(tableclassId.Rows[j][0].ToString()); //获得对应classId在class表中的其他内容
                int       noticeNum      = tableRecentNotice.Rows.Count;
                for (int k = 0; k < noticeNum; k++)
                {
                    arrayRecentNotice[k] = new RecentNoticeControll();
                    arrayRecentNotice[k].labelNotName.Content = tableRecentNotice.Rows[noticeNum - 1 - k][7];
                    //为UserControl的属性赋值
                    arrayRecentNotice[k].desrciption = tableRecentNotice.Rows[noticeNum - 1 - k][4].ToString();
                    // MessageBox.Show(tableclassInfo.Rows[1][1].ToString());
                    arrayRecentNotice[k].className   = tableclassInfo.Rows[0][1].ToString(); //有问题
                    arrayRecentNotice[k].classSpecId = tableclassInfo.Rows[0][5].ToString();

                    listViewRecentNotice.Items.Add(arrayRecentNotice[k]);
                    //定义点击查看作业公告详情按钮
                    arrayRecentNotice[k].btnRecntNo1.Click += new RoutedEventHandler(btnRecntNo1_Click);
                }
            }
        }