373 lines
20 KiB
C#
373 lines
20 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.ProjectData
|
|
{
|
|
public partial class UnitWorkEdit : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 项目id
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
|
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
BLL.UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpUnit, this.CurrUser.LoginProjectId, Const.ProjectUnitType_2, true);//施工
|
|
BLL.UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpSupervisorUnit, this.CurrUser.LoginProjectId, Const.ProjectUnitType_3, true);//监理
|
|
BLL.UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpNDEUnit, this.CurrUser.LoginProjectId, Const.ProjectUnitType_5, true);//检测
|
|
string UnitWorkId = Request.Params["UnitWorkId"];
|
|
if (!string.IsNullOrEmpty(UnitWorkId))
|
|
{
|
|
|
|
Model.WBS_UnitWork UnitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(UnitWorkId);
|
|
if (UnitWork != null)
|
|
{
|
|
this.ProjectId = UnitWork.ProjectId;
|
|
this.txtUnitWorkCode.Text = UnitWork.UnitWorkCode;
|
|
this.txtUnitWorkName.Text = UnitWork.UnitWorkName;
|
|
if (UnitWork.Costs != null)
|
|
{
|
|
this.txtCosts.Text = UnitWork.Costs.ToString();
|
|
}
|
|
if (!string.IsNullOrEmpty(UnitWork.UnitId))
|
|
{
|
|
this.drpUnit.SelectedValue = UnitWork.UnitId;
|
|
}
|
|
if (!string.IsNullOrEmpty(UnitWork.SupervisorUnitId))
|
|
{
|
|
this.drpSupervisorUnit.SelectedValue = UnitWork.SupervisorUnitId;
|
|
}
|
|
if (!string.IsNullOrEmpty(UnitWork.NDEUnit))
|
|
{
|
|
this.drpNDEUnit.SelectedValue = UnitWork.NDEUnit;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
SaveData(true);
|
|
}
|
|
|
|
private void SaveData(bool bl)
|
|
{
|
|
//if (this.drpProjectType.SelectedValue == BLL.Const._Null)
|
|
//{
|
|
// Alert.ShowInTop("所属工程不能为空!", MessageBoxIcon.Warning);
|
|
// return;
|
|
//}
|
|
string UnitWorkId = Request.Params["UnitWorkId"];
|
|
Model.WBS_UnitWork UnitWork = new Model.WBS_UnitWork();
|
|
UnitWork.ProjectId = this.CurrUser.LoginProjectId;
|
|
UnitWork.UnitWorkCode = this.txtUnitWorkCode.Text.Trim();
|
|
UnitWork.UnitWorkName = this.txtUnitWorkName.Text.Trim();
|
|
//if (this.drpUnit.SelectedValue != BLL.Const._Null)
|
|
//{
|
|
// UnitWork.UnitId = this.drpUnit.SelectedValue;
|
|
//}
|
|
//else
|
|
//{
|
|
// Alert.ShowInTop("请选择施工单位!");
|
|
// return;
|
|
//}
|
|
if (this.drpSupervisorUnit.SelectedValue != BLL.Const._Null)
|
|
{
|
|
UnitWork.SupervisorUnitId = this.drpSupervisorUnit.SelectedValue;
|
|
}
|
|
if (this.drpNDEUnit.SelectedValue != BLL.Const._Null)
|
|
{
|
|
UnitWork.NDEUnit = this.drpNDEUnit.SelectedValue;
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtCosts.Text.Trim()))
|
|
{
|
|
UnitWork.Costs = Convert.ToDecimal(this.txtCosts.Text.Trim());
|
|
}
|
|
if (!string.IsNullOrEmpty(UnitWorkId))
|
|
{
|
|
UnitWork.UnitWorkId = UnitWorkId;
|
|
BLL.UnitWorkService.UpdateUnitWork(UnitWork);
|
|
var divisionProject = Funs.DB.WBS_DivisionProject.FirstOrDefault(x => x.UnitWorkId == UnitWork.UnitWorkId);
|
|
if (divisionProject == null)
|
|
{
|
|
#region 拷贝WBS内容
|
|
//拷贝分部及子分部
|
|
var divisions1 = from x in Funs.DB.WBS_Division where x.SuperDivisionId == null select x;
|
|
foreach (var d1 in divisions1)
|
|
{
|
|
Model.WBS_DivisionProject newDivisionProject = new Model.WBS_DivisionProject();
|
|
newDivisionProject.DivisionProjectId = SQLHelper.GetNewID(typeof(Model.WBS_DivisionProject));
|
|
newDivisionProject.ProjectId = this.CurrUser.LoginProjectId;
|
|
newDivisionProject.DivisionCode = d1.DivisionCode;
|
|
newDivisionProject.DivisionName = d1.DivisionName;
|
|
newDivisionProject.SortIndex = d1.SortIndex;
|
|
newDivisionProject.SuperDivisionId = d1.SuperDivisionId;
|
|
newDivisionProject.CNProfessionalId = d1.CNProfessionalId;
|
|
newDivisionProject.UnitWorkId = UnitWork.UnitWorkId;
|
|
newDivisionProject.OldDivisionId = d1.DivisionId;
|
|
newDivisionProject.SubItemType = d1.SubItemType;
|
|
BLL.DivisionProjectService.AddDivisionProject(newDivisionProject); //分部
|
|
List<Model.WBS_Division> divisions2 = (from x in Funs.DB.WBS_Division where x.SuperDivisionId == d1.DivisionId select x).ToList();
|
|
if (divisions2.Count() > 0)
|
|
{
|
|
this.InsertDivisionDetail(divisions2, newDivisionProject.DivisionProjectId, UnitWork.UnitWorkId);
|
|
}
|
|
}
|
|
//拷贝分项
|
|
var breakdowns = from x in Funs.DB.WBS_Breakdown select x;
|
|
foreach (var b in breakdowns)
|
|
{
|
|
Model.WBS_BreakdownProject bp = new Model.WBS_BreakdownProject();
|
|
bp.BreakdownProjectId = SQLHelper.GetNewID(typeof(Model.WBS_BreakdownProject));
|
|
bp.ProjectId = this.CurrUser.LoginProjectId;
|
|
bp.BreakdownCode = b.BreakdownCode;
|
|
bp.BreakdownName = b.BreakdownName;
|
|
bp.DivisionProjectId = (from x in Funs.DB.WBS_DivisionProject where x.OldDivisionId == b.DivisionId && x.UnitWorkId == UnitWork.UnitWorkId select x.DivisionProjectId).FirstOrDefault();
|
|
bp.Basis = b.Basis;
|
|
bp.CheckPoints = b.CheckPoints;
|
|
bp.RecordAndCode = b.RecordAndCode;
|
|
bp.Class = b.Class;
|
|
bp.SortIndex = b.SortIndex;
|
|
bp.Remark = b.Remark;
|
|
bp.ModelURL = b.ModelURL;
|
|
bp.UnitWorkId = UnitWork.UnitWorkId;
|
|
bp.IsAcceptance = b.IsAcceptance;
|
|
bp.IsYellow = b.IsYellow;
|
|
bp.WuHuan = b.WuHuan;
|
|
bp.JianLi = b.JianLi;
|
|
bp.FenBao = b.FenBao;
|
|
bp.YeZhu = b.YeZhu;
|
|
bp.SourceBreakdownId = b.BreakdownId;
|
|
bp.CheckAcceptType = b.CheckAcceptType;
|
|
|
|
BLL.BreakdownProjectService.AddBreakdownProject(bp);
|
|
}
|
|
#endregion
|
|
}
|
|
else
|
|
{
|
|
#region 拷贝建筑工程WBS内容
|
|
//拷贝分部及子分部
|
|
var divisions1 = from x in Funs.DB.WBS_Division where x.SuperDivisionId == null && x.CNProfessionalId == BLL.Const.CNProfessionalConstructId select x;
|
|
foreach (var d1 in divisions1)
|
|
{
|
|
Model.WBS_DivisionProject newDivisionProject = new Model.WBS_DivisionProject();
|
|
newDivisionProject.DivisionProjectId = SQLHelper.GetNewID(typeof(Model.WBS_DivisionProject));
|
|
newDivisionProject.ProjectId = this.CurrUser.LoginProjectId;
|
|
newDivisionProject.DivisionCode = d1.DivisionCode;
|
|
newDivisionProject.DivisionName = d1.DivisionName;
|
|
newDivisionProject.SortIndex = d1.SortIndex;
|
|
newDivisionProject.SuperDivisionId = d1.SuperDivisionId;
|
|
newDivisionProject.CNProfessionalId = d1.CNProfessionalId;
|
|
newDivisionProject.UnitWorkId = UnitWork.UnitWorkId;
|
|
newDivisionProject.OldDivisionId = d1.DivisionId;
|
|
BLL.DivisionProjectService.AddDivisionProject(newDivisionProject); //分部
|
|
List<Model.WBS_Division> divisions2 = (from x in Funs.DB.WBS_Division where x.SuperDivisionId == d1.DivisionId select x).ToList();
|
|
if (divisions2.Count() > 0)
|
|
{
|
|
this.InsertDivisionDetail(divisions2, newDivisionProject.DivisionProjectId, UnitWork.UnitWorkId);
|
|
}
|
|
}
|
|
//拷贝分项
|
|
var breakdowns = from x in Funs.DB.WBS_Breakdown
|
|
join y in Funs.DB.WBS_Division on x.DivisionId equals y.DivisionId
|
|
where y.CNProfessionalId == BLL.Const.CNProfessionalConstructId
|
|
select x;
|
|
foreach (var b in breakdowns)
|
|
{
|
|
Model.WBS_BreakdownProject bp = new Model.WBS_BreakdownProject();
|
|
bp.BreakdownProjectId = SQLHelper.GetNewID(typeof(Model.WBS_BreakdownProject));
|
|
bp.ProjectId = this.CurrUser.LoginProjectId;
|
|
bp.BreakdownCode = b.BreakdownCode;
|
|
bp.BreakdownName = b.BreakdownName;
|
|
bp.DivisionProjectId = (from x in Funs.DB.WBS_DivisionProject where x.OldDivisionId == b.DivisionId && x.UnitWorkId == UnitWork.UnitWorkId select x.DivisionProjectId).FirstOrDefault();
|
|
bp.Basis = b.Basis;
|
|
bp.CheckPoints = b.CheckPoints;
|
|
bp.RecordAndCode = b.RecordAndCode;
|
|
bp.Class = b.Class;
|
|
bp.SortIndex = b.SortIndex;
|
|
bp.Remark = b.Remark;
|
|
bp.ModelURL = b.ModelURL;
|
|
bp.UnitWorkId = UnitWork.UnitWorkId;
|
|
bp.IsAcceptance = b.IsAcceptance;
|
|
bp.IsYellow = b.IsYellow;
|
|
bp.WuHuan = b.WuHuan;
|
|
bp.JianLi = b.JianLi;
|
|
bp.FenBao = b.FenBao;
|
|
bp.YeZhu = b.YeZhu;
|
|
bp.SourceBreakdownId = b.BreakdownId;
|
|
|
|
BLL.BreakdownProjectService.AddBreakdownProject(bp);
|
|
}
|
|
#endregion
|
|
}
|
|
Model.DataBase_DataTypeProject dp = Funs.DB.DataBase_DataTypeProject.FirstOrDefault(x=>x.UnitWorkId== UnitWorkId);
|
|
if (dp == null)
|
|
{
|
|
#region 拷贝资料库内容
|
|
Model.DataBase_DataTypeProject dataTypeProject = BLL.DataTypeProjectService.GetDataTypeProjectBySourceDataTypeId(Const.DataTypeNewConstructId, this.CurrUser.LoginProjectId);
|
|
List<Model.DataBase_DataType> childDataTypes = BLL.DataTypeService.GetDataTypesBySuperDataTypeId(Const.DataTypeNewConstructId);
|
|
if (childDataTypes.Count > 0)
|
|
{
|
|
if (dataTypeProject != null)
|
|
{
|
|
InsertDataTypeDetail(childDataTypes, dataTypeProject.DataTypeProjectId, this.CurrUser.LoginProjectId, UnitWork.UnitWorkId);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
else
|
|
{
|
|
UnitWork.UnitWorkId = SQLHelper.GetNewID(typeof(Model.WBS_UnitWork));
|
|
BLL.UnitWorkService.AddUnitWork(UnitWork);
|
|
#region 拷贝WBS内容
|
|
//拷贝分部及子分部
|
|
var divisions1 = from x in Funs.DB.WBS_Division where x.SuperDivisionId == null select x;
|
|
foreach (var d1 in divisions1)
|
|
{
|
|
Model.WBS_DivisionProject newDivisionProject = new Model.WBS_DivisionProject();
|
|
newDivisionProject.DivisionProjectId = SQLHelper.GetNewID(typeof(Model.WBS_DivisionProject));
|
|
newDivisionProject.ProjectId = this.CurrUser.LoginProjectId;
|
|
newDivisionProject.DivisionCode = d1.DivisionCode;
|
|
newDivisionProject.DivisionName = d1.DivisionName;
|
|
newDivisionProject.SortIndex = d1.SortIndex;
|
|
newDivisionProject.SuperDivisionId = d1.SuperDivisionId;
|
|
newDivisionProject.CNProfessionalId = d1.CNProfessionalId;
|
|
newDivisionProject.UnitWorkId = UnitWork.UnitWorkId;
|
|
newDivisionProject.OldDivisionId = d1.DivisionId;
|
|
BLL.DivisionProjectService.AddDivisionProject(newDivisionProject); //分部
|
|
List<Model.WBS_Division> divisions2 = (from x in Funs.DB.WBS_Division where x.SuperDivisionId == d1.DivisionId select x).ToList();
|
|
if (divisions2.Count() > 0)
|
|
{
|
|
this.InsertDivisionDetail(divisions2, newDivisionProject.DivisionProjectId, UnitWork.UnitWorkId);
|
|
}
|
|
}
|
|
//拷贝分项
|
|
var breakdowns = from x in Funs.DB.WBS_Breakdown select x;
|
|
foreach (var b in breakdowns)
|
|
{
|
|
Model.WBS_BreakdownProject bp = new Model.WBS_BreakdownProject();
|
|
bp.BreakdownProjectId = SQLHelper.GetNewID(typeof(Model.WBS_BreakdownProject));
|
|
bp.ProjectId = this.CurrUser.LoginProjectId;
|
|
bp.BreakdownCode = b.BreakdownCode;
|
|
bp.BreakdownName = b.BreakdownName;
|
|
bp.DivisionProjectId = (from x in Funs.DB.WBS_DivisionProject where x.OldDivisionId == b.DivisionId && x.UnitWorkId == UnitWork.UnitWorkId select x.DivisionProjectId).FirstOrDefault();
|
|
bp.Basis = b.Basis;
|
|
bp.CheckPoints = b.CheckPoints;
|
|
bp.RecordAndCode = b.RecordAndCode;
|
|
bp.Class = b.Class;
|
|
bp.SortIndex = b.SortIndex;
|
|
bp.Remark = b.Remark;
|
|
bp.ModelURL = b.ModelURL;
|
|
bp.UnitWorkId = UnitWork.UnitWorkId;
|
|
bp.IsAcceptance = b.IsAcceptance;
|
|
bp.IsYellow = b.IsYellow;
|
|
bp.WuHuan = b.WuHuan;
|
|
bp.JianLi = b.JianLi;
|
|
bp.FenBao = b.FenBao;
|
|
bp.YeZhu = b.YeZhu;
|
|
bp.SourceBreakdownId = b.BreakdownId;
|
|
|
|
BLL.BreakdownProjectService.AddBreakdownProject(bp);
|
|
}
|
|
#endregion
|
|
#region 拷贝资料库内容
|
|
Model.DataBase_DataTypeProject dataTypeProject = BLL.DataTypeProjectService.GetDataTypeProjectBySourceDataTypeId(Const.DataTypeNewConstructId, this.CurrUser.LoginProjectId);
|
|
List<Model.DataBase_DataType> childDataTypes = BLL.DataTypeService.GetDataTypesBySuperDataTypeId(Const.DataTypeNewConstructId);
|
|
if (childDataTypes.Count > 0)
|
|
{
|
|
if (dataTypeProject != null)
|
|
{
|
|
InsertDataTypeDetail(childDataTypes, dataTypeProject.DataTypeProjectId, this.CurrUser.LoginProjectId, UnitWork.UnitWorkId);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 循环拷贝子级分部
|
|
/// </summary>
|
|
/// <param name="dataTypes"></param>
|
|
private void InsertDivisionDetail(List<Model.WBS_Division> divisions, string superDivisionId, string unitWorkId)
|
|
{
|
|
foreach (var d in divisions)
|
|
{
|
|
Model.WBS_DivisionProject newDivisionProject = new Model.WBS_DivisionProject();
|
|
newDivisionProject.DivisionProjectId = SQLHelper.GetNewID(typeof(Model.WBS_DivisionProject));
|
|
newDivisionProject.ProjectId = this.CurrUser.LoginProjectId;
|
|
newDivisionProject.DivisionCode = d.DivisionCode;
|
|
newDivisionProject.DivisionName = d.DivisionName;
|
|
newDivisionProject.SortIndex = d.SortIndex;
|
|
newDivisionProject.SuperDivisionId = superDivisionId;
|
|
newDivisionProject.CNProfessionalId = d.CNProfessionalId;
|
|
newDivisionProject.UnitWorkId = unitWorkId;
|
|
newDivisionProject.OldDivisionId = d.DivisionId;
|
|
newDivisionProject.SubItemType = d.SubItemType;
|
|
BLL.DivisionProjectService.AddDivisionProject(newDivisionProject); //子级分部
|
|
List<Model.WBS_Division> divisions2 = (from x in Funs.DB.WBS_Division where x.SuperDivisionId == d.DivisionId select x).ToList();
|
|
if (divisions2.Count() > 0)
|
|
{
|
|
this.InsertDivisionDetail(divisions2, newDivisionProject.DivisionProjectId, unitWorkId);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 循环拷贝子级类别
|
|
/// </summary>
|
|
/// <param name="dataTypes"></param>
|
|
private void InsertDataTypeDetail(List<Model.DataBase_DataType> dataTypes, string superDataTypeId, string projectId, string unitWorkId)
|
|
{
|
|
foreach (var d in dataTypes)
|
|
{
|
|
|
|
Model.DataBase_DataTypeProject newDataTypeProject = new Model.DataBase_DataTypeProject();
|
|
newDataTypeProject.DataTypeProjectId = SQLHelper.GetNewID(typeof(Model.DataBase_DataTypeProject));
|
|
newDataTypeProject.ProjectId = projectId;
|
|
newDataTypeProject.DataTypeCode = d.DataTypeCode;
|
|
newDataTypeProject.DataTypeName = d.DataTypeName;
|
|
newDataTypeProject.SuperDataTypeId = superDataTypeId;
|
|
newDataTypeProject.SortIndex = d.SortIndex;
|
|
newDataTypeProject.Pages = d.Pages;
|
|
newDataTypeProject.Remark = d.Remark;
|
|
newDataTypeProject.IsRelatedWBS = d.IsRelatedWBS;
|
|
newDataTypeProject.SourceDataTypeId = d.DataTypeId;
|
|
|
|
newDataTypeProject.UnitWorkId = unitWorkId;
|
|
|
|
BLL.DataTypeProjectService.AddDataTypeProject(newDataTypeProject);
|
|
|
|
List<Model.DataBase_DataType> childDataTypes = BLL.DataTypeService.GetDataTypesBySuperDataTypeId(d.DataTypeId);
|
|
if (childDataTypes.Count > 0)
|
|
{
|
|
InsertDataTypeDetail(childDataTypes, newDataTypeProject.DataTypeProjectId, projectId, unitWorkId);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
} |