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

.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.MatCode;
  12. public partial class MatCode_default : 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.             MatCode matcode = new MatCode();
  20.             dv = matcode.MatCodeSearch("","");
  21.             try
  22.             {
  23.                 this.GridView1.PageSize = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["MorePageNum"]);
  24.             }
  25.             catch
  26.             {
  27.                 this.GridView1.PageSize = 10;
  28.             }
  29.                 this.GridView1.DataSource = dv;
  30.             this.GridView1.DataBind();
  31.         }
  32.     }
  33.     protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
  34.     {
  35.         int currentpageindex;
  36.         currentpageindex = Convert.ToInt32(e.NewPageIndex);
  37.         if (currentpageindex == -2)
  38.         {
  39.             TextBox txtNewPageIndex;
  40.             txtNewPageIndex = GridView1.BottomPagerRow.FindControl("LinkTextBoxNewPage") as TextBox;
  41.             if (txtNewPageIndex != null)
  42.             {
  43.                 try
  44.                 {
  45.                     currentpageindex = Convert.ToInt32(txtNewPageIndex.Text) - 1;
  46.                 }
  47.                 catch
  48.                 {
  49.                     currentpageindex = 0;
  50.                 }
  51.             }
  52.         }
  53.         currentpageindex = currentpageindex < 0 ? 0 : currentpageindex;
  54.         currentpageindex = currentpageindex >= GridView1.PageCount ? GridView1.PageCount - 1 : currentpageindex;
  55.         GridView1.PageIndex = currentpageindex;
  56.         MatCode matcode = new MatCode();
  57.         DataView dv = matcode.MatCodeSearch("", "");
  58.         dv.Sort = (string)ViewState["sortFieldName"];
  59.         this.GridView1.DataSource = dv;
  60.         this.GridView1.DataBind();
  61.     }
  62.     protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
  63.     {
  64.         try
  65.         {
  66.             int id = Convert.ToInt16(GridView1.DataKeys[e.RowIndex].Value.ToString());
  67.             MatCode matcode = new MatCode();
  68.             matcode.MatCodeDelete(id);
  69.             GridView1.DataSource = matcode.MatCodeSearch("","4");
  70.             GridView1.DataBind();
  71.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:删除记录成功!');</script>");
  72.         }
  73.         catch (Exception ex)
  74.         {
  75.             ClientScript.RegisterStartupScript(this.GetType(), "errorMessage", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "") + "');</script>");
  76.         }
  77.     }
  78.     protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
  79.     {
  80.        int id =Convert.ToInt32( GridView1.DataKeys[e.NewEditIndex].Value.ToString());
  81.        // Response.Write(id.ToString());
  82.         ClientScript.RegisterStartupScript(this.GetType(), "", "<script> window.showModalDialog('MatCodeUpdate.aspx?id=" +id+ "','','help:0;dialogWidth:'+650+'px;dialogHeight:'+400+'px,status=no;');window.location.replace(window.location.href);</script>");
  83.         //  Response.Write("<script>window.open('UserUpdata.aspx?userid=" + userid + "','','window.innerHeight:500px;innerWidth:600px,top:250px;left:250px;location=no, status=no;');</script>");
  84.     }
  85.     protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
  86.     {
  87.     }
  88.     protected void IB_Search_Click(object sender, ImageClickEventArgs e)
  89.     {
  90.         string condition = this.DDL_Condition.SelectedValue.Trim();
  91.         string SearchTxt = this.TB_Condition.Text.Trim();
  92.         DataView dv = new DataView();
  93.         MatCode matcode = new MatCode();
  94.         dv = matcode.MatCodeSearch(SearchTxt,condition);
  95.         this.GridView1.DataSource = dv;
  96.         this.GridView1.DataBind();
  97.     }
  98.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  99.     {
  100.         if (e.Row.RowType == DataControlRowType.DataRow)
  101.         {
  102.             int iRow;
  103.             iRow = e.Row.DataItemIndex;
  104.             iRow = iRow % 2;
  105.             if (iRow > 0)
  106.                 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='#f0f0f0';");
  107.             else
  108.                 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';");
  109.             e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#E8F2FA';");
  110.         }
  111.     }
  112. }