AuditSelect.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:6k
- 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;
- public partial class SysManage_AuditSelect : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- DataView dv = new DataView();
- Audit audit = new Audit();
- dv = audit.AuditSearch("", "",Convert.ToDateTime(null),Convert.ToDateTime(null));
- 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;
- Audit audit = new Audit();
- DataView dv = new DataView();
- dv = audit.AuditSearch("", "", Convert.ToDateTime(null), Convert.ToDateTime(null));
- dv.Sort = (string)ViewState["sortFieldName"];
- this.GridView1.DataSource = dv;
- this.GridView1.DataBind();
- }
- protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
- {
- try
- {
- int auditid = Convert.ToInt16(GridView1.DataKeys[e.RowIndex].Value.ToString());
- Audit audit = new Audit();
- audit.AuditDelete(auditid);
- DataView dv = new DataView();
- dv = audit.AuditSearch("", "", Convert.ToDateTime(null), Convert.ToDateTime(null));
- 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_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();
- Audit audit = new Audit();
- if (condition == "5")
- {
- if (TB_StartTime.Text.Trim() != "" && TB_EndTime.Text.Trim() != "")
- {
- DateTime starttime = Convert.ToDateTime(TB_StartTime.Text.Trim().ToString());
- DateTime endtime = Convert.ToDateTime(TB_EndTime.Text.Trim().ToString());
- if (endtime > starttime)
- {
- dv = audit.AuditSearch(SearchTxt, condition, starttime, endtime);
- }
- else
- {
- Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('结束时间要大于开始时间!');</script>");
- return;
- }
- }
- else
- {
- Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请选择起始时间!');</script>");
- return;
- }
- }
- else
- dv = audit.AuditSearch("", "", Convert.ToDateTime(null), Convert.ToDateTime(null));
- 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';");
- }
- }
- protected void DDL_Condition_SelectedIndexChanged(object sender, EventArgs e)
- {
- string condition = this.DDL_Condition.SelectedValue.Trim();
- if (condition == "5")
- {
- TB_StartTime.Visible = true;
- TB_EndTime.Visible = true;
- TB_Condition.Visible = false;
- }
- else
- {
- TB_StartTime.Visible = false;
- TB_EndTime.Visible = false;
- TB_Condition.Visible = true;
- }
- }
- }