announce_detail.aspx.cs
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:3k
源码类别:

OA系统

开发平台:

ASP/ASPX

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;
  12. public partial class web_announcement_announce_detail : System.Web.UI.Page
  13. {
  14.     protected void Page_Load(object sender, EventArgs e)
  15.     {
  16.         if (!IsPostBack)
  17.         {
  18.             if (Request.QueryString["a_id"] != null)
  19.             {
  20.                 this.SetValue(Request.QueryString["a_id"]);
  21.             }
  22.         }
  23.     }
  24.     protected void SetValue(string id)
  25.     {
  26.         SqlConnection conn = dbConnection.getConnection();
  27.         conn.Open();
  28.         SqlCommand cmd = new SqlCommand("select a.subject, t.name type, a.content, a.validate_date, a.cre_user," +
  29.             "a.cre_date, a.attachment, a.attachment_save_name, a.attachment_length from OA_ANNOUNCEMENT a " +
  30.             "inner join OA_ANNOUNCEMENT_TYPE t on a.type_id=t.id where a.id=" + id, conn);
  31.         SqlDataReader dr = cmd.ExecuteReader();
  32.         if (dr.Read())
  33.         {
  34.             LblSubject.Text = dr["subject"].ToString();
  35.             LblType.Text = dr["type"].ToString();
  36.             LblContent.Text = dr["content"].ToString();
  37.             LblValidateDate.Text = dr["validate_date"].ToString();
  38.             LblCreUser.Text = dr["cre_user"].ToString();
  39.             LblCreDate.Text = dr["cre_date"].ToString();
  40.             if (!dr["attachment"].ToString().Equals(""))
  41.             {
  42.                 TblAnnouncement.Rows[6].Visible = true;
  43.                 LbAttachment.Text = dr["attachment"].ToString();
  44.                 AttachmentSaveName.Value = dr["attachment_save_name"].ToString();
  45.                 ContentLength.Value = dr["attachment_length"].ToString();
  46.             }
  47.         }
  48.         dr.Close();
  49.         conn.Close();
  50.     }
  51.     protected void LbAttachment_Click(object sender, EventArgs e)
  52.     {
  53.         this.DownLoadFile(AttachmentSaveName.Value);
  54.     }
  55.     protected void DownLoadFile(string name)
  56.     {
  57.         string directory = "..\oa_upload\announce\";
  58.         try
  59.         {
  60.             Response.Clear();
  61.             Response.ClearHeaders();
  62.             Response.Buffer = false;
  63.             Response.ContentType = "application/octet-stream";
  64.             Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(LbAttachment.Text, System.Text.Encoding.UTF8));
  65.             Response.AppendHeader("Content-Length", ContentLength.Value);
  66.             Response.WriteFile(directory + name);
  67.             Response.Flush();
  68.             Response.End();
  69.         }
  70.         catch (Exception ex)
  71.         {
  72.             Response.Write(ex.Message);
  73.         }
  74.     }
  75. }