ERP系统上传文档信息下载(十八)
下载的公用方法:
/// <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系统上传文档信息下载(十八)的更多相关文章
- 百度大脑UNIT3.0解读之对话式文档问答——上传文档获取对话能力
在日常生活中,用户会经常碰到很多复杂的规章制度.规则条款.比如:乘坐飞机时,能不能带宠物上飞机,3岁小朋友是否需要买票等.在工作中,也会面对公司多样的规定制度和报销政策.比如:商业保险理赔需要什么材料 ...
- 跟我学SharePoint 2013视频培训课程——怎样创建文档库并上传文档(8)
课程简介 第8天,怎样在SharePoint 2013怎样创建文档库并上传文档. 视频 SharePoint 2013 交流群 41032413
- 自记录:git如何上传文档到git@osc
前提: D盘有gitserver文件夹 双击桌面的git.exe文件,打开git命令窗口 输入cd d: 命令进入D盘 输入cd gitserver命令进入 找到git@osc自己参与项目里的htt ...
- 开源ERP系统Odoo搭建文档
本文参考链接地址: https://devecho.com/v/209/ https://www.cnblogs.com/wxylog/p/6386974.html 什么是Odoo 为什么选择Odoo ...
- SharePoint 上传文档提示别人迁出
前言 我们在使用SharePoint文档库的时候,经常会遇到文档被别人迁出,自己无法修改的情况.这时候,我们最好的办法就是找到那个迁出的人,怼他!如果,他已经离职了,我们无法找到,那么,就请继续往瞎看 ...
- HDFS设计思路,HDFS使用,查看集群状态,HDFS,HDFS上传文件,HDFS下载文件,yarn web管理界面信息查看,运行一个mapreduce程序,mapreduce的demo
26 集群使用初步 HDFS的设计思路 l 设计思想 分而治之:将大文件.大批量文件,分布式存放在大量服务器上,以便于采取分而治之的方式对海量数据进行运算分析: l 在大数据系统中作用: 为各类分布式 ...
- linux系统上传下载命令rz和sz的教程
(一)安装方法汇总(注意:一下命令如果没有权限的需要在每个命令前面加一个sudo) 1.安装方法(推荐) sudo yum install lrzsz 2.在安装Linux系统时选中“DialupNe ...
- SecureCRT上传、下载文件 使用rz【上传】& sz【下载】命令
首先安装:apt-get install lrzsz SecureCRT这款SSH客户端软件同时具备了终端仿真器和文件传输功能.比ftp命令方便多了,而且服务器不用再开FTP服务了.rz,sz是便是L ...
- <源代码>FTPclient追加方式上传自己定义信息
实现功能:向FTPserver以追加方式上传自己定义信息(例程中为:2014-10-08 13:47:15 test.) 源代码下载(免积分):http://download.csdn.net/det ...
随机推荐
- PHP 高并发、抢票、秒杀 解决方案
对于抢票.秒杀这种业务,我说说自己对这种高并发的理解吧,这里提出个人认为比较可行的几个方案:方案一:使用队列来实现可以基于例如MemcacheQ等这样的消息队列,具体的实现方案这么表述吧比如有100张 ...
- nyoj------203三国志
三国志 时间限制:3000 ms | 内存限制:65535 KB 难度:5 描述 <三国志>是一款很经典的经营策略类游戏.我们的小白同学是这款游戏的忠实玩家.现在他把游戏简化一下,地 ...
- uva 10723
10723 - Cyborg Genes Time limit: 3.000 seconds Problem F Cyborg Genes Time Limit 1 Second Septembe ...
- 454. 4Sum II ——查找本质:hash最快,二分次之
Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such t ...
- mysql 5.7 zip 文件在 windows下的安装
1.下载mysql最新版本. http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.15-winx64.zip 2.解压到文件夹. D:\softwa ...
- Hive的Transform功能
Hive的TRANSFORM关键字提供了在SQL中调用自写脚本的功能,适合实现Hive中没有的功能又不想写UDF的情况.例如,按日期统计每天出现的uid数,通常用如下的SQL SELECT date, ...
- [开发笔记]-Windows Service服务相关注意事项
注意一:报错:“本地计算机上的 *** 服务启动后停止.某些服务在未由其他服务或程序使用时将自动停止.” 该问题主要的原因是 Service服务程序中有错误. 遇到这个问题时,无论是重新安装服务,还是 ...
- HDOJ 1754 I Hate It 线段树 第二题
I Hate It Problem Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少.这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就 ...
- SeGue 多控制器跨界面传递数据原理
多控制器跨界面传递数据原理
- 站在K2角度审视流程--任务的独占与释放
应用场景一:某件事情由A.B两人(或者更多人)完成,任务开始后,两人随时可以处理任务,只需有一人处理完成,此事情即可结束. 应用场景二:某件事情由A.B两人(或者更多人)完成,任务开始后,两人随时可以 ...