Example #1
0
        /// <summary>
        /// 查询别的寝室
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click_1(object sender, EventArgs e)
        {
            listView1.Items.Clear();
            //获取学生信息数据
            Student    stu    = new Student();
            StudentDAO stuDao = new StudentDAO();

            stu = stuDao.getAllStudentById(textBox2.Text);
            //获取寝室有关数据
            DormitoryDAO   dmtDao = new DormitoryDAO();
            HealthScoreDAO hsDao  = new HealthScoreDAO();

            //提高加载速度,挂起ui
            listView1.BeginUpdate();
            //开始往listview中添加数据
            ListViewItem item   = new ListViewItem();
            ArrayList    hsList = hsDao.getHealthScoreByDorid(stu.Dorid);

            foreach (HealthScore hs in hsList)
            {
                DateTime dt    = DateTime.Now;
                String   month = dt.ToString().Substring(5, 2);
                //只显示当前月分数信息
                if (month.Equals(hs.Checkdate.ToString().Substring(5, 2)))
                {
                    Dormitory dmt = dmtDao.getDormitoriesByDmt(stu.Dorid);
                    item.Text = stu.Stuid.ToString();           //学号
                    item.SubItems.Add(stu.Stuname.ToString());  //姓名
                    item.SubItems.Add(stu.Dorid.ToString());    //寝室号
                    item.SubItems.Add(hs.Score.ToString());     //寝室分数
                    item.SubItems.Add(hs.Checkdate.ToString()); //修改时间
                    item.SubItems.Add(dmt.Dorhonor.ToString()); //寝室荣誉
                    listView1.Items.Add(item);
                }
            }
            //结束数据处理,开始一次绘制
            listView1.EndUpdate();
        }
Example #2
0
        /// <summary>
        /// 根据选定班级加载信息
        /// </summary>
        /// <param name="content"></param>
        public void GetStuInfomation(String content, String info)
        {
            listView1.Items.Clear();
            //获取班级信息表
            Department    dpt    = new Department();
            DepartmentDAO dptDAO = new DepartmentDAO();
            //获取到班级id
            Int32 selectDorid = dptDAO.GetDepidByDepName(content);
            //获取学生信息数据
            ArrayList  stuList = new ArrayList();
            StudentDAO stuDao  = new StudentDAO();

            stuList = stuDao.getAllStudentByDepid(selectDorid);
            //获取寝室有关数据
            DormitoryDAO   dmtDao = new DormitoryDAO();
            HealthScoreDAO hsDao  = new HealthScoreDAO();

            if (selectDorid != -1)
            {
                //提高加载速度,挂起ui
                listView1.BeginUpdate();
                //开始往listview中添加数据
                foreach (Student stu in stuList)
                {
                    ListViewItem item   = new ListViewItem();
                    ArrayList    hsList = hsDao.getHealthScoreByDorid(stu.Dorid);
                    foreach (HealthScore hs in hsList)
                    {
                        DateTime dt    = DateTime.Now;
                        String   month = dt.ToString().Substring(5, 2);
                        //只显示当前月分数信息
                        if (info.Equals("当前月"))
                        {
                            if (month.Equals(hs.Checkdate.ToString().Substring(5, 2)))
                            {
                                Dormitory dmt = dmtDao.getDormitoriesByDmt(stu.Dorid);
                                item.Text = stu.Stuid.ToString();           //学号
                                item.SubItems.Add(stu.Stuname.ToString());  //姓名
                                item.SubItems.Add(stu.Dorid.ToString());    //寝室号
                                item.SubItems.Add(hs.Score.ToString());     //寝室分数
                                item.SubItems.Add(hs.Checkdate.ToString()); //修改时间
                                item.SubItems.Add(dmt.Dorhonor.ToString()); //寝室荣誉
                                listView1.Items.Add(item);
                            }
                        }
                        else if (info.Equals("所有"))
                        {
                            Dormitory dmt = dmtDao.getDormitoriesByDmt(stu.Dorid);
                            item.Text = stu.Stuid.ToString();           //学号
                            item.SubItems.Add(stu.Stuname.ToString());  //姓名
                            item.SubItems.Add(stu.Dorid.ToString());    //寝室号
                            item.SubItems.Add(hs.Score.ToString());     //寝室分数
                            item.SubItems.Add(hs.Checkdate.ToString()); //修改时间
                            item.SubItems.Add(dmt.Dorhonor.ToString()); //寝室荣誉
                            listView1.Items.Add(item);
                        }
                    }
                }
                //结束数据处理,开始一次绘制ui
                listView1.EndUpdate();
            }
        }