UserSelect.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:8k
源码类别:

.net编程

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using com.etong.user;
  12. using com.etong.Inform;
  13. public partial class UserSelect : System.Web.UI.Page
  14. {
  15.     protected void Page_Load(object sender, EventArgs e)
  16.     {
  17.         if (!IsPostBack)
  18.         {
  19.             AllUser user = new AllUser();
  20.             DataSet ds = new DataSet();
  21.             int flag = Convert.ToInt32(Request.QueryString["Flag"].ToString());
  22.             if (flag == 1)
  23.             {
  24.                 string UserAccount = Request.QueryString["UserAccount"].ToString();
  25.                 Panel1.Visible = false;
  26.                 Panel2.Visible = true;
  27.                 ds = user.GetUserIDFAccount(UserAccount);
  28.                 GridView2.DataSource = ds;
  29.                 GridView2.DataBind();
  30.             }
  31.             if (flag == 2)
  32.             {
  33.                 string empname = Request.QueryString["UserAccount"].ToString();
  34.                 //string empname = Session["EmpName"].ToString();
  35.                 ds = user.GetUserID(empname);
  36.                 GridView1.DataSource = ds;
  37.                 GridView1.DataBind();
  38.             }
  39.             //else
  40.             //{
  41.             //    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('输入的参数出错!')</script>");
  42.             //    return;
  43.             //}
  44.         }
  45.     }
  46.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  47.     {
  48.         string empname = Request.QueryString["UserAccount"].ToString();
  49.         int currentpageindex;
  50.         currentpageindex = Convert.ToInt32(e.NewPageIndex);
  51.         if (currentpageindex == -2)
  52.         {
  53.             TextBox txtNewPageIndex;
  54.             txtNewPageIndex = GridView1.BottomPagerRow.FindControl("LinkTextBoxNewPage") as TextBox;
  55.             if (txtNewPageIndex != null)
  56.             {
  57.                 try
  58.                 {
  59.                     currentpageindex = Convert.ToInt32(txtNewPageIndex.Text) - 1;
  60.                 }
  61.                 catch
  62.                 {
  63.                     currentpageindex = 0;
  64.                 }
  65.             }
  66.         }
  67.         currentpageindex = currentpageindex < 0 ? 0 : currentpageindex;
  68.         currentpageindex = currentpageindex >= GridView1.PageCount ? GridView1.PageCount - 1 : currentpageindex;
  69.         GridView1.PageIndex = currentpageindex;
  70.         AllUser user = new AllUser();
  71.         DataSet ds = user.GetUserID(empname);       
  72.         GridView1.DataSource = ds;
  73.         GridView1.DataBind(); 
  74.     }
  75.     protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
  76.     {
  77.         string UserAccount = Request.QueryString["UserAccount"].ToString();     
  78.         int currentpageindex;
  79.         currentpageindex = Convert.ToInt32(e.NewPageIndex);
  80.         if (currentpageindex == -2)
  81.         {
  82.             TextBox txtNewPageIndex;
  83.             txtNewPageIndex = GridView1.BottomPagerRow.FindControl("LinkTextBoxNewPage") as TextBox;
  84.             if (txtNewPageIndex != null)
  85.             {
  86.                 try
  87.                 {
  88.                     currentpageindex = Convert.ToInt32(txtNewPageIndex.Text) - 1;
  89.                 }
  90.                 catch
  91.                 {
  92.                     currentpageindex = 0;
  93.                 }
  94.             }
  95.         }
  96.         currentpageindex = currentpageindex < 0 ? 0 : currentpageindex;
  97.         currentpageindex = currentpageindex >= GridView1.PageCount ? GridView1.PageCount - 1 : currentpageindex;
  98.         GridView1.PageIndex = currentpageindex;
  99.         AllUser user = new AllUser();
  100.         DataSet ds = user.GetUserIDFAccount(UserAccount);
  101.         GridView2.DataSource = ds;
  102.         GridView2.DataBind();
  103.     }
  104.     protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  105.     {
  106.         GridViewRow row = ((Control)e.CommandSource).BindingContainer as GridViewRow;
  107.         int index = row.RowIndex;
  108.         string Password = Request.QueryString["PassWord"].ToString();
  109.         string UserIP = Request.QueryString["UserIP"].ToString();
  110.         string empname = Request.QueryString["UserAccount"].ToString();
  111.         if (e.CommandName == "Select")
  112.         {
  113.             int UserID = Convert.ToInt32(GridView1.DataKeys[index].Value.ToString());
  114.             AllUser user = new AllUser();
  115.             CheckUserInfo checkuserinfo = user.PCheckUser(UserID, Password, UserIP);
  116.             if (checkuserinfo != null)
  117.             {
  118.                 Session["checkuserinfo"] = checkuserinfo;
  119.                 if (Password == "111111")
  120.                 {
  121.                     Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>PwsDialog();</script>");
  122.                     return;
  123.                 }
  124.                 else
  125.                 {
  126.                     this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>window.returnValue='success';window.close();</script>");
  127.                     return;
  128.                 }
  129.             }
  130.             else
  131.             {
  132.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>window.returnValue='UserID=" + UserID + "&UserIP=" + UserIP + "';window.close();</script>");
  133.                 return;
  134.                 //string url = "PassWord.aspx?UserID=" + UserID + "&UserIP=" + UserIP ;
  135.                 //Response.Redirect(url);
  136.                 //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>APwsDialog('" + empname + "','" + UserIP + "',2);</script>");
  137.                // return;
  138.             }
  139.         }
  140.     }           
  141.     protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
  142.     {
  143.         GridViewRow row = ((Control)e.CommandSource).BindingContainer as GridViewRow;
  144.         int index = row.RowIndex;
  145.         string Password = Request.QueryString["PassWord"].ToString();
  146.         string UserIP = Request.QueryString["UserIP"].ToString();
  147.         string UserAccount = Request.QueryString["UserAccount"].ToString();
  148.         if (e.CommandName == "Select")
  149.         {                      
  150.             int UserID = Convert.ToInt32(GridView2.DataKeys[index].Value.ToString());
  151.             AllUser user = new AllUser();
  152.             CheckUserInfo checkuserinfo = user.PCheckUser(UserID, Password, UserIP);
  153.             if (checkuserinfo != null)
  154.             {
  155.                 Session["checkuserinfo"] = checkuserinfo;
  156.                 if (Password == "111111")
  157.                 {
  158.                     Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>PwsDialog();</script>");
  159.                     return;
  160.                 }
  161.                 else
  162.                 {
  163.                     this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>window.returnValue='success';window.close();</script>");
  164.                     return;
  165.                 }
  166.             }
  167.             else
  168.             {
  169.                 this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>window.returnValue='UserID="+UserID+"&UserIP="+UserIP+"';window.close();</script>");
  170.                 return;
  171.                 //string url = "PassWord.aspx?UserID=" + UserID + "&UserIP=" + UserIP ;
  172.                 //Response.Redirect(url);
  173.                 //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>APwsDialog('" + UserAccount + "','" + UserIP + "',1);</script>");
  174.                 //return;
  175.             }
  176.         }
  177.     }   
  178. }