예제 #1
0
        public async Task <ActionResult> List(string search = "", int page = 1)
        {
            var data = await _adminsBll.GetAdminsByNickName(search);

            List <AdminsListViewModel> list = new List <AdminsListViewModel>();

            foreach (var item in data)
            {
                var role = await _rolesBll.GetRolesAsync(item.RolesId);

                AdminsListViewModel alvm = new AdminsListViewModel()
                {
                    Id         = item.Id,
                    Email      = item.Email,
                    Photo      = item.Photo,
                    NickName   = item.NickName,
                    UpdateTime = item.UpdateTime,
                    RolesTitle = role.Title
                };
                list.Add(alvm);
            }
            ViewBag.Search    = search;
            ViewBag.PageIndex = page;
            IPagedList <AdminsListViewModel> pages = list.ToPagedList(page, PageConfig.GetPageSize());

            return(View(pages));
        }
예제 #2
0
        //1. 每页展示多少条
        //2. 一共能分多少页
        public async Task <ActionResult> List(string search = "", int page = 1)
        {
            // 注册日志
            //ILog log = LogManager.GetLogger(typeof(RolesManagerController));
            // (1)得到数据总条数
            var count = await _rolesBll.GetRolesCountAsync(search);

            //  (2)设置总页数
            //var total = PageConfig.GetTotalPage(count);
            //  (3)设置每页要展示条数
            //var pageSize = PageConfig.GetPageSize();

            var data = await _rolesBll.GetRolesList(search, false);

            List <RolesListViewModel> list = new List <RolesListViewModel>();

            foreach (var item in data)
            {
                RolesListViewModel rlvm = new RolesListViewModel()
                {
                    Id         = item.Id,
                    Title      = item.Title,
                    UpdateTime = item.UpdateTime
                };
                list.Add(rlvm);
            }

            ViewBag.Search    = search;
            ViewBag.PageIndex = page;
            IPagedList <RolesListViewModel> pages = list.ToPagedList(page, PageConfig.GetPageSize());

            return(View(pages));
        }
 private void 查询全部学生成绩信息ToolStripMenuItem5_Click(object sender, EventArgs e)
 {
     //设定相关选项卡为选中状态
     this.skinTabControlDate.SelectedTab = skinTabPageSCmapping;
     SCMappingdt = scmbll.GetDataByPage(PageConfig.GetPageSize(), SCMappingDBIndex); //填充数据到临时数据表格
     skinDataGridViewSCMapping.DataSource = SCMappingdt;                             //填充数据显示控件
     skinLabelPage.Text = "当前第" + SCMappingDBIndex + "页/共" + SCMGetTotal() + "页";
 }
 private void 查询全部班级信息ToolStripMenuItem4_Click(object sender, EventArgs e)
 {
     //设定相关选项卡为选中状态
     this.skinTabControlDate.SelectedTab = skinTabPageClassInfo;
     classInfodt = clabll.GetDataByPage(PageConfig.GetPageSize(), ClassInfoDBIndex); //填充数据到临时数据表格
     skinDataGridViewClassInfo.DataSource = classInfodt;                             //填充数据显示控件
     skinLabelPage.Text = "当前第" + ClassInfoDBIndex + "页/共" + ClaGetTotal() + "页";
 }
 private void 查询全部教师数据ToolStripMenuItem2_Click(object sender, EventArgs e)
 {
     //设定相关选项卡为选中状态
     this.skinTabControlDate.SelectedTab = skinTabPageTeacher;
     Teacherdt = teabll.GetDataByPage(PageConfig.GetPageSize(), TeacherDBIndex); //填充数据到临时数据表格
     skinDataGridViewTeacher.DataSource = Teacherdt;                             //填充数据显示控件
     skinLabelPage.Text = "当前第" + TeacherDBIndex + "页/共" + TeaGetTotal() + "页";
 }
        /*工具栏相关操作===================================================*/

        private void 查询全部学生信息ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            //设定相关选项卡为选中状态
            this.skinTabControlDate.SelectedTab = skinTabPageStudent;
            Studentdt = stubll.GetDataByPage(PageConfig.GetPageSize(), StudentDBIndex); //填充数据到临时数据表格
            skinDataGridViewStudent.DataSource = Studentdt;                             //填充数据显示控件
            skinLabelPage.Text = "当前第" + StudentDBIndex + "页/共" + StuGetTotal() + "页";
        }
        /// <summary>
        /// 计算 SC_Mapping 表内数据可分出的页数总数
        /// </summary>
        /// <returns></returns>
        private int SCMGetTotal()
        {
            int total = scmbll.GetDBRows();

            if (total % PageConfig.GetPageSize() != 0)        //计算是否有余数
            {
                return(total / PageConfig.GetPageSize() + 1); //有余数多加1页
            }
            else
            {
                return(total / PageConfig.GetPageSize());    //正常分页
            }
        }
 /// <summary>
 /// 跳转至尾页
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SkinButtonRight_Click(object sender, EventArgs e)
 {
     //判断当前选中数据页
     if (skinTabControlDate.SelectedTab == skinTabPageStudent)
     {
         StudentDBIndex = StuGetTotal();
         Studentdt      = stubll.GetDataByPage(PageConfig.GetPageSize(), StuGetTotal()); //填充数据到临时数据表格
         skinDataGridViewStudent.DataSource = Studentdt;                                 //填充数据显示控件
         skinLabelPage.Text = "当前第" + StudentDBIndex + "页/共" + StuGetTotal() + "页";
     }
     else if (skinTabControlDate.SelectedTab == skinTabPageTeacher)
     {
         TeacherDBIndex = TeaGetTotal();
         Teacherdt      = teabll.GetDataByPage(PageConfig.GetPageSize(), TeaGetTotal()); //填充数据到临时数据表格
         skinDataGridViewTeacher.DataSource = Teacherdt;                                 //填充数据显示控件
         skinLabelPage.Text = "当前第" + TeacherDBIndex + "页/共" + TeaGetTotal() + "页";
     }
     else if (skinTabControlDate.SelectedTab == skinTabPageCourse)
     {
         CourseInfoDBIndex = CouGetTotal();
         CourseInfodt      = coubll.GetDataByPage(PageConfig.GetPageSize(), CourseInfoDBIndex); //填充数据到临时数据表格
         skinDataGridViewCourse.DataSource = CourseInfodt;                                      //填充数据显示控件
         skinLabelPage.Text = "当前第" + CourseInfoDBIndex + "页/共" + CouGetTotal() + "页";
     }
     else if (skinTabControlDate.SelectedTab == skinTabPageClassInfo)
     {
         ClassInfoDBIndex = ClaGetTotal();
         classInfodt      = clabll.GetDataByPage(PageConfig.GetPageSize(), ClassInfoDBIndex); //填充数据到临时数据表格
         skinDataGridViewClassInfo.DataSource = classInfodt;                                  //填充数据显示控件
         skinLabelPage.Text = "当前第" + ClassInfoDBIndex + "页/共" + ClaGetTotal() + "页";
     }
     else if (skinTabControlDate.SelectedTab == skinTabPageSCmapping)
     {
         SCMappingDBIndex = SCMGetTotal();
         SCMappingdt      = scmbll.GetDataByPage(PageConfig.GetPageSize(), SCMappingDBIndex); //填充数据到临时数据表格
         skinDataGridViewSCMapping.DataSource = SCMappingdt;                                  //填充数据显示控件
         skinLabelPage.Text = "当前第" + SCMappingDBIndex + "页/共" + SCMGetTotal() + "页";
     }
 }
 /// <summary>
 /// 下一页
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SkinButtonDown_Click(object sender, EventArgs e)
 {
     //判断当前选中数据页
     if (skinTabControlDate.SelectedTab == skinTabPageStudent)
     {
         StudentDBIndex++;
         if (StudentDBIndex > StuGetTotal())
         {
             MessageBox.Show("当前已经是最后一页", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             StudentDBIndex = StuGetTotal();
         }
         else
         {
             Studentdt = stubll.GetDataByPage(PageConfig.GetPageSize(), StudentDBIndex); //填充数据到临时数据表格
             skinDataGridViewStudent.DataSource = Studentdt;                             //填充数据显示控件
             skinLabelPage.Text = "当前第" + StudentDBIndex + "页/共" + StuGetTotal() + "页";
         }
     }
     else if (skinTabControlDate.SelectedTab == skinTabPageTeacher)
     {
         TeacherDBIndex++;
         if (TeacherDBIndex > TeaGetTotal())
         {
             MessageBox.Show("当前已经是最后一页", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             StudentDBIndex = TeaGetTotal();
         }
         else
         {
             Teacherdt = teabll.GetDataByPage(PageConfig.GetPageSize(), TeacherDBIndex); //填充数据到临时数据表格
             skinDataGridViewTeacher.DataSource = Teacherdt;                             //填充数据显示控件
             skinLabelPage.Text = "当前第" + TeacherDBIndex + "页/共" + TeaGetTotal() + "页";
         }
     }
     else if (skinTabControlDate.SelectedTab == skinTabPageCourse)
     {
         CourseInfoDBIndex++;
         if (CourseInfoDBIndex > CouGetTotal())
         {
             MessageBox.Show("当前已经是最后一页", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             CourseInfoDBIndex = CouGetTotal();
         }
         else
         {
             CourseInfodt = coubll.GetDataByPage(PageConfig.GetPageSize(), CourseInfoDBIndex); //填充数据到临时数据表格
             skinDataGridViewCourse.DataSource = CourseInfodt;                                 //填充数据显示控件
             skinLabelPage.Text = "当前第" + CourseInfoDBIndex + "页/共" + CouGetTotal() + "页";
         }
     }
     else if (skinTabControlDate.SelectedTab == skinTabPageClassInfo)
     {
         ClassInfoDBIndex++;
         if (ClassInfoDBIndex > ClaGetTotal())
         {
             MessageBox.Show("当前已经是最后一页", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             StudentDBIndex = ClaGetTotal();
         }
         else
         {
             classInfodt = clabll.GetDataByPage(PageConfig.GetPageSize(), ClassInfoDBIndex); //填充数据到临时数据表格
             skinDataGridViewClassInfo.DataSource = classInfodt;                             //填充数据显示控件
             skinLabelPage.Text = "当前第" + ClassInfoDBIndex + "页/共" + ClaGetTotal() + "页";
         }
     }
     else if (skinTabControlDate.SelectedTab == skinTabPageSCmapping)
     {
         SCMappingDBIndex++;
         if (SCMappingDBIndex > SCMGetTotal())
         {
             MessageBox.Show("当前已经是最后一页", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             SCMappingDBIndex = SCMGetTotal();
         }
         else
         {
             SCMappingdt = scmbll.GetDataByPage(PageConfig.GetPageSize(), SCMappingDBIndex); //填充数据到临时数据表格
             skinDataGridViewSCMapping.DataSource = SCMappingdt;                             //填充数据显示控件
             skinLabelPage.Text = "当前第" + SCMappingDBIndex + "页/共" + SCMGetTotal() + "页";
         }
     }
 }