FilesManager.aspx.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:6k
- using System;
- using System.Data;
- using System.Configuration;
- 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 System.IO;
- public partial class FileBooks_FilesManager : System.Web.UI.Page
- {
- /// <summary>
- /// 模板
- /// </summary>
- Model.Files MR = new Model.Files();
- /// <summary>
- /// 业务
- /// </summary>
- BLL.Files BR = new BLL.Files();
- /// <summary>
- /// 查询条件
- /// </summary>
- public string TiaoJian
- {
- get
- {
- if (ViewState["FilesTiaoJian"] == null)
- {
- return "";
- }
- else
- {
- return ViewState["FilesTiaoJian"].ToString();
- }
- }
- set { ViewState["FilesTiaoJian"] = value; }
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginLogic.MatchLoad("../", "FileBooks_FilesManager");
- if (!IsPostBack)
- {
- TiaoJian = "";
- if (Request.QueryString["TiaoJian"] != null)
- {
- TiaoJian = Server.UrlDecode(Request.QueryString["TiaoJian"].ToString());
- }
- MyDataBind(1);
- }
- }
- /// <summary>
- /// 获取信息
- /// </summary>
- /// <param name="pidx">页号</param>
- public void MyDataBind(int pidx)
- {
- AspNetPager1.RecordCount = BR.GetCount(TiaoJian);
- List<Model.Files> LRData = BR.GetPageList(20, pidx, "ID", false, TiaoJian);
- if (LRData.Count == 0)
- {
- Model.Files MR = new Model.Files();
- LRData.Add(MR);
- }
- GridView1.DataSource = LRData;
- GridView1.DataBind();
- }
- /// <summary>
- /// 卷按案
- /// </summary>
- /// <returns></returns>
- public string SuoShuJuanAn()
- {
- if (Eval("SSJA") != null)
- {
- int Id = int.Parse(Eval("SSJA").ToString());
- return EnumGet.GetRollName(Id);
- }
- else
- {
- return "";
- }
- }
- /// <summary>
- /// 附件下载地址
- /// </summary>
- /// <returns></returns>
- public string FuJian()
- {
- if (Eval("FJPath") != null)
- {
- string FJPath = Eval("FJPath").ToString();
- return "<a href='UpLoadFiles/" + FJPath + "' target='_blank'>下载</a>";
- }
- else
- {
- return "-";
- }
- }
- /// <summary>
- /// 操作
- /// </summary>
- /// <returns></returns>
- public string CaoZuo()
- {
- string Id = Eval("Id").ToString();
- //编辑 清空密码 删除
- string Rtstr = "<a href='UpFilesAdd.aspx'>添加文件</a> ";
- if (BR.GetCount(TiaoJian) > 0)
- {
- Rtstr += "<a href='UpFilesEdit.aspx?id=" + Id + "'>修改文件信息</a> ";
- }
- return Rtstr;
- }
- protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
- {
- MyDataBind(e.NewPageIndex);
- }
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- for (int i = 0; i < GridView1.Rows.Count; i++)
- {
- //首先判断是否是数据行
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- //当鼠标停留时更改背景色
- e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F0F0F0'");
- //当鼠标移开时还原背景色
- e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
- }
- }
- }
- protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
- {
- for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
- {
- CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
- if (CheckBox1.Checked)
- {
- cbox.Checked = true;
- }
- else
- {
- cbox.Checked = false;
- }
- }
- }
- protected void DelButton1_Click(object sender, EventArgs e)
- {
- try
- {
- for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
- {
- CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
- if (cbox.Checked)
- {
- // Response.Write(GridView1.Rows[i].Cells[1].Text.ToString() + ":True");
-
- int Id = int.Parse(GridView1.Rows[i].Cells[1].Text.ToString());
- if (Id == 0)
- {
- throw new Exception("该记录不能删除!");
- }
- DelFile(Id);
- BR.Delete(Id);
- }
- else
- {
- //Response.Write((GridView1.Rows[i].Cells[1]).Text.ToString() + ":False");
- }
- }
- MessageBox.Show("删除完成!");
- }
- catch (Exception exp)
- { MessageBox.Show(exp.Message); }
- MyDataBind(AspNetPager1.CurrentPageIndex);
- }
- /// <summary>
- /// 删除文件
- /// </summary>
- /// <param name="GuidStr"></param>
- public void DelFile(int ID)
- {
- try
- {
- Model.Files Mf = new BLL.Files().GetModel(ID);
- string FileUpdatePathFull = AppDomain.CurrentDomain.BaseDirectory + "FileBooks\UpLoadFiles\" + Mf.FJPath;
- File.Delete(FileUpdatePathFull);
- }
- catch { }
- }
- }