AuditSelect.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.user;
  12. public partial class SysManage_AuditSelect : 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.             Audit audit = new Audit();
  20.             dv = audit.AuditSearch("", "",Convert.ToDateTime(null),Convert.ToDateTime(null));
  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.         Audit audit = new Audit();
  57.         DataView dv = new DataView();
  58.         dv = audit.AuditSearch("", "", Convert.ToDateTime(null), Convert.ToDateTime(null));
  59.         dv.Sort = (string)ViewState["sortFieldName"];
  60.         this.GridView1.DataSource = dv;
  61.         this.GridView1.DataBind();
  62.     }
  63.     protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
  64.     {
  65.         try
  66.         {
  67.             int auditid = Convert.ToInt16(GridView1.DataKeys[e.RowIndex].Value.ToString());
  68.             Audit audit = new Audit();
  69.             audit.AuditDelete(auditid);
  70.             DataView dv = new DataView();           
  71.             dv = audit.AuditSearch("", "", Convert.ToDateTime(null), Convert.ToDateTime(null));
  72.             GridView1.DataBind();
  73.             ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('系统提示:删除记录成功!');</script>");
  74.         }
  75.         catch (Exception ex)
  76.         {
  77.             ClientScript.RegisterStartupScript(this.GetType(), "errorMessage", "<script>alert('" + ex.Message.Replace("'", "").Replace("rn", "") + "');</script>");
  78.         }
  79.     }
  80.     protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
  81.     {
  82.     }
  83.     protected void IB_Search_Click(object sender, ImageClickEventArgs e)
  84.     {
  85.         string condition = this.DDL_Condition.SelectedValue.Trim();        
  86.         string SearchTxt = this.TB_Condition.Text.Trim();
  87.         DataView dv = new DataView();
  88.         Audit audit = new Audit();
  89.         if (condition == "5")
  90.         {
  91.             if (TB_StartTime.Text.Trim() != "" && TB_EndTime.Text.Trim() != "")
  92.             {
  93.                 DateTime starttime = Convert.ToDateTime(TB_StartTime.Text.Trim().ToString());
  94.                 DateTime endtime = Convert.ToDateTime(TB_EndTime.Text.Trim().ToString());
  95.                 if (endtime > starttime)
  96.                 {
  97.                     dv = audit.AuditSearch(SearchTxt, condition, starttime, endtime);
  98.                 }
  99.                 else
  100.                 {
  101.                     Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('结束时间要大于开始时间!');</script>");
  102.                     return;
  103.                 }
  104.             }
  105.             else
  106.             {
  107.                 Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请选择起始时间!');</script>");
  108.                 return;
  109.             }
  110.         }
  111.         else
  112.             dv = audit.AuditSearch("", "", Convert.ToDateTime(null), Convert.ToDateTime(null));
  113.         this.GridView1.DataSource = dv;
  114.         this.GridView1.DataBind();
  115.     }
  116.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  117.     {
  118.         if (e.Row.RowType == DataControlRowType.DataRow)
  119.         {
  120.             int iRow;
  121.             iRow = e.Row.DataItemIndex;
  122.             iRow = iRow % 2;
  123.             if (iRow > 0)
  124.                 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='#f0f0f0';");
  125.             else
  126.                 e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';");
  127.             e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#E8F2FA';");
  128.         }
  129.     }
  130.     protected void DDL_Condition_SelectedIndexChanged(object sender, EventArgs e)
  131.     {
  132.         string condition = this.DDL_Condition.SelectedValue.Trim();
  133.         if (condition == "5")
  134.         {
  135.             TB_StartTime.Visible = true;
  136.             TB_EndTime.Visible = true;
  137.             TB_Condition.Visible = false;
  138.         }
  139.         else
  140.         {
  141.             TB_StartTime.Visible = false;
  142.             TB_EndTime.Visible = false;
  143.             TB_Condition.Visible = true; 
  144.         }
  145.     }
  146. }