announce_detail.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:3k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- 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.Data.SqlClient;
- public partial class web_announcement_announce_detail : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- if (Request.QueryString["a_id"] != null)
- {
- this.SetValue(Request.QueryString["a_id"]);
- }
- }
- }
- protected void SetValue(string id)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlCommand cmd = new SqlCommand("select a.subject, t.name type, a.content, a.validate_date, a.cre_user," +
- "a.cre_date, a.attachment, a.attachment_save_name, a.attachment_length from OA_ANNOUNCEMENT a " +
- "inner join OA_ANNOUNCEMENT_TYPE t on a.type_id=t.id where a.id=" + id, conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- LblSubject.Text = dr["subject"].ToString();
- LblType.Text = dr["type"].ToString();
- LblContent.Text = dr["content"].ToString();
- LblValidateDate.Text = dr["validate_date"].ToString();
- LblCreUser.Text = dr["cre_user"].ToString();
- LblCreDate.Text = dr["cre_date"].ToString();
- if (!dr["attachment"].ToString().Equals(""))
- {
- TblAnnouncement.Rows[6].Visible = true;
- LbAttachment.Text = dr["attachment"].ToString();
- AttachmentSaveName.Value = dr["attachment_save_name"].ToString();
- ContentLength.Value = dr["attachment_length"].ToString();
- }
- }
- dr.Close();
- conn.Close();
- }
- protected void LbAttachment_Click(object sender, EventArgs e)
- {
- this.DownLoadFile(AttachmentSaveName.Value);
- }
- protected void DownLoadFile(string name)
- {
- string directory = "..\oa_upload\announce\";
- try
- {
- Response.Clear();
- Response.ClearHeaders();
- Response.Buffer = false;
- Response.ContentType = "application/octet-stream";
- Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(LbAttachment.Text, System.Text.Encoding.UTF8));
- Response.AppendHeader("Content-Length", ContentLength.Value);
- Response.WriteFile(directory + name);
- Response.Flush();
- Response.End();
- }
- catch (Exception ex)
- {
- Response.Write(ex.Message);
- }
- }
- }