132 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			132 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			C#
		
	
	
	
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
using System.Web;
 | 
						|
using System.Web.UI;
 | 
						|
using System.Web.UI.WebControls;
 | 
						|
using System.Data.SqlClient;
 | 
						|
using BLL;
 | 
						|
using System.Data;
 | 
						|
 | 
						|
namespace FineUIPro.Web.SysManage
 | 
						|
{
 | 
						|
    public partial class LogList : PageBase
 | 
						|
    {
 | 
						|
        protected void Page_Load(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            // 表头过滤
 | 
						|
            FilterDataRowItem = FilterDataRowItemImplement;
 | 
						|
 | 
						|
            if (!IsPostBack)
 | 
						|
            {
 | 
						|
                BindGrid();
 | 
						|
            }
 | 
						|
        }
 | 
						|
 | 
						|
        #region BindGrid
 | 
						|
 | 
						|
        private void BindGrid()
 | 
						|
        {
 | 
						|
            string strSql = @"SELECT LogId,dbo.Sys_Log.UserId,OperationTime,Ip,HostName,OperationLog,dbo.Sys_User.UserName FROM Sys_Log 
 | 
						|
                              LEFT JOIN dbo.Sys_User ON Sys_User.UserId = Sys_Log.UserId
 | 
						|
                              order by OperationTime desc";
 | 
						|
         
 | 
						|
            DataTable tb = SQLHelper.GetDataTableRunText(strSql, null);       
 | 
						|
            Grid1.RecordCount = tb.Rows.Count;
 | 
						|
            tb = GetFilteredTable(Grid1.FilteredData, tb);
 | 
						|
            var table = this.GetPagedDataTable(Grid1, tb);
 | 
						|
            Grid1.DataSource = table;
 | 
						|
            Grid1.DataBind();
 | 
						|
        }
 | 
						|
 | 
						|
        #region 表头过滤
 | 
						|
        protected void Grid1_FilterChange(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            BindGrid();
 | 
						|
        }
 | 
						|
 | 
						|
        private bool FilterDataRowItemImplement(object sourceObj, string fillteredOperator, object fillteredObj, string column)
 | 
						|
        {
 | 
						|
            bool valid = false;
 | 
						|
             if (column == "UserName")
 | 
						|
            {
 | 
						|
                string sourceValue = sourceObj.ToString();
 | 
						|
                string fillteredValue = fillteredObj.ToString();
 | 
						|
                if (fillteredOperator == "equal")
 | 
						|
                {
 | 
						|
                    if (sourceValue == fillteredValue)
 | 
						|
                    {
 | 
						|
                        valid = true;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                else if (fillteredOperator == "contain")
 | 
						|
                {
 | 
						|
                    if (sourceValue.Contains(fillteredValue))
 | 
						|
                    {
 | 
						|
                        valid = true;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
            else if (column == "OperationTime")
 | 
						|
            {
 | 
						|
                if (!String.IsNullOrEmpty(sourceObj.ToString()))
 | 
						|
                {
 | 
						|
                    DateTime sourceValue = Convert.ToDateTime(sourceObj);
 | 
						|
                    DateTime fillteredValue = Convert.ToDateTime(fillteredObj);
 | 
						|
 | 
						|
                    if (fillteredOperator == "greater")
 | 
						|
                    {
 | 
						|
                        if (sourceValue > fillteredValue)
 | 
						|
                        {
 | 
						|
                            valid = true;
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                    else if (fillteredOperator == "less")
 | 
						|
                    {
 | 
						|
                        if (sourceValue < fillteredValue)
 | 
						|
                        {
 | 
						|
                            valid = true;
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                    else if (fillteredOperator == "equal")
 | 
						|
                    {
 | 
						|
                        if (sourceValue == fillteredValue)
 | 
						|
                        {
 | 
						|
                            valid = true;
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
            return valid;
 | 
						|
        }
 | 
						|
 | 
						|
        #endregion
 | 
						|
        #endregion
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 分页下拉选择
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="sender"></param>
 | 
						|
        /// <param name="e"></param>
 | 
						|
        protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
 | 
						|
        {
 | 
						|
            Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
 | 
						|
            BindGrid();
 | 
						|
        }
 | 
						|
 | 
						|
        protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
 | 
						|
        {
 | 
						|
            Grid1.PageIndex = e.NewPageIndex;
 | 
						|
            BindGrid();
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
        protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
 | 
						|
        {
 | 
						|
            Grid1.SortDirection = e.SortDirection;
 | 
						|
            Grid1.SortField = e.SortField;
 | 
						|
 | 
						|
            BindGrid();
 | 
						|
        }
 | 
						|
    }
 | 
						|
} |