下载的公用方法:

 /// <summary>
/// 下载文档
/// </summary>
/// <param name="TableName">查询表</param>
/// <param name="column">查询列</param>
/// <param name="condition">查询条件</param>
/// <returns>byte[]</returns>
public static byte[] GetDownDocumet(string TableName,string column,string condition)
{
long datalen = 0;
System.Data.SqlClient.SqlDataReader reader= SqlComm.GetDataReaderByCondition(TableName, column, condition);
byte[] data = null;
try
{
while (reader.Read())
{
//读取数据的长度
datalen = reader.GetBytes(0, 0, data, 0, 1);
//分配缓区
data = new byte[datalen];
//读取数据
datalen = reader.GetBytes(0, 0, data, 0, (int)datalen);
}
reader.Close();
return data;
}
catch (Exception ex)
{
return null;
} }

下载:

获取文档二进制流:

 filecontent = Comm.GetDownDocumet("BioCrmCorrelationDocument", "Content", " DocumentID=" + id);

下载的具体步骤:

protected void lbtndown_Click(object sender, EventArgs e)
{
//创建弹出式Windows下载窗体
Response.AddHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(this.lbName.Text));
//把二进制数组写入Http输出流
Response.BinaryWrite(filecontent);
//想当前客户端缓冲区输出
Response.Flush();
//停止执行
Response.End(); }

修改的后台代码:

 static byte[] filecontent = null;
private void Pageinfoband()
{
if (Request.QueryString["ID"] != null)
{
string id = Request.QueryString["ID"].ToString();
BioCrmCorrelationDocumentBLL dbll = new BioCrmCorrelationDocumentBLL();
DocumentInfoView dv = new DocumentInfoView();
dv=dbll.getDocumentViewByID(id);
this.txtsubJect.Text = dv.Subject;
this.txtRemark.Text = dv.Remark;
this.lbType.Text = dv.Type;
this.txtCustomerID.Text = dv.CustomerID.ToString();
this.ddlLevel.SelectedItem.Text = dv.DocumentLevel;
this.cbDelete.Checked = dv.DeleteState;
this.lbExtendName.Text = dv.ExetendName;
this.lbName.Text = dv.Name;
filecontent = Comm.GetDownDocumet("BioCrmCorrelationDocument", "Content", " DocumentID=" + id);
this.lbSize.Text = dv.DocumentSize.ToString();
this.txtUserName.Text = dv.UserID.ToString();
this.hf_CustomerDocumentID.Value = dv.CustomerDocumentID.ToString();
lbUpdateTime.Text = dv.UploadTime.ToString(); }
} /// <summary>
/// 保存编辑内容
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSubmit_Click(object sender, EventArgs e)
{
BioCrmCorrelationDocument document = new BioCrmCorrelationDocument();
document.DocumentID =int.Parse( Request.QueryString["ID"].ToString());
document.Subject = this.txtsubJect.Text; document.UserID =int.Parse(Session["Userid"].ToString());
document.Remark = this.txtRemark.Text;
document.DocumentLevel = this.ddlLevel.SelectedValue; if (this.FileUpload1.HasFile)
{
document.Name = DateTime.Now.ToString("yyyyMMdd hhmmss") + this.FileUpload1.FileName;
document.Content = this.FileUpload1.FileBytes;
document.Type=this.FileUpload1.PostedFile.ContentType;
document.UploadTime = DateTime.Now;
document.DocumentSize = this.FileUpload1.FileContent.Length;
document.ExetendName = System.IO.Path.GetExtension(this.FileUpload1.FileName);
}
else
{
document.Name = this.lbName.Text;
document.Content = filecontent;
document.Type = this.lbType.Text;
document.UploadTime =Convert.ToDateTime( lbUpdateTime.Text);
document.DocumentSize =long.Parse(this.lbSize.Text);
document.ExetendName = this.lbExtendName.Text;
} //物理文件上传
string filepath = Server.MapPath(@"\Files\CRMFiles\");
if (Comm.FileExists(filepath + this.lbName.Text))
{
Comm.FileDelete(filepath + this.lbName.Text);
} Comm.FileUpLoad(this.FileUpload1, filepath, document.Name); BioCrmCorrelationDocumentBLL documentbll = new BioCrmCorrelationDocumentBLL();
//文档信息添加 包括文件上传(转换为二进制数组后上传)
int count= documentbll.BioCrmCorrelationDocumentUpdate(document);
//文档信息添加成功
if (count != 0)
{
BioCrmCustomerDocument customerdocument = new BioCrmCustomerDocument();
customerdocument.CustomerDocumentID = int.Parse(this.hf_CustomerDocumentID.Value);
customerdocument.CustomerID = int.Parse(this.txtCustomerID.Text);
customerdocument.DeleteState =cbDelete.Checked;
customerdocument.DocumentID = document.DocumentID;
BioCrmCustomerDocumentBLL customerdocumentbll = new BioCrmCustomerDocumentBLL();
int count1= customerdocumentbll.BioCrmCustomerDocumentUpdate(customerdocument);
if (count1 == 0)
{
SqlComm.DeleteTableByCondition("BioCrmCorrelationDocument", "where DocumentID=" + document.DocumentID);
}
else
{
Response.Redirect("DocumentListShow.aspx");
}
}
}

不同角色查询不同的文档:

         /// <summary>
/// 查询所有联系人信息
/// </summary>
private void getallPageList()
{
string id = Session["Userid"].ToString();
condition = " and UserID=" + id;
if (UserLogin.user.RoleId == 8)
{
condition = " or UserID !=" + id;
}
this.AspNetPager1.RecordCount = SqlComm.getDataCountByCondition("dbo.View_DoucmentInfo", condition);
this.AspNetPager1.PageSize = pagesize;
this.GridView1.DataSource = SqlComm.getDataByPageIndex("dbo.View_DoucmentInfo", "*", "DocumentID", condition, pageindex, pagesize);
this.GridView1.DataBind();
}

ERP系统上传文档信息下载(十八)的更多相关文章

  1. 百度大脑UNIT3.0解读之对话式文档问答——上传文档获取对话能力

    在日常生活中,用户会经常碰到很多复杂的规章制度.规则条款.比如:乘坐飞机时,能不能带宠物上飞机,3岁小朋友是否需要买票等.在工作中,也会面对公司多样的规定制度和报销政策.比如:商业保险理赔需要什么材料 ...

  2. 跟我学SharePoint 2013视频培训课程——怎样创建文档库并上传文档(8)

    课程简介 第8天,怎样在SharePoint 2013怎样创建文档库并上传文档. 视频 SharePoint 2013 交流群 41032413

  3. 自记录:git如何上传文档到git@osc

    前提: D盘有gitserver文件夹 双击桌面的git.exe文件,打开git命令窗口 输入cd  d: 命令进入D盘 输入cd gitserver命令进入 找到git@osc自己参与项目里的htt ...

  4. 开源ERP系统Odoo搭建文档

    本文参考链接地址: https://devecho.com/v/209/ https://www.cnblogs.com/wxylog/p/6386974.html 什么是Odoo 为什么选择Odoo ...

  5. SharePoint 上传文档提示别人迁出

    前言 我们在使用SharePoint文档库的时候,经常会遇到文档被别人迁出,自己无法修改的情况.这时候,我们最好的办法就是找到那个迁出的人,怼他!如果,他已经离职了,我们无法找到,那么,就请继续往瞎看 ...

  6. HDFS设计思路,HDFS使用,查看集群状态,HDFS,HDFS上传文件,HDFS下载文件,yarn web管理界面信息查看,运行一个mapreduce程序,mapreduce的demo

    26 集群使用初步 HDFS的设计思路 l 设计思想 分而治之:将大文件.大批量文件,分布式存放在大量服务器上,以便于采取分而治之的方式对海量数据进行运算分析: l 在大数据系统中作用: 为各类分布式 ...

  7. linux系统上传下载命令rz和sz的教程

    (一)安装方法汇总(注意:一下命令如果没有权限的需要在每个命令前面加一个sudo) 1.安装方法(推荐) sudo yum install lrzsz 2.在安装Linux系统时选中“DialupNe ...

  8. SecureCRT上传、下载文件 使用rz【上传】& sz【下载】命令

    首先安装:apt-get install lrzsz SecureCRT这款SSH客户端软件同时具备了终端仿真器和文件传输功能.比ftp命令方便多了,而且服务器不用再开FTP服务了.rz,sz是便是L ...

  9. &lt;源代码&gt;FTPclient追加方式上传自己定义信息

    实现功能:向FTPserver以追加方式上传自己定义信息(例程中为:2014-10-08 13:47:15 test.) 源代码下载(免积分):http://download.csdn.net/det ...

随机推荐

  1. js便签笔记(13)——jsonp其实很简单【ajax跨域请求】

    前两天被问到ajax跨域如何解决,还真被问住了,光知道有个什么jsonp,迷迷糊糊的没有说上来.抱着有问题必须解决的态度,我看了许多资料,原来如此... 为何一直知道jsonp,但一直迷迷糊糊的不明白 ...

  2. BootStrap 最佳资源合集(转)

    witter BootStrap是一款优秀的前端的框架,称得上是前端的一个框架利器.Web前端开发者每天都在与HTML.CSS.JavaScript打交道,然 而不少人都是在周而复始的写模板.样式和交 ...

  3. PDF 补丁丁 0.4.1 版:新增嵌入中文字库、替换文档字库的功能

    PDF 补丁丁 0.4.1 版新增了嵌入中文字库.替换文档字库的功能. 嵌入汉字字库 历史上有一批黄底黑字的 PDF 文档.这批文档都具有相同的问题:没有嵌入字库.在一些设备上阅读时显示乱码.复制文本 ...

  4. sqlserver 2008 左补齐字符串

    SQLServer:right函数 语法 Right(string, length)   Right 函数的语法具有下面的命名参数:   部分 说明 string 必要参数.字符串表达式,从中最右边的 ...

  5. AlarmManager手机闹钟简介

    1.void set(int type , long triggerAtTime , PendingIntent operation ) : 设置在 triggerAtTime时间启动由operati ...

  6. HDU 3642 扫描线(立方体体积并)

    Get The Treasury Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  7. linux 线程操作问题undefined reference to 'pthread_create'的解决办法(cmake)

    问题原因: pthread 库不是 Linux 系统默认的库,连接时需要使用静态库 libpthread.a. 所以在使用pthread_create()创建线程时,需要链接该库. 1. 终端:问题解 ...

  8. [开发笔记]-WindowsService服务程序开发

    Windows服务:Microsoft Windows 服务(即,以前的 NT服务)使您能够创建在它们自己的 Windows 会话中可长时间运行的可执行应用程序.这些服务可以在计算机启动时自动启动,可 ...

  9. 10款最好用的MySQL数据库客户端图形界面管理工具

    MySQL Workbench 该工具由MySQL开发,是一个跨平台的可视化数据库设计工具.它是DBDesigner4项目备受期待的替代者,它是一个本地图形化工具,支持的操作系统包括Windows.L ...

  10. [转]powerDesigner生成excel版本的数据库文件

    powerDesigner生成excel版本的数据库文件 出处:http://ray-allen.iteye.com/blog/1893347 脚本 excel  今天收到一个需求,要把数据库设计给一 ...