public void getattachment(string attachment)//獲取母網頁傳出的文字資訊 { JuicDao dao = new JuicDao("MENU"); //刪除資料夾內檔案 var MISupload = dao.GetANNupload(attachment); if (MISupload.Rows.Count > 0) { if (MISupload.Rows[0]["pdfurl"].ToString() != "") { string p_FilePath = MISupload.Rows[0]["pdfurl"].ToString(); HyperLink1.Visible = true; HyperLink1.NavigateUrl = p_FilePath; } else { HyperLink1.Visible = false; } } //獲取母網頁傳出的文字資訊 }
//點擊gridview內的button會開啟詳細公告 protected void gvANN_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "post") { ModalPanel.Visible = true; Announce.gettitle(e.CommandArgument.ToString().Split(new string[] { ",," }, StringSplitOptions.RemoveEmptyEntries)[0].Trim()); Announce.getcontent(e.CommandArgument.ToString().Split(new string[] { ",," }, StringSplitOptions.RemoveEmptyEntries)[1].Trim()); Announce.getpostdate(e.CommandArgument.ToString().Split(new string[] { ",," }, StringSplitOptions.RemoveEmptyEntries)[2].Trim()); Announce.getdept(e.CommandArgument.ToString().Split(new string[] { ",," }, StringSplitOptions.RemoveEmptyEntries)[3].Trim()); Announce.getauthor(e.CommandArgument.ToString().Split(new string[] { ",," }, StringSplitOptions.RemoveEmptyEntries)[4].Trim()); Announce.getattachment(e.CommandArgument.ToString().Split(new string[] { ",," }, StringSplitOptions.RemoveEmptyEntries)[5].Trim()); } if (e.CommandName == "remove") { JuicDao dao = new JuicDao("MENU"); //刪除資料夾內檔案 var MISupload = dao.GetANNupload(e.CommandArgument.ToString()); if (MISupload.Rows.Count > 0) { if (MISupload.Rows[0]["pdfurl"].ToString() != "") { string p_FilePath = MISupload.Rows[0]["pdfurl"].ToString(); System.IO.File.Delete(System.Web.Hosting.HostingEnvironment.MapPath(p_FilePath)); } } //刪除資料庫路徑 dao.DeleteANN(e.CommandArgument.ToString()); gvANN.DataSourceID = "SqlDataSource1"; //因updatepanel無法直行 string strJS = "alert('刪除成功');location.href = ('JuicWMS2.aspx');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "", strJS, true); } }