//全选按钮 protected void btnSelect_All_Click(object sender, EventArgs e) { Grid_UnitInspect.SelectAllRows(); int[] select = Grid_UnitInspect.SelectedRowIndexArray; int m; //取整数(不是四舍五入,全舍) int Pages = (int)Math.Floor(Convert.ToDouble(Grid_UnitInspect.RecordCount / this.Grid_UnitInspect.PageSize)); if (Grid_UnitInspect.PageIndex == Pages) { m = (Grid_UnitInspect.RecordCount - this.Grid_UnitInspect.PageSize * Grid_UnitInspect.PageIndex); } else { m = this.Grid_UnitInspect.PageSize; } bool isCheck = false; for (int i = 0; i < m; i++) { if (CBoxSelect.GetCheckedState(i) == false) { isCheck = true; } } if (isCheck) { foreach (int item in select) { CBoxSelect.SetCheckedState(item, true); } btnDelete.Enabled = true; btnSelect_All.Text = "取消全选"; } else { foreach (int item in select) { CBoxSelect.SetCheckedState(item, false); } btnDelete.Enabled = false; btnSelect_All.Text = "全选"; } }
//初始化 public void InitData() { try { ViewState["page"] = 0; List <UnitInspect> list = inspect.FindPaged(Convert.ToInt32(Session["SecrecyLevel"])); Grid_UnitInspect.RecordCount = list.Count(); if (list != null) { Grid_UnitInspect.DataSource = list.Skip(Grid_UnitInspect.PageIndex * Grid_UnitInspect.PageSize).Take(Grid_UnitInspect.PageSize); Grid_UnitInspect.DataBind(); } btnDelete.Enabled = false; } catch (Exception ex) { pm.SaveError(ex, this.Request); } }
private void FindByWorkPlace() { try { ViewState["page"] = 2; Grid_UnitInspect.PageIndex = 0; List <UnitInspect> list = inspect.FindByWorkPlace(tb_content.Text.Trim(), Convert.ToInt32(Session["SecrecyLevel"])); Grid_UnitInspect.RecordCount = list.Count(); if (list != null) { Grid_UnitInspect.DataSource = list.Skip(Grid_UnitInspect.PageIndex * Grid_UnitInspect.PageSize).Take(Grid_UnitInspect.PageSize); Grid_UnitInspect.DataBind(); } btnDelete.Enabled = false; } catch (Exception ex) { pm.SaveError(ex, this.Request); } }
//导出 protected void btn_Get_Click(object sender, EventArgs e) { try { if (page == 1) { List <UnitInspect> list = new List <UnitInspect>(); if (dCondition.SelectedText.Trim() == "全部") { list = inspect.FindPaged(Convert.ToInt32(Session["SecrecyLevel"])); } else { list = inspect.FindByInspectTime(Convert.ToInt32(dCondition.SelectedText.Trim()), Convert.ToInt32(Session["SecrecyLevel"])); } if (list != null) { Grid_UnitInspect.DataSource = list; Grid_UnitInspect.DataBind(); } } if (page == 0) { List <UnitInspect> list = inspect.FindPaged(Convert.ToInt32(Session["SecrecyLevel"])); if (list != null) { Grid_UnitInspect.DataSource = list; Grid_UnitInspect.DataBind(); } } pm.ExportExcel(3, Grid_UnitInspect, 2); } catch (Exception ex) { pm.SaveError(ex, this.Request); return; } }