UserSelect.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:8k
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using com.etong.user;
- using com.etong.Inform;
- public partial class UserSelect : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- AllUser user = new AllUser();
- DataSet ds = new DataSet();
- int flag = Convert.ToInt32(Request.QueryString["Flag"].ToString());
- if (flag == 1)
- {
- string UserAccount = Request.QueryString["UserAccount"].ToString();
- Panel1.Visible = false;
- Panel2.Visible = true;
- ds = user.GetUserIDFAccount(UserAccount);
- GridView2.DataSource = ds;
- GridView2.DataBind();
- }
- if (flag == 2)
- {
- string empname = Request.QueryString["UserAccount"].ToString();
- //string empname = Session["EmpName"].ToString();
- ds = user.GetUserID(empname);
- GridView1.DataSource = ds;
- GridView1.DataBind();
- }
- //else
- //{
- // Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('输入的参数出错!')</script>");
- // return;
- //}
- }
- }
- protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
- {
- string empname = Request.QueryString["UserAccount"].ToString();
- int currentpageindex;
- currentpageindex = Convert.ToInt32(e.NewPageIndex);
- if (currentpageindex == -2)
- {
- TextBox txtNewPageIndex;
- txtNewPageIndex = GridView1.BottomPagerRow.FindControl("LinkTextBoxNewPage") as TextBox;
- if (txtNewPageIndex != null)
- {
- try
- {
- currentpageindex = Convert.ToInt32(txtNewPageIndex.Text) - 1;
- }
- catch
- {
- currentpageindex = 0;
- }
- }
- }
- currentpageindex = currentpageindex < 0 ? 0 : currentpageindex;
- currentpageindex = currentpageindex >= GridView1.PageCount ? GridView1.PageCount - 1 : currentpageindex;
- GridView1.PageIndex = currentpageindex;
- AllUser user = new AllUser();
- DataSet ds = user.GetUserID(empname);
- GridView1.DataSource = ds;
- GridView1.DataBind();
- }
- protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
- {
- string UserAccount = Request.QueryString["UserAccount"].ToString();
- int currentpageindex;
- currentpageindex = Convert.ToInt32(e.NewPageIndex);
- if (currentpageindex == -2)
- {
- TextBox txtNewPageIndex;
- txtNewPageIndex = GridView1.BottomPagerRow.FindControl("LinkTextBoxNewPage") as TextBox;
- if (txtNewPageIndex != null)
- {
- try
- {
- currentpageindex = Convert.ToInt32(txtNewPageIndex.Text) - 1;
- }
- catch
- {
- currentpageindex = 0;
- }
- }
- }
- currentpageindex = currentpageindex < 0 ? 0 : currentpageindex;
- currentpageindex = currentpageindex >= GridView1.PageCount ? GridView1.PageCount - 1 : currentpageindex;
- GridView1.PageIndex = currentpageindex;
- AllUser user = new AllUser();
- DataSet ds = user.GetUserIDFAccount(UserAccount);
- GridView2.DataSource = ds;
- GridView2.DataBind();
- }
- protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
- {
- GridViewRow row = ((Control)e.CommandSource).BindingContainer as GridViewRow;
- int index = row.RowIndex;
- string Password = Request.QueryString["PassWord"].ToString();
- string UserIP = Request.QueryString["UserIP"].ToString();
- string empname = Request.QueryString["UserAccount"].ToString();
- if (e.CommandName == "Select")
- {
- int UserID = Convert.ToInt32(GridView1.DataKeys[index].Value.ToString());
- AllUser user = new AllUser();
- CheckUserInfo checkuserinfo = user.PCheckUser(UserID, Password, UserIP);
- if (checkuserinfo != null)
- {
- Session["checkuserinfo"] = checkuserinfo;
- if (Password == "111111")
- {
- Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>PwsDialog();</script>");
- return;
- }
- else
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>window.returnValue='success';window.close();</script>");
- return;
- }
- }
- else
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>window.returnValue='UserID=" + UserID + "&UserIP=" + UserIP + "';window.close();</script>");
- return;
- //string url = "PassWord.aspx?UserID=" + UserID + "&UserIP=" + UserIP ;
- //Response.Redirect(url);
- //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>APwsDialog('" + empname + "','" + UserIP + "',2);</script>");
- // return;
- }
- }
- }
- protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
- {
- GridViewRow row = ((Control)e.CommandSource).BindingContainer as GridViewRow;
- int index = row.RowIndex;
- string Password = Request.QueryString["PassWord"].ToString();
- string UserIP = Request.QueryString["UserIP"].ToString();
- string UserAccount = Request.QueryString["UserAccount"].ToString();
- if (e.CommandName == "Select")
- {
- int UserID = Convert.ToInt32(GridView2.DataKeys[index].Value.ToString());
- AllUser user = new AllUser();
- CheckUserInfo checkuserinfo = user.PCheckUser(UserID, Password, UserIP);
- if (checkuserinfo != null)
- {
- Session["checkuserinfo"] = checkuserinfo;
- if (Password == "111111")
- {
- Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>PwsDialog();</script>");
- return;
- }
- else
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>window.returnValue='success';window.close();</script>");
- return;
- }
- }
- else
- {
- this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>window.returnValue='UserID="+UserID+"&UserIP="+UserIP+"';window.close();</script>");
- return;
- //string url = "PassWord.aspx?UserID=" + UserID + "&UserIP=" + UserIP ;
- //Response.Redirect(url);
- //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>APwsDialog('" + UserAccount + "','" + UserIP + "',1);</script>");
- //return;
- }
- }
- }
- }