Files
CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/SanKu/ReportLog.aspx.cs
T

147 lines
5.1 KiB
C#
Raw Normal View History

2026-09-10 18:51:12 +08:00
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
namespace FineUIPro.Web.SanKu
{
public partial class ReportLog : PageBase
{
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Funs.DropDownPageSize(this.ddlPageSize);
if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
{
Grid1.PageSize = this.CurrUser.PageSize.Value;
}
//日志默认查询日期从前一天开始
this.txtStartTime.Text = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
// 绑定表格
this.BindGrid();
}
}
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
string strSql = @" SELECT rlog.* FROM SANKU_REPORT_LOG AS rlog WITH(NOLOCK) WHERE 1=1 ";
List<SqlParameter> listStr = new List<SqlParameter>();
if (!string.IsNullOrEmpty(this.txtContent.Text.Trim()))
{
strSql += " AND rlog.CONTENT LIKE @Content";
listStr.Add(new SqlParameter("@Content", "%" + this.txtContent.Text.Trim() + "%"));
}
if (!string.IsNullOrWhiteSpace(this.rbResult.SelectedValue))
{//结果
strSql += " AND rlog.RESULT = @Result";
listStr.Add(new SqlParameter("@Result", this.rbResult.SelectedValue));
}
if (!string.IsNullOrWhiteSpace(this.rbOpType.SelectedValue))
{//方式
strSql += " AND rlog.OPTYPE = @OpType";
listStr.Add(new SqlParameter("@OpType", this.rbOpType.SelectedValue));
}
if (!string.IsNullOrEmpty(txtStartTime.Text.Trim()))
{
strSql += " and rlog.CREATE_TIME >= @StartTime";
listStr.Add(new SqlParameter("@StartTime", txtStartTime.Text.Trim()));
}
if (!string.IsNullOrEmpty(this.txtEndTime.Text.Trim()))
{
strSql += " and rlog.CREATE_TIME <= @EndTime";
listStr.Add(new SqlParameter("@EndTime", this.txtEndTime.Text.Trim()));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.RecordCount = tb.Rows.Count;
//tb = GetFilteredTable(Grid1.FilteredData, tb);
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
#region
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 导出按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOut_Click(object sender, EventArgs e)
{
Response.ClearContent();
string filename = Funs.GetNewFileName();
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("三库——业务数据日志" + filename, System.Text.Encoding.UTF8) + ".xls");
Response.ContentType = "application/excel";
Response.ContentEncoding = System.Text.Encoding.UTF8;
this.Grid1.PageSize = this.Grid1.RecordCount;
this.BindGrid();
Response.Write(GetGridTableHtml(Grid1));
Response.End();
}
#endregion
#region
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
/// <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();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
BindGrid();
}
#endregion
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
}
}