/// <summary> /// GridView行事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvResources_RowCommand(object sender, GridViewCommandEventArgs e) { GridViewRow row = (GridViewRow)((Image)e.CommandSource).NamingContainer; string filename = ""; string rid = e.CommandArgument.ToString(); object o_fn = DAL.DBHelper.ExecuteScalar("select FileName from Resources where ResID=" + rid); if (o_fn != null) { filename = o_fn.ToString(); } else { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert("您下载的文件已不存在!")); return; } if (e.CommandName.ToLower().Trim() == "download") { string dlDir = "../Company/upLoadRes/"; string path = Server.MapPath(dlDir + filename); FileInfo file = new FileInfo(path); if (file.Exists) { Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(file.Name).Replace('+', ' ')); Response.AddHeader("Content-Length", file.Length.ToString()); Response.ContentType = "application/octet-stream"; Response.WriteFile(file.FullName); DownLoadFilesBLL.UpdResourcesResTimesByResID(Convert.ToInt32(rid)); Response.End(); } else { Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("000666", "您下载的文件不在文件夹中"))); } } }
/// <summary> /// 初始化查询条件 /// </summary> private void GetShopList() { int Lev = Convert.ToInt32(BLL.CommonClass.CommonDataBLL.GetBalanceLevel(Session["Member"].ToString()).Rows[0][0]); string condition = "1<2 and DownTarget <> 1 and (DownMenberLev=0 or DownMenberLev=" + Lev + ")"; if (this.txt_member.Text != "") { condition += " and ResName like '%" + this.txt_member.Text.Trim().Replace("'", "") + "%'"; } if (this.Txt_Name.Text != "") { condition += " and FileName like '%" + this.Txt_Name.Text.Trim().Replace("'", "") + "%'"; } DataTable dt = DownLoadFilesBLL.GetResourcesInfoByConditions("*", condition); gvResources.DataSource = dt; gvResources.DataBind(); Pager1.PageBind(0, 10, " Resources", "ResID, ResName, FileName, ResDescription, ResSize, ResDateTime, ResTimes", condition, "ResID", "gvResources"); }