{
Database db = new Database();
string Guidstr = Request.Form.Get("checkGuid");
//Response.Write(Guidstr);
if (Guidstr.Split(',').Length > 1)
{
Response.Write("<script type='text/javascript'>alert('下载时候不能选择多个文档一起下载,请重新选择!');</script>");
}
else if (Guidstr != "" && Guidstr != null && Guidstr.Split(',').Length == 1)
{
string sql = "select FileName,FileContent,FileSize from tb_OldInput where Guidstr='" + Guidstr + "'";
DataTable dt = db.GetTable(sql);
if (dt.Rows.Count > 0)
{
Response.Clear();
String strFileName = dt.Rows[0]["FileName"].ToString();
int FileSize = int.Parse(dt.Rows[0]["FileSize"].ToString());
Response.ContentType = "APPLICATION/OCTET-STREAM";
Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(strFileName));
Response.Buffer = true;
Response.BinaryWrite((Byte[])dt.Rows[0]["FileContent"]);
Response.Flush();
Response.End();
}
}
}
protected void Look_Click(object sender, EventArgs e)//PDF文档查看
{
Database db = new Database();
string Guidstr = Request.Form.Get("checkGuid");
//Response.Write(Guidstr);
if (Guidstr.Split(',').Length > 1)
{
Response.Write("<script type='text/javascript'>alert('查看时候不能选择多个文档一起查看,请重新选择!');</script>");
}
else if (Guidstr != "" && Guidstr != null && Guidstr.Split(',').Length == 1)
{
string sql = "select FileContent from tb_OldInput where Guidstr='" + Guidstr + "'";
DataTable dt = db.GetTable(sql);
if (dt.Rows.Count > 0)
{
byte[] Files = (byte[])dt.Rows[0]["FileContent"];
Response.ContentType = "application/pdf";
Response.BinaryWrite(Files);
Response.End();
}
}
}