HJGL_DS/HJGL_DS/FineUIPro.Web/JGZL/DocumentDescription.aspx.cs

244 lines
10 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 static System.Windows.Forms.VisualStyles.VisualStyleElement;
using System.IO;
namespace FineUIPro.Web.JGZL
{
public partial class DocumentDescription : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
private string DocumentDescriptionId
{
get
{
return (string)ViewState["DocumentDescriptionId"];
}
set
{
ViewState["DocumentDescriptionId"] = 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();
}
}
#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")
{
this.PageData();
}
}
#endregion
#region
///<summary>
///查询
///</summary>
///<param name="sender"></param>
///<param name="e"></param>
protected void drpProjectId_SelectedIndexChanged(object sender, EventArgs e)
{
this.InitTreeMenu();
}
#endregion
private void PageData()
{
string projectId = this.tvControlItem.SelectedNodeID;
if (!string.IsNullOrEmpty(projectId))
{
var report = BLL.DocumentDescriptionService.GetDocumentDescriptionByProjectId(projectId);
if (report != null)
{
this.DocumentDescriptionId = report.DocumentDescriptionId;
this.txtProjectOverview.Text = report.ProjectOverview;
this.txtConstructionUnit.Text = report.ConstructionUnit;
this.txtDesigningUnit.Text = report.DesigningUnit;
this.txtTestingUnit.Text = report.TestingUnit;
this.txtConstructionCompany.Text = report.ConstructionCompany;
}
else
{
//var project = BLL.Base_ProjectService.GetProjectByProjectId(projectId);
//var isoLists = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByProjectId(projectId);
//string isoInfos = string.Empty;
//foreach (var item in isoLists)
//{
// int hdCount = 0;
// int gdCount = 0;
// var joitInfos = (from x in Funs.DB.HJGL_PW_JointInfo where x.ISO_ID == item.ISO_ID select x);
// if (joitInfos.Count() > 0)
// {
// hdCount = joitInfos.Where(x => x.JOT_JointAttribute == "活动").Count();
// gdCount = joitInfos.Where(x => x.JOT_JointAttribute == "固定").Count();
// }
// isoInfos += "管线编号" + item.ISO_IsoNo + ",其中活动焊口" + hdCount + "道,固定焊口" + gdCount + "道;";
//}
//if (!string.IsNullOrEmpty(isoInfos))
//{
// isoInfos = isoInfos.Substring(0, isoInfos.LastIndexOf(''));
//}
//this.txtProjectOverview.Text = "本文件为" + project.ProjectName + "" + string.Format("{0:yyyy年MM月dd日}", project.StartDate) + "开工,到" + string.Format("{0:yyyy年MM月dd日}", project.EndDate) + "施工结束,主要施工内容:" + isoInfos;
this.txtConstructionUnit.Text = "浙江石油化工有限公司";
this.txtConstructionCompany.Text = "浙江鼎盛石化工程有限公司";
}
}
}
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.JGZL_DocumentDescriptionMenuId, BLL.Const.BtnSave))
{
Model.JGZL_DocumentDescription newDocumentDescription = new Model.JGZL_DocumentDescription();
newDocumentDescription.ProjectOverview = this.txtProjectOverview.Text;
newDocumentDescription.ConstructionUnit = this.txtConstructionUnit.Text;
newDocumentDescription.DesigningUnit = this.txtDesigningUnit.Text;
newDocumentDescription.TestingUnit = this.txtTestingUnit.Text;
newDocumentDescription.ConstructionCompany = this.txtConstructionCompany.Text;
if (!string.IsNullOrEmpty(this.DocumentDescriptionId))
{
newDocumentDescription.DocumentDescriptionId = this.DocumentDescriptionId;
BLL.DocumentDescriptionService.UpdateDocumentDescription(newDocumentDescription);
ShowNotify("修改成功!", MessageBoxIcon.Success);
}
else
{
newDocumentDescription.CompileMan = this.CurrUser.UserId;
newDocumentDescription.CompileDate = DateTime.Now;
newDocumentDescription.Reviewer = this.CurrUser.UserId;
newDocumentDescription.ReviewDate = DateTime.Now;
newDocumentDescription.ProjectId = this.tvControlItem.SelectedNodeID;
newDocumentDescription.DocumentDescriptionId = SQLHelper.GetNewID(typeof(Model.JGZL_DocumentDescription));
this.DocumentDescriptionId = newDocumentDescription.DocumentDescriptionId;
BLL.DocumentDescriptionService.AddDocumentDescription(newDocumentDescription);
ShowNotify("保存成功!", MessageBoxIcon.Success);
}
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#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();
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
keyValuePairs.Add("ProjectName", BLL.Base_ProjectService.GetProjectByProjectId(projectId).ProjectName);
keyValuePairs.Add("ProjectOverview", this.txtProjectOverview.Text);
keyValuePairs.Add("ConstructionUnit", this.txtConstructionUnit.Text);
keyValuePairs.Add("DesigningUnit", this.txtDesigningUnit.Text);
keyValuePairs.Add("TestingUnit", this.txtTestingUnit.Text);
keyValuePairs.Add("ConstructionCompany", this.txtConstructionCompany.Text);
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;
}
}
#endregion
}
}