📄 filesearch.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 File_FileSearch : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DIV1.Visible = false;
DIV2.Visible = false;
DIV3.Visible = false;
ViewState["condition"] = "NO";
}
}
protected void btnFind_Click(object sender, EventArgs e)
{
if (DIV1.Visible == false)
{
DIV1.Visible = true;
ViewState["condition"] = "OK";
return;
}
else
{
DIV1.Visible = false;
ViewState["condition"] = "NO";
}
}
//搜索
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
DIV2.Visible = false;
DIV3.Visible = true;
string fileName = txtFileName.Text.Trim();
string fileOwner = txtCreateName.Text.Trim();
string accessory = txtAccessory.Text.Trim();
string startTime = txtStartTime.Text.Trim();
string endTime = txtEndTime.Text.Trim();
if (ViewState["condition"].ToString() == "OK")
{
if (startTime == "" && endTime == "")
{
if (this.RadioButton1.Checked)
{
startTime = DateTime.Now.ToShortDateString() + " 00:00:00";
endTime = DateTime.Now.ToShortDateString() + " 23:59:59";
}
else if (this.RadioButton2.Checked)
{
Int32 week = (Int32)DateTime.Now.DayOfWeek;
if (week == 0)
startTime = DateTime.Now.AddDays(-(week + 7) + 1).ToShortDateString() + " 00:00:00";
else
startTime = DateTime.Now.AddDays(-week + 1).ToShortDateString() + " 00:00:00";
endTime = DateTime.Now.AddDays(-week + 7).ToShortDateString() + " 23:59:59";
}
else
{
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";
}
}
}
//根据用户填写的数据得到文件信息
IList<FileInfo> list = FileInfoManager.GetFileInfoByCondition(fileName, fileOwner, accessory,startTime,endTime);
if (list != null)
{
if (list.Count > 0)
{
//PagedDataSource pds = new PagedDataSource();
//pds.DataSource = list;
//pds.AllowPaging = true;
//pds.PageSize = 10;
//pds.CurrentPageIndex = Int32.Parse(lblcureent.Text);
//lblsum.Text = pds.PageCount.ToString();
GridView1.Visible = true;
this.GridView1.DataSource = list;
GridView1.DataBind();
}
else
{
GridView1.Visible = false;
Label mes = new Label();
mes.Text = "查询完毕,没有结果显示!";
DIV3.Controls.Add(mes);
}
}
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("~/File/FileManage/FileManage.aspx");
}
//GridView命令行处理事件
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "showFile")
{
DIV2.Visible = true;
FileInfo file = FileInfoManager.GetFileInfoByFileId(Int32.Parse(e.CommandArgument.ToString()));
this.lblFileName.Text = file.FileName;
lblFilePath.Text = file.FilePath;
txtRemark.Text = file.Remark;
lblCreateTime.Text = file.CreateDate.ToString();
lblCreateUser.Text = file.FileOwner.UserId;
}
}
//数据绑定行绑定事件
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#FFFBD1'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor");
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -