//初始化 public void InitData() { try { ViewState["page"] = 0; List <Common.Entities.AchievementCA> list = ca.FindPaged(Convert.ToInt32(Session["SecrecyLevel"])); Grid_AchievementCA.RecordCount = list.Count(); if (list != null) { Grid_AchievementCA.DataSource = list.Skip(Grid_AchievementCA.PageIndex * Grid_AchievementCA.PageSize).Take(Grid_AchievementCA.PageSize); Grid_AchievementCA.DataBind(); } } catch (Exception ex) { pm.SaveError(ex, this.Request); } }
//全选按钮 protected void btnSelect_All_Click(object sender, EventArgs e) { Grid_AchievementCA.SelectAllRows(); int[] select = Grid_AchievementCA.SelectedRowIndexArray; int m; //取整数(不是四舍五入,全舍) int Pages = (int)Math.Floor(Convert.ToDouble(Grid_AchievementCA.RecordCount / this.Grid_AchievementCA.PageSize)); if (Grid_AchievementCA.PageIndex == Pages) { m = (Grid_AchievementCA.RecordCount - this.Grid_AchievementCA.PageSize * Grid_AchievementCA.PageIndex); } else { m = this.Grid_AchievementCA.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 FindByName() { try { ViewState["page"] = 1; List <int> achieve = ach.FindByAchievementNamelist(tCondition.Text.Trim()); List <Common.Entities.AchievementCA> list = ca.FindByAchievementName(achieve, Convert.ToInt32(Session["SecrecyLevel"])); Convert.ToInt32(Session["SecrecyLevel"]); Grid_AchievementCA.RecordCount = list.Count(); if (list != null) { Grid_AchievementCA.DataSource = list.Skip(Grid_AchievementCA.PageIndex * Grid_AchievementCA.PageSize).Take(Grid_AchievementCA.PageSize); Grid_AchievementCA.DataBind(); } } catch (Exception ex) { pm.SaveError(ex, this.Request); } }
//按完成人搜索 public void FindByPeople() { try { ViewState["page"] = 4; List <int> UserInfoID = user.FindList(tCondition.Text.Trim(), Convert.ToInt32(Session["SecrecyLevel"])); List <int> AchieveID = blst.SelectIDlist(UserInfoID, Convert.ToInt32(Session["SecrecyLevel"])); List <Common.Entities.AchievementCA> list = ca.FindByAchievementName(AchieveID, Convert.ToInt32(Session["SecrecyLevel"])); Grid_AchievementCA.RecordCount = list.Count(); if (list != null) { Grid_AchievementCA.DataSource = list.Skip(Grid_AchievementCA.PageIndex * Grid_AchievementCA.PageSize).Take(Grid_AchievementCA.PageSize); Grid_AchievementCA.DataBind(); } } catch (Exception ex) { pm.SaveError(ex, this.Request); } }
//按验收评语级别 public void FindByCACommnetLevel() { try { //保存当前的搜索状态 ViewState["page"] = 5; //获取到查询结果 List <Common.Entities.AchievementCA> list = ca.FindByCACommnetLevel(tCondition.Text.Trim(), Convert.ToInt32(Session["SecrecyLevel"])); //结果数量传给前台 Grid_AchievementCA.RecordCount = list.Count(); if (list != null) { Grid_AchievementCA.DataSource = list.Skip(Grid_AchievementCA.PageIndex * Grid_AchievementCA.PageSize).Take(Grid_AchievementCA.PageSize); Grid_AchievementCA.DataBind(); } } catch (Exception ex) { pm.SaveError(ex, this.Request); } }
//导出 protected void btn_Get_Click(object sender, EventArgs e) { try { if (page == 0) { List <Common.Entities.AchievementCA> list = ca.FindPaged(Convert.ToInt32(Session["SecrecyLevel"])); if (list != null) { Grid_AchievementCA.DataSource = list; Grid_AchievementCA.DataBind(); } } if (page == 1) { List <int> achieve = ach.FindByAchievementNamelist(tCondition.Text.Trim()); List <Common.Entities.AchievementCA> list = ca.FindByAchievementName(achieve, Convert.ToInt32(Session["SecrecyLevel"])); Convert.ToInt32(Session["SecrecyLevel"]); if (list != null) { Grid_AchievementCA.DataSource = list; Grid_AchievementCA.DataBind(); } } if (page == 2) { List <Common.Entities.AchievementCA> list = ca.FindByCATime(Convert.ToInt32(dCondition.SelectedText.Trim()), Convert.ToInt32(Session["SecrecyLevel"])); if (list != null) { Grid_AchievementCA.DataSource = list; Grid_AchievementCA.DataBind(); } } if (page == 3) { List <Common.Entities.AchievementCA> list = ca.FindByCAUnit(tCondition.Text.Trim(), Convert.ToInt32(Session["SecrecyLevel"])); if (list != null) { Grid_AchievementCA.DataSource = list; Grid_AchievementCA.DataBind(); } } if (page == 4) { List <int> UserInfoID = user.FindList(tCondition.Text.Trim(), Convert.ToInt32(Session["SecrecyLevel"])); List <int> AchieveID = blst.SelectIDlist(UserInfoID, Convert.ToInt32(Session["SecrecyLevel"])); List <Common.Entities.AchievementCA> list = ca.FindByAchievementName(AchieveID, Convert.ToInt32(Session["SecrecyLevel"])); if (list != null) { Grid_AchievementCA.DataSource = list; Grid_AchievementCA.DataBind(); } } if (page == 5) { List <Common.Entities.AchievementCA> list = ca.FindByCACommnetLevel(tCondition.Text.Trim(), Convert.ToInt32(Session["SecrecyLevel"])); if (list != null) { Grid_AchievementCA.DataSource = list; Grid_AchievementCA.DataBind(); } } if (page == 6) { List <Common.Entities.AchievementCA> list = ca.FindPaged(Convert.ToInt32(Session["SecrecyLevel"])); if (list != null) { Grid_AchievementCA.DataSource = list; Grid_AchievementCA.DataBind(); } } if (page == 7) { List <Common.Entities.AchievementCA> list = ca.FindByMember(tCondition.Text.Trim(), Convert.ToInt32(Session["SecrecyLevel"])); if (list != null) { Grid_AchievementCA.DataSource = list; Grid_AchievementCA.DataBind(); } } pm.ExportExcel(3, Grid_AchievementCA, 1); } catch (Exception ex) { pm.SaveError(ex, this.Request); } }