SGGL_SHJ/SGGL/FineUIPro.Web/ZHGL/Plan/ActionPlanList.aspx.cs

899 lines
47 KiB
C#

using Aspose.Words;
using Aspose.Words.Tables;
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
namespace FineUIPro.Web.ZHGL.Plan
{
public partial class ActionPlanList : PageBase
{
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Funs.DropDownPageSize(this.ddlPageSize);
////权限按钮方法
this.GetButtonPower();
this.btnNew.OnClientClick = Window1.GetShowReference("ActionPlanListEdit.aspx") + "return false;";
ProjectService.InitAllProjectDropDownList(this.drpProject, false);
drpProject.Items.Insert(0, new FineUIPro.ListItem("公司本部", "Company"));
Funs.FineUIPleaseSelect(drpProject, "按项目/公司本部查询");
// 绑定表格
this.BindGrid();
}
}
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
string strSql = "SELECT ActionPlanList.ActionPlanListId,ActionPlanList.ProjectId,Project.ProjectName,ActionPlanListCode,ActionPlanList.ActionPlanListName,ActionPlanList.VersionNo,(CASE ActionPlanList.ProjectType WHEN '1' THEN 'EPC' WHEN '2' THEN 'EPCM' WHEN '3' THEN 'C' WHEN '4' THEN '其他' END ) AS ProjectType,ActionPlanList.ActionPlanListContents,ActionPlanList.CompileMan,Users.PersonName AS CompileManName, ActionPlanList.CompileDate,ActionPlanList.States"
+ @" FROM ActionPlan_ActionPlanList AS ActionPlanList "
+ @" LEFT JOIN Base_Project AS Project ON ActionPlanList.ProjectId=Project.ProjectId "
+ @" LEFT JOIN Sys_FlowOperate AS FlowOperate ON ActionPlanList.ActionPlanListId=FlowOperate.DataId AND FlowOperate.IsClosed <> 1"
+ @" LEFT JOIN Person_Persons AS OperateUser ON FlowOperate.OperaterId=OperateUser.PersonId "
+ @" LEFT JOIN Person_Persons AS Users ON Users.PersonId = ActionPlanList.CompileMan "
+ @" WHERE 1=1 ";
List<SqlParameter> listStr = new List<SqlParameter>();
if (this.drpProject.SelectedValue != BLL.Const._Null)
{
if (this.drpProject.SelectedValue == "Company")
{
strSql += " AND ActionPlanList.ProjectId is null";
}
else
{
strSql += " AND ActionPlanList.ProjectId = @ProjectId";
listStr.Add(new SqlParameter("@ProjectId", this.drpProject.SelectedValue));
}
}
if (!string.IsNullOrEmpty(this.txtActionPlanListCode.Text.Trim()))
{
strSql += " AND ActionPlanListCode LIKE @ActionPlanListCode";
listStr.Add(new SqlParameter("@ActionPlanListCode", "%" + this.txtActionPlanListCode.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.txtActionPlanListName.Text.Trim()))
{
strSql += " AND ActionPlanListName LIKE @ActionPlanListName";
listStr.Add(new SqlParameter("@ActionPlanListName", "%" + this.txtActionPlanListName.Text.Trim() + "%"));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.RecordCount = tb.Rows.Count;
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
#endregion
#region
/// <summary>
/// 改变索引事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
/// <summary>
/// 分页下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
BindGrid();
}
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, EventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.BindGrid();
BLL.LogService.AddSys_Log(this.CurrUser, string.Empty, string.Empty, BLL.Const.OfficeActionPlanListMenuId, Const.BtnQuery);
}
#endregion
#region
/// <summary>
/// 双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
{
this.EditData();
}
/// <summary>
/// 右键编辑事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuEdit_Click(object sender, EventArgs e)
{
this.EditData();
}
/// <summary>
/// 编辑数据方法
/// </summary>
private void EditData()
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string id = Grid1.SelectedRowID.Split(',')[0];
Model.ActionPlan_ActionPlanList actionPlanList = ActionPlanListService.GetActionPlanListById(id);
if (actionPlanList.States == Const.ActionPlanList_Complete)
{
Alert.ShowInTop("该文件已经审批完成,无法操作,请右键查看!", MessageBoxIcon.Warning);
return;
}
else if (actionPlanList.States == Const.ActionPlanList_Compile)
{
if (actionPlanList.CompileMan == CurrUser.PersonId || CurrUser.PersonId == Const.sysglyId)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ActionPlanListEdit.aspx?actionPlanListId={0}", id)));
}
else
{
Alert.ShowInTop("您不是编制人,无法操作!请右键查看", MessageBoxIcon.Warning);
return;
}
}
else if (actionPlanList.States == Const.ActionPlanList_Review || actionPlanList.States == Const.ActionPlanList_Reviewing || actionPlanList.States == Const.ActionPlanList_ReCompile || actionPlanList.States == Const.ActionPlanList_Review2 || actionPlanList.States == Const.ActionPlanList_DepartReview)
{
Model.ActionPlan_ActionPlanListApprove approve = ActionPlanListApproveService.GetActionPlanListApproveByApproveMan(id, CurrUser.PersonId);
if (approve != null || CurrUser.PersonId == Const.sysglyId)
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ActionPlanListEdit.aspx?actionPlanListId={0}", id)));
return;
//Response.Redirect("ActionPlanListAudit.aspx?actionPlanListId=" + id);
//PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckListView.aspx?CheckControlCode={0}", id, "查看 - ")));
}
else
{
if (actionPlanList.CompileMan.Equals(CurrUser.PersonId))
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ActionPlanListEdit.aspx?actionPlanListId={0}", id)));
}
else
{
Alert.ShowInTop("您不是办理用户,无法操作!请右键查看", MessageBoxIcon.Warning);
return;
}
}
}
}
#endregion
protected void btnMenuView_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string id = Grid1.SelectedRowID.Split(',')[0];
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ActionPlanListView.aspx?ActionPlanListId={0}", id)));
}
#region
/// <summary>
/// 右键删除事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length > 0)
{
bool isShow = false;
if (Grid1.SelectedRowIndexArray.Length == 1)
{
isShow = true;
}
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
if (this.judgementDelete(rowID, isShow))
{
var getV = BLL.ActionPlanListService.GetActionPlanListById(rowID);
if (getV != null)
{
BLL.LogService.AddSys_Log(this.CurrUser, getV.ActionPlanListCode, getV.ActionPlanListId, BLL.Const.OfficeActionPlanListMenuId, Const.BtnDelete);
BLL.ActionPlanListService.DeleteActionPlanListById(rowID);
}
}
}
BindGrid();
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
}
}
/// <summary>
/// 判断是否可以删除
/// </summary>
/// <returns></returns>
private bool judgementDelete(string id, bool isShow)
{
string content = string.Empty;
if (string.IsNullOrEmpty(content))
{
return true;
}
else
{
if (isShow)
{
Alert.ShowInTop(content);
}
return false;
}
}
#endregion
#region
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private void GetButtonPower()
{
if (Request.Params["value"] == "0")
{
return;
}
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.OfficeActionPlanListMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
this.btnNew.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnModify))
{
this.btnMenuEdit.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnDelete))
{
this.btnMenuDelete.Hidden = false;
}
}
}
#endregion
#region
/// 导出按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOut_Click(object sender, EventArgs e)
{
Response.ClearContent();
string filename = Funs.GetNewFileName();
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("安全实施计划" + filename, System.Text.Encoding.UTF8) + ".xls");
Response.ContentType = "application/excel";
Response.ContentEncoding = System.Text.Encoding.UTF8;
this.Grid1.PageSize = 5000;
this.BindGrid();
Response.Write(GetGridTableHtml(Grid1));
Response.End();
}
#endregion
/// <summary>
/// 把办理人转换代号为文字形式
/// </summary>
/// <param name="ActionPlanListId"></param>
/// <returns></returns>
///
public static string ConvertApproveMan(object ActionPlanListId)
{
string name = string.Empty;
if (ActionPlanListId != null)
{
var approves = BLL.ActionPlanListApproveService.GetActionPlanListApprovesNotHandleList(ActionPlanListId.ToString());
foreach (var item in approves)
{
name += BLL.Person_PersonsService.GetPersonsNameById(item.ApproveMan) + ",";
}
if (!string.IsNullOrEmpty(name))
{
name = name.Substring(0, name.Length - 1);
}
}
return name;
}
#region
/// <summary>
///
/// </summary>
/// <param name="sender"></param>btnPrinter_Click
/// <param name="e"></param>
protected void btnPrinter_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
return;
}
string Id = Grid1.SelectedRowID;
Model.ActionPlan_ActionPlanList actionPlanList = BLL.ActionPlanListService.GetActionPlanListById(Id);
if (actionPlanList.States != BLL.Const.ActionPlanList_Complete && this.CurrUser.PersonId != BLL.Const.sysglyId && this.CurrUser.PersonId != BLL.Const.hfnbdId)
{
Alert.ShowInTop("状态必须为审批完成的才能导出!", MessageBoxIcon.Warning);
return;
}
if (actionPlanList != null)
{
try
{
string rootPath = Server.MapPath("~/");
string initTemplatePath = string.Empty;
string uploadfilepath = string.Empty;
string newUrl = string.Empty;
string filePath = string.Empty;
initTemplatePath = "File\\Word\\ZHGL\\项目安全生产策划书评审表.doc";
uploadfilepath = rootPath + initTemplatePath;
string projectName = BLL.ProjectService.GetProjectNameByProjectId(actionPlanList.ProjectId);
if (!string.IsNullOrEmpty(projectName))
{
projectName = "(" + projectName + ")";
}
else
{
projectName = "(无项目)";
}
projectName = projectName.Replace("/", "_");
newUrl = uploadfilepath.Replace(".doc", projectName + ".doc");
filePath = uploadfilepath.Replace(".doc", projectName + ".pdf");
if (File.Exists(newUrl))
{
File.Delete(newUrl);
}
File.Copy(uploadfilepath, newUrl);
///更新书签
Document doc = new Aspose.Words.Document(newUrl);
//写入第一行
Bookmark bookmarkProjectName = doc.Range.Bookmarks["ProjectName"];
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var project = ProjectService.GetProjectByProjectId(actionPlanList.ProjectId);
var ActionPlan_ActionPlanListApproveList = db.ActionPlan_ActionPlanListApprove.Where(x => x.ActionPlanListId == Id && x.ApproveType == "2").ToList();
if (bookmarkProjectName != null)
{
if (project != null)
{
if (project.ProjectName.Length > 20 && ActionPlan_ActionPlanListApproveList.Count != 0)
{
bookmarkProjectName.Text = project.ProjectName.Substring(0, 20) + "\n" +
project.ProjectName.Substring(20);
}
else
{
bookmarkProjectName.Text = project.ProjectName;
}
}
}
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
builder.MoveToBookmark("tab");
builder.StartTable();
builder.CellFormat.Borders.LineStyle = LineStyle.Single;
builder.CellFormat.Borders.Color = System.Drawing.Color.Black;
builder.Bold = false;
builder.RowFormat.Height = 20;
builder.Font.Size = 9;
#region
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 100;
builder.Font.Bold = true;
builder.Write("项目部编制人员");
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 300;
builder.Font.Bold = false;
var getCompileMan = Person_PersonsService.GetPerson_PersonsById(actionPlanList.CompileMan);
if (!string.IsNullOrEmpty(getCompileMan.SignatureUrl) && File.Exists(rootPath + getCompileMan.SignatureUrl))
{
var file = rootPath + getCompileMan.SignatureUrl;
builder.InsertImage(file, 80, 20);
}
else
{
builder.Write(getCompileMan.PersonName);
}
builder.EndRow();
#endregion
if (ActionPlan_ActionPlanListApproveList.Count > 0)
{
#region
for (int i = 0; i < ActionPlan_ActionPlanListApproveList.Count; i++)
{
//一行两个
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 100;
builder.Font.Bold = true;
builder.Write("项目部审核人");
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
var getApproveMan = Person_PersonsService.GetPerson_PersonsById(ActionPlan_ActionPlanListApproveList[i].ApproveMan);
//判断是不是最后一个
if (ActionPlan_ActionPlanListApproveList.Count == i + 1)
{
builder.CellFormat.Width = 150;
builder.Font.Bold = false;
if (!string.IsNullOrEmpty(getApproveMan.SignatureUrl) && File.Exists(rootPath + getApproveMan.SignatureUrl))
{
var file = rootPath + getApproveMan.SignatureUrl;
builder.InsertImage(file, 80, 20);
}
else
{
builder.Write(getApproveMan.PersonName);
}
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 150;
builder.Write("");
}
else
{
builder.CellFormat.Width = 150;
builder.Font.Bold = false;
if (!string.IsNullOrEmpty(getApproveMan.SignatureUrl) && File.Exists(rootPath + getApproveMan.SignatureUrl))
{
var file = rootPath + getApproveMan.SignatureUrl;
builder.InsertImage(file, 80, 20);
}
else
{
builder.Write(getApproveMan.PersonName);
}
}
//判断还有没有数据 有的话继续加
if (ActionPlan_ActionPlanListApproveList.Count > i + 1)
{
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 100;
builder.Font.Bold = true;
builder.Write("项目部审核人");
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 50;
var getApproveMan2 = Person_PersonsService.GetPerson_PersonsById(ActionPlan_ActionPlanListApproveList[i + 1].ApproveMan);
builder.Font.Bold = false;
if (!string.IsNullOrEmpty(getApproveMan2.SignatureUrl) && File.Exists(rootPath + getApproveMan2.SignatureUrl))
{
var file = rootPath + getApproveMan2.SignatureUrl;
builder.InsertImage(file, 80, 20);
}
else
{
builder.Write(getApproveMan2.PersonName);
}
builder.EndRow();
i += 1;
}
else
{
//没有数据
builder.EndRow();
}
}
#endregion
}
else
{
}
var approves = db.ActionPlan_ActionPlanListApprove.Where(x => x.ActionPlanListId == Id && x.ApproveType == BLL.Const.ActionPlanList_Reviewing).ToList();
var ActionPlan_ActionPlanListApproveList2 = db.ActionPlan_ActionPlanListApprove.Where(x => x.ActionPlanListId == Id && x.ApproveType == "6").ToList();
DateTime date = DateTime.Now;
if (ActionPlan_ActionPlanListApproveList2.Count > 0 || approves.Count > 0)
{
date = ActionPlan_ActionPlanListApproveList2.OrderByDescending(x => x.ApproveDate).FirstOrDefault().ApproveDate.Value;
#region
//主要评审部门
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 400;
builder.Font.Bold = true;
builder.Write("主要评审部门");
builder.EndRow();
#region
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 150;
builder.Font.Bold = true;
builder.Write("评审部门");
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 100;
builder.Font.Bold = true;
builder.Write("评审意见");
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 150;
builder.Font.Bold = true;
builder.Write("评审部门负责人/日期");
builder.EndRow();
#endregion
foreach (var item in approves)
{
if (item.ApproveDate != null)
{
//部门名称
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 150;
builder.Font.Bold = false;
builder.Write("施工管理部");
//评审意见
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 100;
builder.Font.Bold = false;
if (!string.IsNullOrEmpty(item.ApproveIdea))
{
builder.Write(item.ApproveIdea);
}
else
{
builder.Write("无");
}
//评审日期
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 150;
builder.Font.Bold = false;
if (item.ApproveDate != null)
{
var getUser = Person_PersonsService.GetPerson_PersonsById(item.ApproveMan);
if (!string.IsNullOrEmpty(getUser.SignatureUrl) && File.Exists(rootPath + getUser.SignatureUrl))
{
var file = rootPath + getUser.SignatureUrl;
builder.InsertImage(file, 80, 20);
builder.Write(item.ApproveDate.ToString().Split(' ')[0]);
}
else
{
builder.Write(getUser.PersonName + " " + item.ApproveDate.ToString().Split(' ')[0]);
}
}
else
{
builder.Write("");
}
builder.EndRow();
}
}
foreach (var item in ActionPlan_ActionPlanListApproveList2)
{
if (item.ApproveMan != "905a75d6-e733-449f-9742-4dcd71e8d2e1" && item.DepartId != BLL.Const.Depart_CompanyLeaderId && item.ApproveDate != null)
{
//部门名称
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 150;
var departModel = db.Base_Depart.FirstOrDefault(x => x.DepartId == item.DepartId);
builder.Font.Bold = false;
if (departModel != null)
{
builder.Write(departModel.DepartName);
}
//评审意见
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 100;
builder.Font.Bold = false;
if (!string.IsNullOrEmpty(item.ApproveIdea))
{
builder.Write(item.ApproveIdea);
}
else
{
builder.Write("无");
}
//评审日期
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 150;
builder.Font.Bold = false;
if (item.ApproveDate != null)
{
var getUser = Person_PersonsService.GetPerson_PersonsById(item.ApproveMan);
if (!string.IsNullOrEmpty(getUser.SignatureUrl) && File.Exists(rootPath + getUser.SignatureUrl))
{
var file = rootPath + getUser.SignatureUrl;
builder.InsertImage(file, 80, 20);
builder.Write(item.ApproveDate.ToString().Split(' ')[0]);
}
else
{
builder.Write(getUser.PersonName + " " + item.ApproveDate.ToString().Split(' ')[0]);
}
}
else
{
builder.Write("");
}
builder.EndRow();
}
}
#endregion
}
#region 2
//增加审核
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 100;
builder.Font.Bold = true;
builder.Write("审核");
//公司安全总监/部门负责人
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Bottom;//底部对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//水平居中对齐
builder.CellFormat.Width = 300;
builder.Font.Bold = true;
builder.RowFormat.Height = 40;
var AQApprove = (from x in db.ActionPlan_ActionPlanListApprove
where x.ApproveMan == "905a75d6-e733-449f-9742-4dcd71e8d2e1"
select x).FirstOrDefault();
if (AQApprove != null)
{
builder.Write(AQApprove.ApproveIdea + "\n\n");
}
builder.Write("公司安全总监/部门负责人:");
var personAQ = BLL.Person_PersonsService.GetPerson_PersonsById("905a75d6-e733-449f-9742-4dcd71e8d2e1"); //安全总监任学宁
if (!string.IsNullOrEmpty(personAQ.SignatureUrl) && File.Exists(rootPath + personAQ.SignatureUrl))
{
var file = rootPath + personAQ.SignatureUrl;
builder.InsertImage(file, 80, 20);
builder.Write(date.ToString().Split(' ')[0]);
}
else
{
builder.Write(personAQ.PersonName + " " + date.ToString().Split(' ')[0]);
}
//builder.Write(" 年");
//builder.Write(" 月");
//builder.Write(" 日");
builder.EndRow();
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 100;
builder.Font.Bold = true;
builder.Write("审批");
//公司安全总监/部门负责人
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Bottom;//底部对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//水平居中对齐
builder.CellFormat.Width = 300;
builder.Font.Bold = true;
builder.RowFormat.Height = 40;
var GSLDApprove = (from x in db.ActionPlan_ActionPlanListApprove
join y in db.Person_Persons
on x.ApproveMan equals y.PersonId
where x.ActionPlanListId == Id && x.DepartId == BLL.Const.Depart_CompanyLeaderId
select x).FirstOrDefault();
if (GSLDApprove != null)
{
builder.Write(GSLDApprove.ApproveIdea + "\n\n");
}
builder.Write("公司主管生产/安全领导:");
if (GSLDApprove != null)
{
var personGSLD = BLL.Person_PersonsService.GetPerson_PersonsById(GSLDApprove.ApproveMan);
if (!string.IsNullOrEmpty(personGSLD.SignatureUrl) && File.Exists(rootPath + personGSLD.SignatureUrl))
{
var file = rootPath + personGSLD.SignatureUrl;
builder.InsertImage(file, 80, 20);
builder.Write(GSLDApprove.ApproveDate.ToString().Split(' ')[0]);
}
else
{
builder.Write(personGSLD.PersonName + " " + GSLDApprove.ApproveDate.ToString().Split(' ')[0]);
}
}
else
{
builder.Write(" 年");
builder.Write(" 月");
builder.Write(" 日");
}
builder.EndRow();
builder.Font.Bold = false;
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//水平居中对齐
builder.Write("(公司主要评审部门指:安全质量监督部、运营管理部、施工管理部、工艺设计部、财务资产部、采购部、控制部等)");
#endregion
}
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;
Response.Clear();
Response.ContentType = "application/x-zip-compressed";
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
Response.AddHeader("Content-Length", fileSize.ToString());
Response.TransmitFile(pdfUrl, 0, fileSize);
Response.Flush();
Response.Close();
File.Delete(newUrl);
File.Delete(pdfUrl);
}
catch (Exception ex)
{
throw ex;
}
}
else
{
Alert.ShowInTop("未查询到数据,请检查网络!", MessageBoxIcon.Warning);
return;
}
}
private string man(string manName)
{
string appman = string.Empty;
if (Person_PersonsService.GetPerson_PersonsById(manName.ToString()) != null)
{
appman = Person_PersonsService.GetPerson_PersonsById(manName.ToString()).PersonName;
}
return appman;
}
#endregion
}
}