2023-08-31
This commit is contained in:
@@ -0,0 +1,514 @@
|
||||
using BLL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace FineUIPro.Web.PHTGL.ContractCompile
|
||||
{
|
||||
public partial class ContractTrackMatchWBS : PageBase
|
||||
{
|
||||
public string ContractTrackId
|
||||
{
|
||||
get { return (string)ViewState["ContractTrackId"]; }
|
||||
set { ViewState["ContractTrackId"] = value; }
|
||||
}
|
||||
|
||||
#region 页面加载
|
||||
/// <summary>
|
||||
/// 页面加载
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
ContractTrackId = Request.Params["ContractTrackId"];
|
||||
|
||||
InitTreeMenu();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 加载树
|
||||
/// <summary>
|
||||
/// 加载树
|
||||
/// </summary>
|
||||
private void InitTreeMenu()
|
||||
{
|
||||
this.trWBS.Nodes.Clear();
|
||||
this.trWBS.ShowBorder = false;
|
||||
this.trWBS.ShowHeader = false;
|
||||
this.trWBS.EnableIcons = true;
|
||||
this.trWBS.AutoScroll = true;
|
||||
this.trWBS.EnableSingleClickExpand = true;
|
||||
|
||||
TreeNode rootNode1 = new TreeNode();
|
||||
rootNode1.Text = "建筑工程";
|
||||
rootNode1.NodeID = "1";
|
||||
rootNode1.CommandName = "ProjectType";
|
||||
rootNode1.EnableExpandEvent = true;
|
||||
rootNode1.EnableClickEvent = true;
|
||||
this.trWBS.Nodes.Add(rootNode1);
|
||||
TreeNode emptyNode = new TreeNode();
|
||||
emptyNode.Text = "";
|
||||
emptyNode.NodeID = "";
|
||||
rootNode1.Nodes.Add(emptyNode);
|
||||
//this.GetNodes(rootNode1.Nodes, rootNode1.NodeID);
|
||||
|
||||
TreeNode rootNode2 = new TreeNode();
|
||||
rootNode2.Text = "安装工程";
|
||||
rootNode2.NodeID = "2";
|
||||
rootNode2.CommandName = "ProjectType";
|
||||
rootNode2.EnableExpandEvent = true;
|
||||
rootNode2.EnableClickEvent = true;
|
||||
this.trWBS.Nodes.Add(rootNode2);
|
||||
rootNode2.Nodes.Add(emptyNode);
|
||||
//this.GetNodes(rootNode2.Nodes, rootNode2.NodeID);
|
||||
}
|
||||
|
||||
#region 遍历节点方法
|
||||
/// <summary>
|
||||
/// 遍历节点方法
|
||||
/// </summary>
|
||||
/// <param name="nodes">节点集合</param>
|
||||
/// <param name="parentId">父节点</param>
|
||||
private void GetNodes(TreeNodeCollection nodes, string parentId)
|
||||
{
|
||||
List<Model.WBS_WorkPackageProject> workPackages = new List<Model.WBS_WorkPackageProject>();
|
||||
if (parentId.Length == 1) //工程类型节点
|
||||
{
|
||||
workPackages = (from x in Funs.DB.WBS_WorkPackageProject
|
||||
where x.SuperWorkPack == null && x.ProjectId == this.CurrUser.LoginProjectId && x.ProjectType == parentId
|
||||
orderby x.PackageCode ascending
|
||||
select x).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
workPackages = (from x in Funs.DB.WBS_WorkPackageProject
|
||||
where x.SuperWorkPack == parentId && x.ProjectId == this.CurrUser.LoginProjectId
|
||||
orderby x.PackageCode ascending
|
||||
select x).ToList();
|
||||
}
|
||||
foreach (var q in workPackages)
|
||||
{
|
||||
TreeNode newNode = new TreeNode();
|
||||
newNode.Text = q.PackageContent;
|
||||
newNode.NodeID = q.WorkPackageCode;
|
||||
newNode.CommandName = "WorkPackage";
|
||||
newNode.EnableClickEvent = true;
|
||||
nodes.Add(newNode);
|
||||
}
|
||||
|
||||
for (int i = 0; i < nodes.Count; i++)
|
||||
{
|
||||
GetNodes(nodes[i].Nodes, nodes[i].NodeID);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region 展开树
|
||||
/// <summary>
|
||||
/// 展开树
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void trWBS_NodeExpand(object sender, TreeNodeEventArgs e)
|
||||
{
|
||||
e.Node.Nodes.Clear();
|
||||
if (e.Node.CommandName == "ProjectType") //展开工程类型
|
||||
{
|
||||
var trUnitWork = from x in Funs.DB.WBS_UnitWork
|
||||
where x.ProjectId == this.CurrUser.LoginProjectId && x.SuperUnitWork == null && x.ProjectType == e.Node.NodeID
|
||||
select x;
|
||||
trUnitWork = trUnitWork.OrderBy(x => x.UnitWorkCode);
|
||||
if (trUnitWork.Count() > 0)
|
||||
{
|
||||
foreach (var trUnitWorkItem in trUnitWork)
|
||||
{
|
||||
TreeNode newNode = new TreeNode();
|
||||
newNode.Text = trUnitWorkItem.UnitWorkCode + "-" + trUnitWorkItem.UnitWorkName;
|
||||
newNode.NodeID = trUnitWorkItem.UnitWorkId;
|
||||
newNode.CommandName = "UnitWork";
|
||||
newNode.EnableExpandEvent = true;
|
||||
newNode.EnableClickEvent = true;
|
||||
e.Node.Nodes.Add(newNode);
|
||||
if (BLL.WorkPackageService.GetWorkPackages1ByUnitWorkId(trUnitWorkItem.UnitWorkId.ToString()) != null)
|
||||
{
|
||||
TreeNode temp = new TreeNode();
|
||||
temp.Text = "temp";
|
||||
temp.NodeID = "temp";
|
||||
newNode.Nodes.Add(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.Node.CommandName == "UnitWork") //展开单位工程节点
|
||||
{
|
||||
var workPackages = from x in Funs.DB.WBS_WorkPackage where x.UnitWorkId == e.NodeID && x.SuperWorkPack == null && x.IsApprove == true orderby x.WorkPackageCode select x;
|
||||
foreach (var workPackage in workPackages)
|
||||
{
|
||||
TreeNode newNode = new TreeNode();
|
||||
newNode.Text = workPackage.PackageContent;
|
||||
newNode.NodeID = workPackage.WorkPackageId;
|
||||
newNode.CommandName = "WorkPackage";
|
||||
newNode.EnableExpandEvent = true;
|
||||
newNode.EnableClickEvent = true;
|
||||
e.Node.Nodes.Add(newNode);
|
||||
var childWorkPackages = from x in Funs.DB.WBS_WorkPackage where x.SuperWorkPackageId == workPackage.WorkPackageId && x.IsApprove == true select x;
|
||||
if (childWorkPackages.Count() > 0)
|
||||
{
|
||||
TreeNode emptyNode = new TreeNode();
|
||||
emptyNode.Text = "";
|
||||
emptyNode.NodeID = "";
|
||||
newNode.Nodes.Add(emptyNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.Node.CommandName == "WorkPackage") //展开工作包节点
|
||||
{
|
||||
var workPackages = from x in Funs.DB.WBS_WorkPackage where x.SuperWorkPackageId == e.Node.NodeID && x.IsApprove == true orderby x.WorkPackageCode select x;
|
||||
if (workPackages.Count() > 0) //存在子单位工程
|
||||
{
|
||||
foreach (var workPackage in workPackages)
|
||||
{
|
||||
TreeNode newNode = new TreeNode();
|
||||
newNode.Text = workPackage.PackageContent;
|
||||
newNode.NodeID = workPackage.WorkPackageId;
|
||||
newNode.CommandName = "WorkPackage";
|
||||
newNode.EnableExpandEvent = true;
|
||||
newNode.EnableClickEvent = true;
|
||||
e.Node.Nodes.Add(newNode);
|
||||
var childWorkPackages = from x in Funs.DB.WBS_WorkPackage where x.SuperWorkPackageId == workPackage.WorkPackageId && x.IsApprove == true select x;
|
||||
if (childWorkPackages.Count() > 0)
|
||||
{
|
||||
TreeNode emptyNode = new TreeNode();
|
||||
emptyNode.Text = "";
|
||||
emptyNode.NodeID = "";
|
||||
newNode.Nodes.Add(emptyNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 发起设计交底(树节点)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnMenuAddTechnicalDisclose_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.trWBS.SelectedNode != null)
|
||||
{
|
||||
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.CQMSTechnicalDiscloseMenuId, BLL.Const.BtnAdd))
|
||||
{
|
||||
if (this.trWBS.SelectedNode.CommandName == "WorkPackage")
|
||||
{
|
||||
var childWorkPackages = from x in Funs.DB.WBS_WorkPackage where x.SuperWorkPackageId == this.trWBS.SelectedNodeID && x.IsApprove == true select x;
|
||||
if (childWorkPackages.Count() == 0) //末级节点
|
||||
{
|
||||
var oldTechnicalDisclose = BLL.CQMS_TechnicalDiscloseService.GetTechnicalDiscloseByDataId(this.trWBS.SelectedNodeID);
|
||||
if (oldTechnicalDisclose == null)
|
||||
{
|
||||
var unitWork = (from x in Funs.DB.WBS_UnitWork
|
||||
join y in Funs.DB.WBS_WorkPackage on x.UnitWorkId equals y.UnitWorkId
|
||||
where y.WorkPackageId == this.trWBS.SelectedNodeID
|
||||
select x).FirstOrDefault();
|
||||
Model.Technical_TechnicalDisclose technicalDisclose = new Model.Technical_TechnicalDisclose();
|
||||
technicalDisclose.TechnicalDiscloseId = SQLHelper.GetNewID();
|
||||
technicalDisclose.ProjectId = this.CurrUser.LoginProjectId;
|
||||
if (unitWork != null)
|
||||
{
|
||||
technicalDisclose.UnitId = unitWork.UnitId;
|
||||
technicalDisclose.UnitWorkId = unitWork.UnitWorkId;
|
||||
}
|
||||
technicalDisclose.DataId = this.trWBS.SelectedNodeID;
|
||||
technicalDisclose.DiscloseName = this.trWBS.SelectedNode.Text;
|
||||
technicalDisclose.State = "0"; //未交底
|
||||
technicalDisclose.CompileMan = this.CurrUser.PersonId;
|
||||
technicalDisclose.CompileDate = DateTime.Now;
|
||||
BLL.CQMS_TechnicalDiscloseService.AddTechnicalDisclose(technicalDisclose);
|
||||
ShowNotify("发起成功!", MessageBoxIcon.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("该节点已发起设计交底!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("请选择末级节点发起设计交底!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("请选择末级节点发起设计交底!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("请选择树节点!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 展开全部
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnMenuMore_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.trWBS.SelectedNode != null)
|
||||
{
|
||||
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.ControlItemAndCycleMenuId, BLL.Const.BtnAdd))
|
||||
{
|
||||
if (this.trWBS.SelectedNode.CommandName != "ProjectType") //非工程类型节点可以增加
|
||||
{
|
||||
Model.WBS_UnitWork unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(this.trWBS.SelectedNodeID);
|
||||
if (unitWork != null) //单位工程节点
|
||||
{
|
||||
this.trWBS.SelectedNode.Expanded = true;
|
||||
this.trWBS.SelectedNode.Nodes.Clear();
|
||||
var workPackages = from x in Funs.DB.WBS_WorkPackage where x.UnitWorkId == this.trWBS.SelectedNodeID && x.SuperWorkPack == null && x.IsApprove == true orderby x.WorkPackageCode select x;
|
||||
foreach (var workPackage in workPackages)
|
||||
{
|
||||
TreeNode newNode = new TreeNode();
|
||||
newNode.Text = workPackage.PackageContent;
|
||||
newNode.NodeID = workPackage.WorkPackageId;
|
||||
newNode.CommandName = "WorkPackage";
|
||||
newNode.EnableExpandEvent = true;
|
||||
newNode.EnableClickEvent = true;
|
||||
this.trWBS.SelectedNode.Nodes.Add(newNode);
|
||||
var childWorkPackages = from x in Funs.DB.WBS_WorkPackage where x.SuperWorkPackageId == workPackage.WorkPackageId && x.IsApprove == true select x;
|
||||
if (childWorkPackages.Count() > 0)
|
||||
{
|
||||
newNode.Expanded = true;
|
||||
ExpandWorkPackage(newNode.Nodes, newNode.NodeID);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.trWBS.SelectedNode.Expanded = true;
|
||||
this.trWBS.SelectedNode.Nodes.Clear();
|
||||
ExpandWorkPackage(this.trWBS.SelectedNode.Nodes, this.trWBS.SelectedNodeID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("请选择单位工程节点展开!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("请选择树节点!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 展开子级分部分项节点
|
||||
/// </summary>
|
||||
/// <param name="nodes"></param>
|
||||
/// <param name="parentId"></param>
|
||||
private void ExpandWorkPackage(TreeNodeCollection nodes, string parentId)
|
||||
{
|
||||
var workPackages = from x in Funs.DB.WBS_WorkPackage where x.SuperWorkPackageId == parentId && x.IsApprove == true orderby x.WorkPackageCode select x;
|
||||
if (workPackages.Count() > 0) //存在子单位工程
|
||||
{
|
||||
foreach (var workPackage in workPackages)
|
||||
{
|
||||
TreeNode newNode = new TreeNode();
|
||||
newNode.Text = workPackage.PackageContent;
|
||||
newNode.NodeID = workPackage.WorkPackageId;
|
||||
newNode.CommandName = "WorkPackage";
|
||||
newNode.EnableExpandEvent = true;
|
||||
newNode.EnableClickEvent = true;
|
||||
nodes.Add(newNode);
|
||||
var childWorkPackages = from x in Funs.DB.WBS_WorkPackage where x.SuperWorkPackageId == workPackage.WorkPackageId && x.IsApprove == true select x;
|
||||
if (childWorkPackages.Count() > 0)
|
||||
{
|
||||
newNode.Expanded = true;
|
||||
ExpandWorkPackage(newNode.Nodes, newNode.NodeID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Tree点击事件
|
||||
/// <summary>
|
||||
/// Tree点击事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void trWBS_NodeCommand(object sender, TreeCommandEventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 绑定数据
|
||||
/// <summary>
|
||||
/// 绑定数据
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_FilterChange(object sender, EventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||||
{
|
||||
Grid1.PageIndex = e.NewPageIndex;
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Grid1排序
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
||||
{
|
||||
Grid1.SortDirection = e.SortDirection;
|
||||
Grid1.SortField = e.SortField;
|
||||
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>
|
||||
/// 加载Grid
|
||||
/// </summary>
|
||||
private void BindGrid()
|
||||
{
|
||||
string strSql = @"SELECT ControlItemAndCycleId,ControlItemAndCycleCode,InitControlItemCode,ControlItemContent,ControlPoint,ControlItemDef,HGForms,SHForms,Standard,ClauseNo,CheckNum"
|
||||
+ @" FROM WBS_ControlItemAndCycle ";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
strSql += " where WorkPackageId = @WorkPackageId and IsApprove=1 ";
|
||||
listStr.Add(new SqlParameter("@WorkPackageId", this.trWBS.SelectedNodeID));
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
|
||||
Grid1.RecordCount = tb.Rows.Count;
|
||||
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
||||
var table = this.GetPagedDataTable(Grid1, tb);
|
||||
Grid1.DataSource = table;
|
||||
Grid1.DataBind();
|
||||
|
||||
Model.WBS_WorkPackage workPackage = BLL.WorkPackageService.GetWorkPackageByWorkPackageId(this.trWBS.SelectedNodeID);
|
||||
if (workPackage != null)
|
||||
{
|
||||
if (workPackage.ProjectType == "1") //建筑工程
|
||||
{
|
||||
this.Grid1.Columns[4].HeaderText = "对应的建筑资料表格";
|
||||
this.Grid1.Columns[5].Hidden = true;
|
||||
}
|
||||
else //安装工程
|
||||
{
|
||||
this.Grid1.Columns[4].HeaderText = "对应的化工资料表格";
|
||||
this.Grid1.Columns[5].Hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
//<summary>
|
||||
//获取文本
|
||||
//</summary>
|
||||
//<param name="state"></param>
|
||||
//<returns></returns>
|
||||
public static string ConvertText(object Str)
|
||||
{
|
||||
string s = string.Empty;
|
||||
if (Str != null)
|
||||
{
|
||||
string[] strs = Str.ToString().Split(',');
|
||||
foreach (var item in strs)
|
||||
{
|
||||
s += item + "<br/>";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(s))
|
||||
{
|
||||
s = s.Substring(0, s.Length - 5);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
protected void btnAccept_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIDArray.Length>0)
|
||||
{
|
||||
var Ids=Grid1.SelectedRowIDArray;
|
||||
foreach (var item in Ids)
|
||||
{
|
||||
var querymodel = new Model.PHTGL_ContractTrackMatchWBS
|
||||
{
|
||||
ContractTrackId = ContractTrackId,
|
||||
ControlItemAndCycleId = item,
|
||||
};
|
||||
var queryResult =
|
||||
PhtglContracttrackmatchwbsService.GetPHTGL_ContractTrackMatchWBSByModle(querymodel);
|
||||
if (!queryResult.Any())
|
||||
{
|
||||
var newtable = new Model.PHTGL_ContractTrackMatchWBS
|
||||
{
|
||||
Id = SQLHelper.GetNewID(typeof(Model.PHTGL_ContractTrackMatchWBS)),
|
||||
ContractTrackId = ContractTrackId,
|
||||
ControlItemAndCycleId = item,
|
||||
|
||||
};
|
||||
BLL.PhtglContracttrackmatchwbsService.AddPHTGL_ContractTrackMatchWBS(newtable);
|
||||
}
|
||||
}
|
||||
ShowNotify("添加成功", MessageBoxIcon.Success);
|
||||
BindGrid();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("请选择需要添加的数据",MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
protected void Grid1_OnRowDataBound(object sender, GridRowEventArgs e)
|
||||
{
|
||||
var querymodel = new Model.PHTGL_ContractTrackMatchWBS
|
||||
{
|
||||
ContractTrackId = ContractTrackId,
|
||||
ControlItemAndCycleId = e.RowID,
|
||||
};
|
||||
var queryResult =
|
||||
PhtglContracttrackmatchwbsService.GetPHTGL_ContractTrackMatchWBSByModle(querymodel);
|
||||
if (queryResult.Any())
|
||||
{
|
||||
e.RowCssClass = "color3";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user