Rehab.aspx.cs
资源名称:精品OA.rar [点击查看]
上传用户:xgw_05
上传日期:2009-12-11
资源大小:20208k
文件大小:6k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Data.SqlClient;
- using System.Drawing;
- using System.Web;
- using System.Web.SessionState;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- using UDS.Components;
- namespace UDS.SubModule.Staff
- {
- /// <summary>
- /// Rehab 的摘要说明。
- /// </summary>
- public class Rehab : System.Web.UI.Page
- {
- protected System.Web.UI.WebControls.DataGrid StaffList;
- protected System.Web.UI.WebControls.TextBox txb_PageNo;
- protected System.Web.UI.WebControls.TextBox txb_ItemPerPage;
- protected System.Web.UI.WebControls.Label lbl_totalrecord;
- protected System.Web.UI.WebControls.ImageButton btn_first;
- protected System.Web.UI.WebControls.ImageButton btn_pre;
- protected System.Web.UI.WebControls.Label lbl_curpage;
- protected System.Web.UI.WebControls.Label lbl_totalpage;
- protected System.Web.UI.WebControls.ImageButton btn_next;
- protected System.Web.UI.WebControls.ImageButton btn_last;
- protected System.Web.UI.HtmlControls.HtmlInputButton selectbutton;
- protected System.Web.UI.HtmlControls.HtmlInputButton btn_Go;
- protected System.Web.UI.HtmlControls.HtmlInputButton cmdChangeDepartment;
- protected System.Web.UI.HtmlControls.HtmlInputButton cmdRestoreDocument;
- private void Page_Load(object sender, System.EventArgs e)
- {
- // 在此处放置用户代码以初始化页面
- if(!Page.IsPostBack)
- {
- BindGrid();
- }
- }
- /// <summary>
- /// 数据绑定
- /// </summary>
- private void BindGrid()
- {
- SqlDataReader dr; //存放人物的数据
- Database db = new Database();
- db.RunProc("sp_GetDimissionStaff",out dr);
- DataTable dt =Tools.ConvertDataReaderToDataTable(dr);
- //在DataTable的末尾加上空行,使得DataGrid固定行数
- int blankrows = StaffList.PageSize - (dt.Rows.Count % StaffList.PageSize);
- for (int i = 0; i < blankrows; i++)
- {
- dt.Rows.Add(dt.NewRow());
- }
- StaffList.DataSource = dt.DefaultView;
- StaffList.DataBind();
- //对于空纪录不显示checkbox
- for(int i=0;i<StaffList.Items.Count;i++)
- {
- if(StaffList.Items[i].Cells[1].Text==" ")
- {
- StaffList.Items[i].FindControl("cb_StaffID").Visible = false;
- }
- }
- lbl_totalrecord.Text =StaffList.PageCount.ToString();
- lbl_curpage.Text = txb_PageNo.Text = (StaffList.CurrentPageIndex + 1).ToString();
- txb_ItemPerPage.Text = StaffList.PageSize.ToString();
- lbl_totalpage.Text = StaffList.PageCount.ToString();
- }
- private void PagerButtonClick(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- //获得LinkButton的参数值
- String arg = ((ImageButton)sender).CommandArgument;
- switch(arg)
- {
- case ("next"):
- if (StaffList.CurrentPageIndex < (StaffList.PageCount - 1))
- StaffList.CurrentPageIndex ++;
- break;
- case ("pre"):
- if (StaffList.CurrentPageIndex > 0)
- StaffList.CurrentPageIndex --;
- break;
- case ("first"):
- StaffList.CurrentPageIndex=0;
- break;
- case ("last"):
- StaffList.CurrentPageIndex = (StaffList.PageCount - 1);
- break;
- default:
- //本页值
- StaffList.CurrentPageIndex = Convert.ToInt32(arg);
- break;
- }
- BindGrid();
- }
- private void btnGo_Click(object sender, System.EventArgs e)
- {
- //页面直接跳转的代码
- if(txb_PageNo.Text.Trim()!="")
- {
- int PageI=Int32.Parse(txb_PageNo.Text.Trim())-1;
- if (PageI >=0 && PageI < (StaffList.PageCount))
- StaffList.CurrentPageIndex = PageI ;
- }
- BindGrid();
- }
- private void txb_ItemPerPage_TextChanged(object sender, System.EventArgs e)
- {
- if(txb_ItemPerPage.Text.Trim()!="")
- {
- int itemPage=Int32.Parse(txb_ItemPerPage.Text.Trim());
- if(itemPage>0)
- StaffList.PageSize = Int32.Parse(txb_ItemPerPage.Text.Trim());
- }
- BindGrid();
- }
- private string GetSelectedItemID(string controlID)
- {
- String selectedID;
- selectedID = "";
- //遍历DataGrid获得checked的ID
- foreach (DataGridItem item in StaffList.Items)
- {
- if(((CheckBox)item.FindControl(controlID)).Checked)
- selectedID += item.Cells[1].Text.Trim()+",";
- }
- selectedID=selectedID.Substring(0,selectedID.Length-1);
- return selectedID;
- }
- #region Web Form Designer generated code
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
- //
- InitializeComponent();
- base.OnInit(e);
- }
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.btn_first.Click += new System.Web.UI.ImageClickEventHandler(this.PagerButtonClick);
- this.btn_pre.Click += new System.Web.UI.ImageClickEventHandler(this.PagerButtonClick);
- this.btn_next.Click += new System.Web.UI.ImageClickEventHandler(this.PagerButtonClick);
- this.btn_last.Click += new System.Web.UI.ImageClickEventHandler(this.PagerButtonClick);
- this.btn_Go.ServerClick += new System.EventHandler(this.btnGo_Click);
- this.txb_ItemPerPage.TextChanged += new System.EventHandler(this.txb_ItemPerPage_TextChanged);
- this.cmdChangeDepartment.ServerClick += new System.EventHandler(this.cmdChangeDepartment_ServerClick);
- this.cmdRestoreDocument.ServerClick += new System.EventHandler(this.cmdRestoreDocument_ServerClick);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- private void cmdChangeDepartment_ServerClick(object sender, System.EventArgs e)
- {
- Response.Redirect("../Department/ChangeDepartment.aspx?BackFilePath="+Request.CurrentExecutionFilePath+"&StaffIDS="+GetSelectedItemID("cb_StaffID"));
- }
- private void cmdRestoreDocument_ServerClick(object sender, System.EventArgs e)
- {
- UDS.Components.Staff st = new UDS.Components.Staff();
- if(st.ReturnPosition(GetSelectedItemID("cb_StaffID"))==false)
- Server.Transfer("../Error.aspx");
- else
- Response.Redirect("Rehab.aspx");
- }
- }
- }