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

.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.BusinessRule.Zwf;
  12. public partial class sysManage_SysManageUser : System.Web.UI.Page
  13.  {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     { 
  16.         if (!IsPostBack)
  17.         {
  18.             DataView dv = new DataView();
  19.             EtongZwf etongzwf = new EtongZwf();
  20.             dv = etongzwf.UserSearch("", "",false);
  21.             this.GridView1.DataSource = dv;
  22.             this.GridView1.DataBind();
  23.         }
  24.     }
  25.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  26.     {
  27.     
  28.         int currentpageindex;
  29.         currentpageindex = Convert.ToInt32(e.NewPageIndex);
  30.         if (currentpageindex == -2)
  31.         {
  32.             TextBox txtNewPageIndex;
  33.             txtNewPageIndex = GridView1.BottomPagerRow.FindControl("LinkTextBoxNewPage") as TextBox;
  34.             if (txtNewPageIndex != null)
  35.             {
  36.                 try
  37.                 {
  38.                     currentpageindex = Convert.ToInt32(txtNewPageIndex.Text) - 1;
  39.                 }
  40.                 catch
  41.                 {
  42.                     currentpageindex = 0;
  43.                 }
  44.             }
  45.         }
  46.         currentpageindex = currentpageindex < 0 ? 0 : currentpageindex;
  47.         currentpageindex = currentpageindex >= GridView1.PageCount ? GridView1.PageCount - 1 : currentpageindex;
  48.         GridView1.PageIndex = currentpageindex;
  49.         EtongZwf etongzwf = new EtongZwf();
  50.         DataView dv= etongzwf.UserSearch("", "",false);
  51.         dv.Sort = (string)ViewState["sortFieldName"];
  52.         this.GridView1.DataSource = dv;
  53.         this.GridView1.DataBind();
  54.         
  55.     }
  56.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  57.     {
  58.         if (e.Row.RowType == DataControlRowType.DataRow)
  59.          {
  60.              int iRow;
  61.              iRow = e.Row.DataItemIndex;
  62.              iRow = iRow % 2;
  63.              if (iRow > 0)
  64.                  e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='#f0f0f0';");
  65.              else
  66.                  e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';");
  67.            e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#E8F2FA';");   
  68.          
  69.            ImageButton addButton = ((ImageButton)e.Row.FindControl("IB_Key"));
  70.            addButton.CommandArgument = e.Row.RowIndex.ToString();
  71.         }
  72.        
  73.       
  74.     }
  75.     protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
  76.     {
  77.         try
  78.         {
  79.             int userid = Convert.ToInt16(GridView1.DataKeys[e.RowIndex].Value.ToString());
  80.             EtongZwf etongzwf = new EtongZwf();
  81.             etongzwf.UserDelete(userid);
  82.             GridView1.DataSource = etongzwf.UserSearch("", "5",false);
  83.             GridView1.DataBind();
  84.           
  85.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:删除记录成功!');</script>");
  86.         }
  87.         catch (Exception ex)
  88.         {
  89.             ClientScript.RegisterStartupScript(this.GetType(), "errorMessage", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "") + "');</script>");
  90.         }
  91.     }
  92.     protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
  93.     {
  94.         int userid = Convert.ToInt16(GridView1.DataKeys[e.NewEditIndex].Value.ToString());
  95.         ClientScript.RegisterStartupScript(this.GetType(), "", "<script> window.showModalDialog('UserUpdata.aspx?userid=" + userid + "','','help:0;dialogWidth=650px;dialogHeight=400px,status=no;scroll=no;')</script>");
  96.      //   Response.Write();
  97.       //  Response.Write("<script>window.open('UserUpdata.aspx?userid=" + userid + "','','window.innerHeight:500px;innerWidth:600px,top:250px;left:250px;location=no, status=no;');</script>");
  98.     }
  99.     protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
  100.     {
  101.     }
  102.     protected void IB_Search_Click(object sender, ImageClickEventArgs e)
  103.     {
  104.         string  SearchKind = this.DDL_Condition.SelectedValue.Trim();
  105.         string  SearchTxt=this.TB_Condition.Text.Trim();
  106.        bool IsSearch=this.CB_Blur.Checked;
  107.         DataView dv = new DataView();
  108.         EtongZwf etongzwf = new EtongZwf();
  109.         dv = etongzwf.UserSearch(SearchTxt, SearchKind, IsSearch);
  110.         this.GridView1.DataSource = dv;
  111.         this.GridView1.DataBind();
  112.     
  113.     }
  114.     
  115.     protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
  116.     {
  117.    
  118.  
  119.     }
  120.   
  121.     protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  122.     {
  123.         if (e.CommandName == "key2")
  124.         {
  125.             int id = Convert.ToInt32(e.CommandArgument);
  126.             int userid = Convert.ToInt16(GridView1.Rows[id].Cells[0].Text.ToString().Trim());
  127.             EtongZwf etongzwf = new EtongZwf();
  128.             bool returnvalue = etongzwf.UserPwdUpdata(userid);
  129.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:密码重置成功,\n          密码为:111111');</script>");
  130.         }
  131.     }
  132.     protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
  133.     {
  134.         if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)
  135.         {
  136.            e.Row.Cells[0].Visible = false;
  137.            
  138.         }
  139.     }
  140.     protected void ddlRandom_SelectedIndexChanged(object sender, EventArgs e)
  141.     {
  142.         //GridViewRow gvr = this.GridView1.BottomPagerRow;
  143.         //DropDownList ddlRandom = (DropDownList)(gvr.FindControl("ddlRandom"));
  144.         //this.currentPage = Convert.ToInt32(ddlRandom.SelectedIndex.ToString()) + 1;
  145.       
  146.         //Response.Redirect("SysManageUser.aspx?id=" + this.currentPage);
  147.     }
  148.     protected void IB_Key_Click(object sender, ImageClickEventArgs e)
  149.     {
  150.     }
  151. }