408 lines
18 KiB
C#
408 lines
18 KiB
C#
using BLL;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.IO;
|
|
using Org.BouncyCastle.Bcpg.OpenPgp;
|
|
using Aspose.Words;
|
|
|
|
namespace FineUIPro.Web.JGZL
|
|
{
|
|
public partial class CommencementReport : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
private string CommencementReportId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["CommencementReportId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["CommencementReportId"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 项目Id
|
|
/// </summary>
|
|
private string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 加载页面
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
//this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
|
|
|
this.drpProjectId.DataTextField = "ProjectCode";
|
|
this.drpProjectId.DataValueField = "ProjectId";
|
|
this.drpProjectId.DataSource = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
|
|
this.drpProjectId.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpProjectId);
|
|
|
|
this.drpProjectId.SelectedValue = this.CurrUser.LoginProjectId;
|
|
this.InitTreeMenu();//加载树
|
|
this.tvControlItem.SelectedNodeID = this.drpProjectId.SelectedValue;
|
|
this.ProjectId = this.tvControlItem.SelectedNodeID;
|
|
//this.BindGrid();
|
|
PageData();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
private void EmptyText()
|
|
{
|
|
txtContractNumber.Text = string.Empty;
|
|
txtDesignUnit.Text = string.Empty;
|
|
txtPlannedStartDate.Text = string.Empty;
|
|
txtPlannedEndDate.Text = string.Empty;
|
|
txtProjectContent.Text = string.Empty;
|
|
txtConditions.Text = string.Empty;
|
|
txtReviewOpinion.Text = string.Empty;
|
|
txtQualitySupervisionOpinion.Text = string.Empty;
|
|
}
|
|
|
|
private void PageData()
|
|
{
|
|
EmptyText();
|
|
//string projectId = this.tvControlItem.SelectedNodeID;
|
|
if (!string.IsNullOrEmpty(this.ProjectId))
|
|
{
|
|
string pipeLineClass = string.Empty;
|
|
List<string> pipeLineClassLists = new List<string>();
|
|
var isoInfos = (from x in Funs.DB.HJGL_PW_IsoInfo where x.ProjectId == this.ProjectId select x).ToList();
|
|
foreach (var item in isoInfos)
|
|
{
|
|
if (!string.IsNullOrEmpty(item.PipeLineClass) && item.PipeLineClass != "/")
|
|
{
|
|
pipeLineClassLists.Add(item.PipeLineClass);
|
|
}
|
|
}
|
|
foreach (var item in pipeLineClassLists.Distinct())
|
|
{
|
|
pipeLineClass += item + "、";
|
|
}
|
|
if (!string.IsNullOrEmpty(pipeLineClass))
|
|
{
|
|
pipeLineClass = pipeLineClass.Substring(0, pipeLineClass.LastIndexOf('、'));
|
|
}
|
|
double SumSize = Convert.ToDouble((from x in Funs.DB.HJGL_PW_JointInfo where x.ProjectId == this.ProjectId select x.JOT_Size).Sum());
|
|
|
|
|
|
var report = BLL.CommencementReportService.GetCommencementReportByProjectId(this.ProjectId);
|
|
if (report != null)
|
|
{
|
|
this.CommencementReportId = report.CommencementReportId;
|
|
if (!string.IsNullOrEmpty(report.ContractNumber))
|
|
{
|
|
this.txtContractNumber.Text = report.ContractNumber;
|
|
}
|
|
this.txtDesignUnit.Text = report.DesignUnit;
|
|
this.txtPlannedStartDate.Text = report.PlannedStartDate.HasValue ? string.Format("{0:yyyy-MM-dd}", report.PlannedStartDate) : "";
|
|
this.txtPlannedEndDate.Text = report.PlannedEndDate.HasValue ? string.Format("{0:yyyy-MM-dd}", report.PlannedEndDate) : "";
|
|
if (!string.IsNullOrEmpty(report.Conditions))
|
|
{
|
|
this.txtConditions.Text = report.Conditions;
|
|
}
|
|
else
|
|
{
|
|
this.txtConditions.Text = "1、施工方案已经审批:\r\n2、压力管道告知已经办理:\r\n3、材料已经到货并报验合格:\r\n4、人员已经进行技术安全交底:\r\n5、现场已经施工具备开工条件。";
|
|
}
|
|
if (!string.IsNullOrEmpty(report.ProjectContent))
|
|
{
|
|
this.txtProjectContent.Text = report.ProjectContent;
|
|
}
|
|
this.txtReviewOpinion.Text = report.ReviewOpinion;
|
|
this.txtQualitySupervisionOpinion.Text = report.QualitySupervisionOpinion;
|
|
}
|
|
else
|
|
{
|
|
this.CommencementReportId = string.Empty;
|
|
this.txtContractNumber.Text = BLL.Base_ProjectService.GetProjectCode(this.ProjectId);
|
|
this.txtProjectContent.Text = BLL.Base_ProjectService.GetProjectByProjectId(this.ProjectId).ProjectName + ",管道类别为" + pipeLineClass + "级,共计安装压力管道" + isoInfos.Count.ToString() + "条,总吋径量" + SumSize.ToString(".00") + "吋,该项目已经达到开工条件。";
|
|
this.txtConditions.Text = "1、施工方案已经审批:\r\n2、压力管道告知已经办理:\r\n3、材料已经到货并报验合格:\r\n4、人员已经进行技术安全交底:\r\n5、现场已经施工具备开工条件。";
|
|
}
|
|
}
|
|
}
|
|
|
|
#region 加载树项目
|
|
/// <summary>
|
|
/// 加载树
|
|
/// </summary>
|
|
private void InitTreeMenu()
|
|
{
|
|
this.tvControlItem.Nodes.Clear();
|
|
TreeNode rootNode = new TreeNode();
|
|
rootNode.Text = "项目";
|
|
rootNode.ToolTip = "项目";
|
|
rootNode.NodeID = "0";
|
|
rootNode.Expanded = true;
|
|
this.tvControlItem.Nodes.Add(rootNode);
|
|
|
|
List<Model.Base_Project> projects = BLL.Base_ProjectService.GetOnProjectListByUserId(this.CurrUser.UserId, "1");
|
|
if (this.drpProjectId.SelectedValue != BLL.Const._Null)
|
|
{
|
|
projects = projects.Where(e => e.ProjectId == this.drpProjectId.SelectedValue).ToList();
|
|
}
|
|
foreach (var item in projects)
|
|
{
|
|
TreeNode rootProjectNode = new TreeNode();//定义根节点
|
|
rootProjectNode.Text = item.ProjectCode;
|
|
rootProjectNode.NodeID = item.ProjectId;
|
|
rootProjectNode.EnableClickEvent = true;
|
|
rootProjectNode.Expanded = true;
|
|
rootProjectNode.ToolTip = item.ProjectName;
|
|
rootProjectNode.CommandName = "项目名称";
|
|
rootNode.Nodes.Add(rootProjectNode);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 点击TreeView
|
|
/// <summary>
|
|
/// 点击TreeView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
if (this.tvControlItem.SelectedNodeID != "0")
|
|
{
|
|
this.ProjectId = this.tvControlItem.SelectedNodeID;
|
|
PageData();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
///<summary>
|
|
///查询
|
|
///</summary>
|
|
///<param name="sender"></param>
|
|
///<param name="e"></param>
|
|
protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.tvControlItem.SelectedNodeID = this.drpProjectId.SelectedValue;
|
|
this.ProjectId = this.tvControlItem.SelectedNodeID;
|
|
this.InitTreeMenu();
|
|
PageData();
|
|
}
|
|
#endregion
|
|
|
|
#region 打印
|
|
/// <summary>
|
|
/// 打印
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnPrint_Click(object sender, EventArgs e)
|
|
{
|
|
string projectId = this.tvControlItem.SelectedNodeID;
|
|
if (projectId != null)
|
|
{
|
|
string initTemplatePath = "";
|
|
string rootPath = Server.MapPath("~/");
|
|
BLL.Common.FastReportService.ResetData();
|
|
|
|
var report = BLL.CommencementReportService.GetCommencementReportByProjectId(projectId);
|
|
if (report != null)
|
|
{
|
|
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
|
|
keyValuePairs.Add("ProjectName", BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName);
|
|
keyValuePairs.Add("ContractNumber", report.ContractNumber);
|
|
keyValuePairs.Add("DesignUnit", report.DesignUnit);
|
|
keyValuePairs.Add("PlannedStartDate", report.PlannedStartDate.HasValue ? string.Format("{0:yyyy年MM月dd日}", report.PlannedStartDate) : "");
|
|
keyValuePairs.Add("PlannedEndDate", report.PlannedEndDate.HasValue ? string.Format("{0:yyyy年MM月dd日}", report.PlannedEndDate) : "");
|
|
keyValuePairs.Add("ProjectContent", report.ProjectContent);
|
|
keyValuePairs.Add("Conditions", report.Conditions);
|
|
keyValuePairs.Add("ReviewOpinion", report.ReviewOpinion);
|
|
keyValuePairs.Add("QualitySupervisionOpinion", report.QualitySupervisionOpinion);
|
|
BLL.Common.FastReportService.AddFastreportParameter(keyValuePairs);
|
|
|
|
initTemplatePath = "File\\Fastreport\\JGZL\\工程施工开工报告.frx";
|
|
if (File.Exists(rootPath + initTemplatePath))
|
|
{
|
|
PageContext.RegisterStartupScript(WindowPrint.GetShowReference(String.Format("../common/ReportPrint/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请先保存数据!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 保存
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.JGZL_CommencementReportMenuId, Const.BtnSave))
|
|
{
|
|
Model.JGZL_CommencementReport newReport = new Model.JGZL_CommencementReport();
|
|
newReport.ContractNumber = this.txtContractNumber.Text.Trim();
|
|
newReport.DesignUnit = this.txtDesignUnit.Text.Trim();
|
|
newReport.PlannedStartDate = Funs.GetNewDateTime(this.txtPlannedStartDate.Text);
|
|
newReport.PlannedEndDate = Funs.GetNewDateTime(this.txtPlannedEndDate.Text);
|
|
newReport.ProjectContent = this.txtProjectContent.Text;
|
|
newReport.Conditions = this.txtConditions.Text;
|
|
newReport.ReviewOpinion = this.txtReviewOpinion.Text;
|
|
newReport.QualitySupervisionOpinion = this.txtQualitySupervisionOpinion.Text;
|
|
if (!string.IsNullOrEmpty(this.CommencementReportId))
|
|
{
|
|
newReport.CommencementReportId = this.CommencementReportId;
|
|
BLL.CommencementReportService.UpdateCommencementReport(newReport);
|
|
ShowNotify("修改成功!", MessageBoxIcon.Success);
|
|
}
|
|
else
|
|
{
|
|
newReport.ProjectId = this.ProjectId;
|
|
newReport.CompileMan = this.CurrUser.UserId;
|
|
newReport.CompileDate = DateTime.Now;
|
|
newReport.CommencementReportId = SQLHelper.GetNewID(typeof(Model.JGZL_CommencementReport));
|
|
this.CommencementReportId = newReport.CommencementReportId;
|
|
BLL.CommencementReportService.AddCommencementReport(newReport);
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
}
|
|
PageData();
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 导出按钮
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
string rootPath = Server.MapPath("~/");
|
|
string initTemplatePath = string.Empty;
|
|
string uploadfilepath = string.Empty;
|
|
string newUrl = string.Empty;
|
|
string filePath = string.Empty;
|
|
|
|
string projectId = this.tvControlItem.SelectedNodeID;
|
|
if (!string.IsNullOrEmpty(projectId))
|
|
{
|
|
initTemplatePath = Const.JGZL_CommencementReportUrl;
|
|
uploadfilepath = rootPath + initTemplatePath;
|
|
|
|
newUrl = uploadfilepath.Replace("工程施工开工报告导出模板", "工程施工开工报告");
|
|
if (File.Exists(newUrl))
|
|
{
|
|
File.Delete(newUrl);
|
|
}
|
|
File.Copy(uploadfilepath, newUrl);
|
|
Document doc = new Aspose.Words.Document(uploadfilepath);
|
|
|
|
Bookmark projectName = doc.Range.Bookmarks["ProjectName"];
|
|
if (projectName != null)
|
|
{
|
|
projectName.Text = BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName;
|
|
}
|
|
Bookmark contractNumber = doc.Range.Bookmarks["ContractNumber"];
|
|
if (contractNumber != null)
|
|
{
|
|
contractNumber.Text = this.txtContractNumber.Text;
|
|
}
|
|
Bookmark designUnit = doc.Range.Bookmarks["DesignUnit"];
|
|
if (designUnit != null)
|
|
{
|
|
designUnit.Text = this.txtDesignUnit.Text;
|
|
}
|
|
Bookmark plannedStartDate =doc.Range.Bookmarks["PlannedStartDate"];
|
|
if (plannedStartDate != null)
|
|
{
|
|
string startDate = string.Format("{0:yyyy年MM月dd日}", Funs.GetNewDateTime(this.txtPlannedStartDate.Text));
|
|
plannedStartDate.Text = startDate;
|
|
}
|
|
Bookmark plannedEndDate = doc.Range.Bookmarks["PlannedEndDate"];
|
|
if (plannedEndDate != null)
|
|
{
|
|
string endDate = string.Format("{0:yyyy年MM月dd日}", Funs.GetNewDateTime(this.txtPlannedEndDate.Text));
|
|
plannedEndDate.Text = endDate;
|
|
}
|
|
Bookmark projectContent = doc.Range.Bookmarks["ProjectContent"];
|
|
if (projectContent != null)
|
|
{
|
|
projectContent.Text = this.txtProjectContent.Text;
|
|
}
|
|
Bookmark conditions = doc.Range.Bookmarks["Conditions"];
|
|
if (conditions != null)
|
|
{
|
|
conditions.Text = this.txtConditions.Text;
|
|
}
|
|
Bookmark reviewOpinion = doc.Range.Bookmarks["ReviewOpinion"];
|
|
if (reviewOpinion != null)
|
|
{
|
|
reviewOpinion.Text = this.txtReviewOpinion.Text;
|
|
}
|
|
Bookmark qualitySupervisionOpinion = doc.Range.Bookmarks["QualitySupervisionOpinion"];
|
|
if (qualitySupervisionOpinion != null)
|
|
{
|
|
qualitySupervisionOpinion.Text = this.txtQualitySupervisionOpinion.Text;
|
|
}
|
|
doc.Save(newUrl);
|
|
|
|
string fileName = Path.GetFileName(newUrl);
|
|
FileInfo info = new FileInfo(newUrl);
|
|
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(newUrl, 0, fileSize);
|
|
Response.Flush();
|
|
Response.Close();
|
|
File.Delete(newUrl);
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("请选择项目!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |