📄 operatelog.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Office.BLL;
using Office.Model;
public partial class SysManage_OperateLog : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DIV1.Visible = false;
DIV2.Visible = false;
}
}
protected void imbtnSearch_Click(object sender, ImageClickEventArgs e)
{
DIV2.Visible = false;
DIV1.Visible = true;
//开始、结束时间
String StartTime = txtStartTime.Text;
String EndTime = txtEndTime.Text;
if (StartTime == "" && EndTime == "")
{
if (day.Checked)
{
StartTime += DateTime.Now.ToShortDateString() + " 00:00:00";
EndTime += DateTime.Now.ToShortDateString() + " 23:59:59";
}
else if (week.Checked)
{
Int32 we = (Int32)DateTime.Now.DayOfWeek;
if (we == 0)
StartTime += DateTime.Now.AddDays(-(we + 7) + 1).ToShortDateString() + " 00:00:00";
else
StartTime += DateTime.Now.AddDays(-we + 1).ToShortDateString() + " 00:00:00";
EndTime += DateTime.Now.AddDays(-we + 7).ToShortDateString() + " 23:59:59";
}
else if (month.Checked)
{
StartTime += DateTime.Now.AddDays(-DateTime.Now.Day + 1).ToShortDateString() + " 00:00:00";
EndTime += DateTime.Now.AddDays(-DateTime.Now.Day).AddMonths(1).ToShortDateString() + " 23:59:59";
}
else
{
Bind(); return;
}
}
//根据开始时间和结束时间从数据库得到操作日志
IList<OperateLog> list = OperateLogManager.GetAllOperateLogByCondition(StartTime, EndTime);
if (list != null)
{
if (list.Count > 0)
{
GridView1.Visible = true;
chkCheckAll.Visible = true;
btnDelete.Visible = true;
this.GridView1.DataSource = list;
GridView1.DataBind();
}
else
{
GridView1.Visible = false;
chkCheckAll.Visible = false;
btnDelete.Visible = false;
Label mes = new Label();
mes.Text = "查询完毕,没有结果显示!";
DIV1.Controls.Add(mes);
}
}
}
//数据绑定
private void Bind()
{
GridView1.DataSource = OperateLogManager.GetAllOperateLogs();
GridView1.DataBind();
}
//删除事件
protected void btnDelete_Click(object sender, EventArgs e)
{
String str = "";
//遍历GirdView所有行判断复选是否选中.将其ID 累加
for (int i = 0; i < this.GridView1.Rows.Count; i++)
{
CheckBox chk = GridView1.Rows[i].FindControl("CheckBox1") as CheckBox;
if (chk.Checked)
{
str += (GridView1.Rows[i].FindControl("lblOperateId") as Label).Text + ",";
}
}
if (str == "")
str += "0,";
if (OperateLogManager.DeleteOperateLogByOperateIds(str.Substring(0,str.Length-1)))
{
this.DIV1.Visible = false;
this.DIV2.Visible = true;
this.lblMes.Text = "已成功删除您所选记录!";
}
else
{
this.DIV1.Visible = false;
this.DIV2.Visible = true;
this.lblMes.Text = "删除记录失败!";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -