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.common.SysManage { public partial class LogList : PageBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BLL.Base_ProjectService.InitProjectDropDownList(drpProject, true, CurrUser.UserId, null, CurrUser.LoginProjectArea, Resources.Lan.PleaseSelect); BindGrid(); } } #region BindGrid private void BindGrid() { string projectIds = BLL.Base_ProjectService.GetStrProjectIds(this.CurrUser.UserId, null); string strSql = @"select o.LogId, o.OperationTime,o.Ip,o.HostName,u.UserName,p.ProjectName, (o.ButtonName+menu.MenuName) AS OperationLog from dbo.Sys_Log o left join Sys_User u on u.UserId=o.UserId left join Base_Project p on p.ProjectId=o.ProjectId LEFT JOIN dbo.Sys_Menu menu ON menu.MenuId=o.MenuId where 1=1"; if (this.GetLanguage == "en-US") { strSql = @"select o.LogId, o.OperationTime,o.Ip,o.HostName,u.UserName,p.ProjectName, ((SELECT TOP 1 b.ButtonEnName FROM dbo.Sys_ButtonToMenu b WHERE b.MenuId=o.MenuId AND b.ButtonName=o.ButtonName) +menu.MenuEnName) AS OperationLog from dbo.Sys_Log o left join Sys_User u on u.UserId=o.UserId left join Base_Project p on p.ProjectId=o.ProjectId LEFT JOIN dbo.Sys_Menu menu ON menu.MenuId=o.MenuId where 1=1"; } List listStr = new List(); if (drpProject.SelectedValue != BLL.Const._Null) { strSql += " AND o.ProjectId = @ProjectId"; listStr.Add(new SqlParameter("@ProjectId", this.drpProject.SelectedValue)); } else { strSql += " AND (CHARINDEX(o.ProjectId,@ProjectId)>0 OR o.ProjectId is null) "; listStr.Add(new SqlParameter("@ProjectId", projectIds)); } if (!string.IsNullOrEmpty(this.txtUserName.Text.Trim())) { strSql += " AND u.UserName LIKE @UserName"; listStr.Add(new SqlParameter("@UserName", "%" + this.txtUserName.Text.Trim() + "%")); } if (!string.IsNullOrEmpty(this.txtStartDate.Text.Trim())) { strSql += " AND o.OperationTime >= @OperationTime"; listStr.Add(new SqlParameter("@OperationTime", Convert.ToDateTime(txtStartDate.Text.Trim()))); } if (!string.IsNullOrEmpty(this.txtEndDate.Text.Trim())) { strSql += " AND o.OperationTime <= @OperationTime"; listStr.Add(new SqlParameter("@OperationTime", Convert.ToDateTime(txtEndDate.Text.Trim()))); } strSql += " order by o.OperationTime desc ,o.ProjectId"; SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } /// /// 查询 /// /// /// protected void btnQuery_Click(object sender, EventArgs e) { this.BindGrid(); } #endregion /// /// 分页下拉选择 /// /// /// 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(); } } }