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 { /// /// 加载页面 /// /// /// 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(); } } /// /// 绑定数据 /// private void BindGrid() { string strSql = @" SELECT rlog.* FROM SANKU_REPORT_LOG AS rlog WITH(NOLOCK) WHERE 1=1 "; List listStr = new List(); 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 查询 /// /// 查询 /// /// /// protected void TextBox_TextChanged(object sender, EventArgs e) { this.BindGrid(); } #endregion #region 导出按钮 /// /// 导出按钮 /// /// /// 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 分页 /// /// 分页 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { BindGrid(); } /// /// 分页显示条数下拉框 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { BindGrid(); } #endregion protected void Window1_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } } }