default.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:5k
- 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.BusinessRule.MatCode;
- public partial class MatCode_default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- DataView dv = new DataView();
- MatCode matcode = new MatCode();
- dv = matcode.MatCodeSearch("","");
- try
- {
- this.GridView1.PageSize = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["MorePageNum"]);
- }
- catch
- {
- this.GridView1.PageSize = 10;
- }
- this.GridView1.DataSource = dv;
- this.GridView1.DataBind();
- }
- }
- protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
- {
- 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;
- MatCode matcode = new MatCode();
- DataView dv = matcode.MatCodeSearch("", "");
- dv.Sort = (string)ViewState["sortFieldName"];
- this.GridView1.DataSource = dv;
- this.GridView1.DataBind();
- }
- protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
- {
- try
- {
- int id = Convert.ToInt16(GridView1.DataKeys[e.RowIndex].Value.ToString());
- MatCode matcode = new MatCode();
- matcode.MatCodeDelete(id);
- GridView1.DataSource = matcode.MatCodeSearch("","4");
- GridView1.DataBind();
- ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:删除记录成功!');</script>");
- }
- catch (Exception ex)
- {
- ClientScript.RegisterStartupScript(this.GetType(), "errorMessage", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "") + "');</script>");
- }
- }
- protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
- {
- int id =Convert.ToInt32( GridView1.DataKeys[e.NewEditIndex].Value.ToString());
- // Response.Write(id.ToString());
- 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>");
- // Response.Write("<script>window.open('UserUpdata.aspx?userid=" + userid + "','','window.innerHeight:500px;innerWidth:600px,top:250px;left:250px;location=no, status=no;');</script>");
- }
- protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
- {
- }
- protected void IB_Search_Click(object sender, ImageClickEventArgs e)
- {
- string condition = this.DDL_Condition.SelectedValue.Trim();
- string SearchTxt = this.TB_Condition.Text.Trim();
- DataView dv = new DataView();
- MatCode matcode = new MatCode();
- dv = matcode.MatCodeSearch(SearchTxt,condition);
- this.GridView1.DataSource = dv;
- this.GridView1.DataBind();
- }
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- int iRow;
- iRow = e.Row.DataItemIndex;
- iRow = iRow % 2;
- if (iRow > 0)
- e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='#f0f0f0';");
- else
- e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';");
- e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#E8F2FA';");
- }
- }
- }