예제 #1
0
        private void btnEnterClass_Click(object sender, EventArgs e)
        {
            //记录点击的是哪个控件
            TeachClass clickTeachClass = (TeachClass)sender;
            //动态加载BreifView界面,需要知道当前课程名,课程id,老师id,老师姓名
            BreifView newBreif = new BreifView(clickTeachClass.labelClassId1.Content.ToString(), clickTeachClass.labelClassName1.Content.ToString(), tbTeacherInfo.Text, tbTeacherInfo1.Text, this.pngfile);

            newBreif.pngfile = this.pngfile;
            newBreif.Show();
            this.Visibility = System.Windows.Visibility.Hidden;
        }
예제 #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);
                }
            }
        }