예제 #1
0
        void bs_PositionChanged(object sender, EventArgs e)
        {
            if (toolStripComboBox1.ComboBox != null)
            {
                var selected = (CbbPageSize)toolStripComboBox1.ComboBox.SelectedItem;
                if (selected != null && selected.Value != null)
                {
                    take = selected.Value;
                }
            }

            this.Invoke(new MethodInvoker(delegate
            {
                if (bs.Position <= 0)
                {
                    page                     = 0;
                    skip                     = page * take;
                    var data                 = _assessmentService.GetAllAssessmentThao(skip, take, out total);
                    bs.DataSource            = new PageOffsetList(take, total);
                    dgvAssessment.DataSource = data;
                }
                else
                {
                    page          = bs.Position;
                    skip          = page * take;
                    var data      = _assessmentService.GetAllAssessmentThao(skip, take, out total);
                    bs.DataSource = new PageOffsetList(take, total);

                    while (data.Count == 0)
                    {
                        page          = bs.Position;
                        skip          = page * take;
                        data          = _assessmentService.GetAllAssessmentThao(skip, take, out total);
                        bs.DataSource = new PageOffsetList(take, total);
                    }
                    if (data.Count > 0)
                    {
                        dgvAssessment.DataSource = data;
                    }
                }
            }));
        }