string contract_id = context.Request["contract_id"];
if (string.IsNullOrEmpty(contract_id))
{
context.Response.Write("请求参数错误,生成合同文件失败");
return;
}
MemoryStream stream;
//项目性质
string sql = "select project_property from t_crm_business where contract_id=@contract_id";
object project_property = adoTask.ExecuteSqlScalar(sql, new SqlParameter("@contract_id", contract_id));
if (project_property != null && "自送样".Equals(project_property.ToString()))
{
stream = new BusinessService().CreateContractDocumentFile2(contract_id, Current_CompanyId);
}
else
{
stream = new BusinessService().CreateContractDocumentFile(contract_id, Current_CompanyId);
}
context.Response.Clear();
context.Response.ContentType = "application/octet-stream;charset=gb2321";
string filename = "合同" + Guid.NewGuid().ToString().Substring(0, 6);
context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename + ".doc");
context.Response.ContentType = "application/msword";
context.Response.Charset = "utf-8";
context.Response.BinaryWrite(stream.ToArray());
context.Response.End();