Files
HJGL_DS/HJGL_DS/FineUIPro.Web/JGZL/ConDrawingVerification.aspx.cs
T
2026-03-25 16:30:59 +08:00

362 lines
15 KiB
C#

using BLL;
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 Aspose.Words;
namespace FineUIPro.Web.JGZL
{
public partial class ConDrawingVerification : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
private string ConDrawingVerificationId
{
get
{
return (string)ViewState["ConDrawingVerificationId"];
}
set
{
ViewState["ConDrawingVerificationId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
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;
PageData();
}
}
private void PageData()
{
EmptyText();
string projectId = this.tvControlItem.SelectedNodeID;
if (!string.IsNullOrEmpty(projectId))
{
var report = BLL.ConDrawingVerificationService.GetConDrawingVerificationByProjectId(projectId);
if (report != null)
{
this.ConDrawingVerificationId = report.ConDrawingVerificationId;
this.txtDesignUnit.Text = report.DesignUnit;
this.txtProfessional.Text = report.Professional;
//this.txtHost.Text = report.Host;
this.txtVerificationDate.Text = report.VerificationDate.HasValue ? string.Format("{0:yyyy-MM-dd}", report.VerificationDate) : "";
this.txtConDrawingCode.Text = report.ConDrawingCode;
//this.txtPersonnel.Text = report.Personnel;
this.txtContents.Text = report.Contents;
this.txtProblems.Text = report.Problems;
//this.txtRecorder.Text = report.Recorder;
this.txtRecordDate.Text = report.RecordDate.HasValue ? string.Format("{0:yyyy-MM-dd}", report.RecordDate) : "";
//this.txtReviewer.Text = report.Reviewer;
this.txtReviewDate.Text = report.ReviewDate.HasValue ? string.Format("{0:yyyy-MM-dd}", report.ReviewDate) : "";
}
else
{
this.ConDrawingVerificationId = string.Empty;
this.txtVerificationDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
this.txtConDrawingCode.Text = BLL.Base_ProjectService.GetProjectCode(projectId);
}
}
}
private void EmptyText()
{
txtDesignUnit.Text = string.Empty;
txtProfessional.Text = string.Empty;
txtVerificationDate.Text = string.Empty;
txtConDrawingCode.Text = string.Empty;
txtContents.Text = string.Empty;
txtProblems.Text = string.Empty;
txtRecordDate.Text = string.Empty;
txtReviewDate.Text = string.Empty;
}
#endregion
#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")
{
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.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.ConDrawingVerificationService.GetConDrawingVerificationByProjectId(projectId);
if (report != null)
{
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
keyValuePairs.Add("ProjectName", BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName);
keyValuePairs.Add("DesignUnit", report.DesignUnit);
keyValuePairs.Add("Professional", report.Professional);
keyValuePairs.Add("Host", report.Host);
keyValuePairs.Add("VerificationDate", report.VerificationDate.HasValue ? string.Format("{0:yyyy年MM月dd日}", report.VerificationDate) : "");
keyValuePairs.Add("ConDrawingCode", report.ConDrawingCode);
keyValuePairs.Add("Personnel", report.Personnel);
keyValuePairs.Add("Contents", report.Contents);
keyValuePairs.Add("Problems", report.Problems);
keyValuePairs.Add("Recorder", report.Recorder);
keyValuePairs.Add("RecordDate", report.RecordDate.HasValue ? string.Format("{0:yyyy年MM月dd日}", report.RecordDate) : "");
keyValuePairs.Add("Reviewer", report.Reviewer);
keyValuePairs.Add("ReviewDate", report.ReviewDate.HasValue ? string.Format("{0:yyyy年MM月dd日}", report.ReviewDate) : "");
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);
return;
}
}
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_ConDrawingVerificationMenuId, Const.BtnSave))
{
Model.JGZL_ConDrawingVerification newReport = new Model.JGZL_ConDrawingVerification();
newReport.DesignUnit = this.txtDesignUnit.Text.Trim();
newReport.Professional = this.txtProfessional.Text.Trim();
//newReport.Host = this.txtHost.Text.Trim();
newReport.VerificationDate = Funs.GetNewDateTime(this.txtVerificationDate.Text);
newReport.ConDrawingCode = txtConDrawingCode.Text.Trim();
//newReport.Personnel = this.txtPersonnel.Text;
newReport.Contents = this.txtContents.Text;
newReport.Problems = this.txtProblems.Text;
//newReport.Recorder = this.txtRecorder.Text.Trim();
newReport.RecordDate = Funs.GetNewDateTime(this.txtRecordDate.Text.Trim());
//newReport.Reviewer=this.txtReviewer.Text.Trim();
newReport.ReviewDate = Funs.GetNewDateTime(this.txtReviewDate.Text.Trim());
if (!string.IsNullOrEmpty(this.ConDrawingVerificationId))
{
newReport.ConDrawingVerificationId = this.ConDrawingVerificationId;
BLL.ConDrawingVerificationService.UpdateConDrawingVerification(newReport);
ShowNotify("修改成功!", MessageBoxIcon.Success);
}
else
{
newReport.ProjectId = this.tvControlItem.SelectedNodeID;
newReport.CompileMan = this.CurrUser.UserId;
newReport.CompileDate = DateTime.Now;
newReport.ConDrawingVerificationId = SQLHelper.GetNewID(typeof(Model.JGZL_ConDrawingVerification));
this.ConDrawingVerificationId = newReport.ConDrawingVerificationId;
BLL.ConDrawingVerificationService.AddConDrawingVerification(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_ConDrawingVerificationUrl;
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 designUnit = doc.Range.Bookmarks["DesignUnit"];
if (designUnit != null)
{
designUnit.Text = this.txtDesignUnit.Text;
}
Bookmark professional = doc.Range.Bookmarks["Professional"];
if (professional != null)
{
professional.Text = this.txtProfessional.Text;
}
Bookmark verificationDate = doc.Range.Bookmarks["VerificationDate"];
if (verificationDate != null)
{
verificationDate.Text = string.Format("{0:yyyy年MM月dd日}", Funs.GetNewDateTime(this.txtVerificationDate.Text));
}
Bookmark conDrawingCode = doc.Range.Bookmarks["ConDrawingCode"];
if (conDrawingCode != null)
{
conDrawingCode.Text = this.txtConDrawingCode.Text;
}
Bookmark contents = doc.Range.Bookmarks["Contents"];
if (contents != null)
{
contents.Text = this.txtContents.Text;
}
Bookmark problems = doc.Range.Bookmarks["Problems"];
if (problems != null)
{
problems.Text = this.txtProblems.Text;
}
Bookmark recordDate = doc.Range.Bookmarks["RecordDate"];
if (recordDate != null)
{
recordDate.Text = string.Format("{0:yyyy年MM月dd日}", Funs.GetNewDateTime(this.txtRecordDate.Text));
}
Bookmark reviewDate = doc.Range.Bookmarks["ReviewDate"];
if (reviewDate != null)
{
reviewDate.Text = string.Format("{0:yyyy年MM月dd日}", Funs.GetNewDateTime(this.txtReviewDate.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
}
}