2023-03-03 合同打印修改,在线编辑文档控件增加

This commit is contained in:
2023-03-03 10:46:14 +08:00
parent 1cf35eb878
commit 1a8b21b64f
38 changed files with 3465 additions and 695 deletions
@@ -378,91 +378,88 @@ namespace FineUIPro.Web.PHTGL.BiddingManagement
}
#endregion
#region
/// <summary>
/// ApproveUserReviewById
/// </summary>
/// <param name="id"></param>
public void Print(string Id)
{
string rootPath = Server.MapPath("~/");
string initTemplatePath = string.Empty;
string uploadfilepath = string.Empty;
string newUrl = string.Empty;
string filePath = string.Empty;
initTemplatePath = "File\\Word\\PHTGL\\施工招标评标小组名单审批表.docx";
uploadfilepath = rootPath + initTemplatePath;
newUrl = uploadfilepath.Replace(".docx", string.Format("{0:yyyy-MM}", DateTime.Now) + ".docx");
filePath = initTemplatePath.Replace(".docx", string.Format("{0:yyyy-MM}", DateTime.Now) + ".pdf");
if (File.Exists(newUrl))
{
File.Delete(newUrl);
}
File.Copy(uploadfilepath, newUrl);
///更新书签
var getFireWork = PHTGL_BidApproveUserReviewService.GetPHTGL_BidApproveUserReviewById(Id);
var Bid = PHTGL_BidDocumentsReviewService.GetPHTGL_BidDocumentsReviewById(getFireWork.BidDocumentsReviewId);
var Act = BLL.PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(Bid.ActionPlanID);
#region
string strSql = @" SELECT Number = row_number() over(order by ID)
,APP.ApproveUserName as Name
,APP.ApproveUserSpecial as Special
,APP.ApproveUserUnit as Unit
,APP.Remarks as Remarks"
+ @" FROM PHTGL_BidApproveUserReview_Sch1 AS APP "
+ @"where 1=1 AND ApproveUserReviewID = @ApproveUserReviewID ";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ApproveUserReviewID", Id));
//public void Print(string Id)
//{
// string rootPath = Server.MapPath("~/");
// string initTemplatePath = string.Empty;
// string uploadfilepath = string.Empty;
// string newUrl = string.Empty;
// string filePath = string.Empty;
// initTemplatePath = "File\\Word\\PHTGL\\施工招标评标小组名单审批表.docx";
// uploadfilepath = rootPath + initTemplatePath;
// newUrl = uploadfilepath.Replace(".docx", string.Format("{0:yyyy-MM}", DateTime.Now) + ".docx");
// filePath = initTemplatePath.Replace(".docx", string.Format("{0:yyyy-MM}", DateTime.Now) + ".pdf");
// if (File.Exists(newUrl))
// {
// File.Delete(newUrl);
// }
// File.Copy(uploadfilepath, newUrl);
// ///更新书签
// var getFireWork = PHTGL_BidApproveUserReviewService.GetPHTGL_BidApproveUserReviewById(Id);
// var Bid = PHTGL_BidDocumentsReviewService.GetPHTGL_BidDocumentsReviewById(getFireWork.BidDocumentsReviewId);
// var Act = BLL.PHTGL_ActionPlanFormationService.GetPHTGL_ActionPlanFormationById(Bid.ActionPlanID);
// #region 评标小组成员名单
// string strSql = @" SELECT Number = row_number() over(order by ID)
// ,APP.ApproveUserName as Name
// ,APP.ApproveUserSpecial as Special
// ,APP.ApproveUserUnit as Unit
// ,APP.Remarks as Remarks"
// + @" FROM PHTGL_BidApproveUserReview_Sch1 AS APP "
// + @"where 1=1 AND ApproveUserReviewID = @ApproveUserReviewID ";
// List<SqlParameter> listStr = new List<SqlParameter>();
// listStr.Add(new SqlParameter("@ApproveUserReviewID", Id));
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
tb.TableName = "Table";
Document doc = new Aspose.Words.Document(newUrl);
doc.MailMerge.ExecuteWithRegions(tb);
#endregion
Dictionary<string, object> Dic_File = new Dictionary<string, object>();
Dic_File.Add("txtProjectName", Act.ProjectShortName);
Dic_File.Add("txtBidProject", getFireWork.BidProject);
Dic_File.Add("txtBidDocumentCode", Bid.BidDocumentsCode);
foreach (var item in Dic_File)
{
string[] key = { item.Key };
object[] value = { item.Value };
doc.MailMerge.Execute(key, value);
// SqlParameter[] parameter = listStr.ToArray();
// DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
// tb.TableName = "Table";
// Document doc = new Aspose.Words.Document(newUrl);
// doc.MailMerge.ExecuteWithRegions(tb);
// #endregion
// Dictionary<string, object> Dic_File = new Dictionary<string, object>();
// Dic_File.Add("txtProjectName", Act.ProjectShortName);
// Dic_File.Add("txtBidProject", getFireWork.BidProject);
// Dic_File.Add("txtBidDocumentCode", Bid.BidDocumentsCode);
// foreach (var item in Dic_File)
// {
// string[] key = { item.Key };
// object[] value = { item.Value };
// doc.MailMerge.Execute(key, value);
}
// }
if (getFireWork.State == Const.ContractReview_Complete)
{
AsposeWordHelper.InsertImg(doc, rootPath, "Approval_Construction", getFireWork.Approval_Construction, "");
AsposeWordHelper.InsertImg(doc, rootPath, "ConstructionManager", getFireWork.ConstructionManager, "");
AsposeWordHelper.InsertImg(doc, rootPath, "DeputyGeneralManager", getFireWork.DeputyGeneralManager, "");
AsposeWordHelper.InsertImg(doc, rootPath, "ProjectManager", getFireWork.ProjectManager, "");
// if (getFireWork.State == Const.ContractReview_Complete)
// {
// AsposeWordHelper.InsertImg(doc, rootPath, "Approval_Construction", getFireWork.Approval_Construction, "");
// AsposeWordHelper.InsertImg(doc, rootPath, "ConstructionManager", getFireWork.ConstructionManager, "");
// AsposeWordHelper.InsertImg(doc, rootPath, "DeputyGeneralManager", getFireWork.DeputyGeneralManager, "");
// AsposeWordHelper.InsertImg(doc, rootPath, "ProjectManager", getFireWork.ProjectManager, "");
}
doc.Save(newUrl);
//生成PDF文件
string pdfUrl = newUrl.Replace(".doc", ".pdf");
Document doc1 = new Aspose.Words.Document(newUrl);
//验证参数
if (doc1 == null) { throw new Exception("Word文件无效"); }
doc1.Save(pdfUrl, Aspose.Words.SaveFormat.Pdf);//还可以改成其它格式
string fileName = Path.GetFileName(filePath);
FileInfo info = new FileInfo(pdfUrl);
long fileSize = info.Length;
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());
System.Web.HttpContext.Current.Response.TransmitFile(pdfUrl, 0, fileSize);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.Close();
File.Delete(newUrl);
File.Delete(pdfUrl);
}
// }
// doc.Save(newUrl);
// //生成PDF文件
// string pdfUrl = newUrl.Replace(".doc", ".pdf");
// Document doc1 = new Aspose.Words.Document(newUrl);
// //验证参数
// if (doc1 == null) { throw new Exception("Word文件无效"); }
// doc1.Save(pdfUrl, Aspose.Words.SaveFormat.Pdf);//还可以改成其它格式
// string fileName = Path.GetFileName(filePath);
// FileInfo info = new FileInfo(pdfUrl);
// long fileSize = info.Length;
// System.Web.HttpContext.Current.Response.Clear();
// System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
// System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
// System.Web.HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());
// System.Web.HttpContext.Current.Response.TransmitFile(pdfUrl, 0, fileSize);
// System.Web.HttpContext.Current.Response.Flush();
// System.Web.HttpContext.Current.Response.Close();
// File.Delete(newUrl);
// File.Delete(pdfUrl);
//}
protected void btnPrinter_Click(object sender, EventArgs e)
{
@@ -472,7 +469,7 @@ namespace FineUIPro.Web.PHTGL.BiddingManagement
return;
}
string Id = Grid1.SelectedRowID;
Print(Id);
BLL.PHTGL_BidApproveUserReviewService.PrintFile( Id);
}
#endregion
}