/// <summary> /// 获取到当前数据集中总共有多少条记录 /// </summary> private void setRowCout(string status) { try { DataTable DT = new DataTable(); mUserPower = (Model.userPower)Session["Session_Power"]; string sql = "SELECT * FROM vProject_Apply_OrderSignet WHERE DELFLAG = 0 and PDEL=0"; if (mUserPower.isYinLeader.Equals("1") || status == "0" || status == "3") { sql += " and DoUserID='" + mUserPower.userid + "'"; } //if ((null != status && status.Equals("0")) || null != status && status.Equals("3")) //{ // sql = sql + " AND Status=" + status; //} //else //{ // sql = sql + " AND (Status=1 or Status=2)"; //} if (null != status) { sql = sql + " AND Status=" + status; } DT = pageControl.doSql(sql).Tables[0]; if (DT.Rows.Count > 0) { dtrowsHidden.Value = DT.Rows.Count.ToString(); } else { dtrowsHidden.Value = "0"; } } catch { } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string pageindex = null;//这里是为分页服务的 string projectstatus = ""; //使用mUserPower.isYinReader该项 mUserPower = (Model.userPower)Session["Session_Power"]; if (mUserPower.isYinLeader.Equals("1")) { HField_YYQX.Value = mUserPower.isYinLeader; Button_check.Visible = true; } pageindex = Request["pageindex"]; projectstatus = Request["Status"]; string count = dtrowsHidden.Value.ToString(); if (count.Length == 0) { if (null != projectstatus && !projectstatus.Equals("")) { setRowCout(projectstatus);//获取当前状态下有多少条数据记录,为分页提供页数和全部条数服务 } else { setRowCout("0");//获取当前状态下有多少条数据记录,为分页提供页数和全部条数服务 } count = dtrowsHidden.Value.ToString(); } else { count = "0"; } int countint = int.Parse(count); if (pageindex == null || pageindex == "") { pageindex = "1"; } int pageindex_int = int.Parse(pageindex); if (null == projectstatus || projectstatus.Equals("")) { projectstatus = "0"; } ShowListInfo(pageindex_int, projectstatus); if (null != Request["Status"]) { for (int i = 0; i < DDL_Status.Items.Count; i++) { if (DDL_Status.Items[i].Value.ToString().Equals(Request["Status"].ToString())) { DDL_Status.Items[i].Selected = true; } } } } //设置模板页中的管理值 (Master.FindControl("Label_navigation") as Label).Text = "管理 > 用印管理 "; //设置模板页中的管理值 }
/// <summary> ///显示待审核的项目列表信息 /// </summary> /// <param name="pageindex"></param> protected void ShowListInfo(int pageindex, string status) { try { DataTable DT = new DataTable(); mUserPower = (Model.userPower)Session["Session_Power"]; string sqlWhere1 = " DELFLAG = 0 and PDEL=0"; if (mUserPower.isYinLeader.Equals("1") || status == "0" || status == "3") { sqlWhere1 += " and DoUserID='" + mUserPower.userid + "'"; } //if ((null != status && status.Equals("0")) || null != status && status.Equals("3")) //{ // sqlWhere1 = sqlWhere1 + " AND Status=" + status; //} //else //{ // sqlWhere1 = sqlWhere1 + " AND (Status=1 or Status=2)"; //} if (null != status) { sqlWhere1 = sqlWhere1 + " AND Status=" + status; } string allTiaoshu = dtrowsHidden.Value.ToString();//获取到所有的条数 int alltiaoshuInt = int.Parse(allTiaoshu); DT = pageControl.GetList_FenYe_Common(sqlWhere1, pageindex, GridView1.PageSize, alltiaoshuInt, "vProject_Apply_OrderSignet", "ID").Tables[0]; pageindex = pageControl.pageindex(pageindex, GridView1.PageSize, alltiaoshuInt);//获取当前要显示的页码数【如果最后一页的最后一条记录被删除后,还能正常显示】 if (DT.Rows.Count > 0) { //当获取到的数据集不为空的时候,显示在GridView1中 GridView1.Visible = true; GridView1.DataSource = DT; //指定GridView1的数据是DT pageindexHidden.Value = pageindex.ToString(); //给隐藏的页码变量赋值,给下面的分页控件提供数据 GridView1.DataBind(); //将上面指定的信息绑定到GridView1上 Button_check.Enabled = true; tag.Text = ""; pageControl.SetSelectPage(pageindex, int.Parse(dtrowsHidden.Value.ToString()), DropDownList2, GridView1.PageSize, FirstPage, NextPage, PreviousPage, LastPage, Label_showInfo); //加载通用组件里面的分页函数 notice.Text = ""; pageControlShow.Visible = true; //如果记录集不为空,则显示分页控件 } else { GridView1.Visible = false; notice.Text = "*没有符合条件的结果!"; pageControlShow.Visible = false;//如果记录集为空,则不显示分页控件 Button_check.Enabled = false; if (alltiaoshuInt > 0) { ShowListInfo(pageindex - 1, status); } } } catch { } }