0915-gaofei
This commit is contained in:
@@ -268,7 +268,11 @@ namespace FineUIPro.Web.ProjectData
|
||||
this.InsertDataTypeToProject(project.ProjectId);////初始化资料类别数据
|
||||
this.InsertConstructionStandardListToProject(project.ProjectId); ////初始化项目标准规范清单
|
||||
this.InsertITPListProject(project.ProjectId); // 初始化ITP列表
|
||||
this.InsertZT(project); //初始化总图
|
||||
this.InsertAC(project); //初始化防腐绝热
|
||||
this.InsertGE(project); //初始化地勘
|
||||
this.InsertUP(project); //初始化全厂地下主管网
|
||||
this.InsertTF(project); //初始化临时设施
|
||||
this.InsertGL(project); //初始化总图
|
||||
ShowNotify("保存数据成功!", MessageBoxIcon.Success);
|
||||
// 2. 关闭本窗体,然后刷新父窗体
|
||||
// PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
||||
@@ -645,24 +649,25 @@ namespace FineUIPro.Web.ProjectData
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 初始化总图
|
||||
private void InsertZT(Model.Base_Project project)
|
||||
#region 初始化防腐绝热
|
||||
private void InsertAC(Model.Base_Project project)
|
||||
{
|
||||
var zt = Funs.DB.Project_Installation.FirstOrDefault(x => x.ProjectId == project.ProjectId && x.InstallationCode == "ZT");
|
||||
if (zt == null)
|
||||
var ac = Funs.DB.Project_Installation.FirstOrDefault(x => x.ProjectId == project.ProjectId && x.InstallationName == "防腐绝热");
|
||||
if (ac == null)
|
||||
{
|
||||
Model.Project_Installation installation = new Project_Installation();
|
||||
installation.InstallationId = SQLHelper.GetNewID(typeof(Model.Project_Installation));
|
||||
installation.ProjectId = project.ProjectId;
|
||||
installation.InstallationCode = "ZT";
|
||||
installation.InstallationName = "总图";
|
||||
installation.InstallationCode = "AC";
|
||||
installation.InstallationName = "防腐绝热";
|
||||
installation.SuperInstallationId = "0";
|
||||
installation.StartDate = project.StartDate;
|
||||
installation.EndDate = project.EndDate;
|
||||
installation.IsEnd = true;
|
||||
BLL.Project_InstallationService.AddInstallation(installation);
|
||||
// 拷贝总图专业下WBS内容
|
||||
//拷贝单位工程及子单位工程
|
||||
var unitProjectInits = from x in Funs.DB.Wbs_UnitProjectInit where x.CnProfessionId == 20 orderby x.SuperUnitProject select x;
|
||||
var unitProjectInits = from x in Funs.DB.Wbs_UnitProjectInit where x.CnProfessionId == Const.ACCNProfessionalId orderby x.SuperUnitProject select x;
|
||||
foreach (var unitProjectInit in unitProjectInits)
|
||||
{
|
||||
Model.Wbs_UnitProject unitProject = new Model.Wbs_UnitProject();
|
||||
@@ -688,7 +693,7 @@ namespace FineUIPro.Web.ProjectData
|
||||
BLL.UnitProjectService.AddUnitProject(unitProject);
|
||||
}
|
||||
//拷贝分部/子分部/分项/子分项
|
||||
var wbsSetInits = (from x in Funs.DB.WBS_WbsSetInit where x.CnProfessionId == 20 orderby x.SuperWbsSetCode select x).ToList();
|
||||
var wbsSetInits = (from x in Funs.DB.WBS_WbsSetInit where x.CnProfessionId == Const.ACCNProfessionalId orderby x.SuperWbsSetCode select x).ToList();
|
||||
foreach (var wbsSetInit in wbsSetInits)
|
||||
{
|
||||
Model.Wbs_WbsSet wbsSet = new Model.Wbs_WbsSet();
|
||||
@@ -718,6 +723,902 @@ namespace FineUIPro.Web.ProjectData
|
||||
wbsSet.IsIn = true;
|
||||
BLL.WbsSetService.AddWbsSet(wbsSet);
|
||||
}
|
||||
var totalCostControlInits = from x in Funs.DB.WBS_CostControlInit orderby x.CostControlInitCode select x;
|
||||
//拷贝费用清单对应关系
|
||||
var wbsSetMatchCostControlInits = from x in Funs.DB.WBS_WbsSetMatchCostControlInit orderby x.WbsSetCode select x;
|
||||
foreach (var wbsSetMatchCostControlInit in wbsSetMatchCostControlInits)
|
||||
{
|
||||
Model.WBS_WbsSetMatchCostControl wbsSetMatchCostControl = new Model.WBS_WbsSetMatchCostControl();
|
||||
wbsSetMatchCostControl.WbsSetMatchCostControlId = SQLHelper.GetNewID();
|
||||
wbsSetMatchCostControl.WbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetMatchCostControlInit.WbsSetCode && x.InstallationId == installation.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
wbsSetMatchCostControl.CostControlCode = wbsSetMatchCostControlInit.CostControlInitCode;
|
||||
BLL.WbsSetMatchCostControlService.AddWbsSetMatchCostControl(wbsSetMatchCostControl);
|
||||
//拷贝费用清单项
|
||||
var costControlInits = from x in totalCostControlInits where x.CostControlInitCode == wbsSetMatchCostControlInit.CostControlInitCode orderby x.CostControlInitCode select x;
|
||||
foreach (var costControlInit in costControlInits)
|
||||
{
|
||||
Model.WBS_CostControl costControl = new Model.WBS_CostControl();
|
||||
costControl.ProjectId = project.ProjectId;
|
||||
costControl.WbsSetId = wbsSetMatchCostControl.WbsSetId;
|
||||
costControl.CostControlCode = costControlInit.CostControlInitCode;
|
||||
costControl.CostControlName = costControlInit.CostControlInitName;
|
||||
costControl.Unit = costControlInit.Unit;
|
||||
BLL.CostControlService.AddCostControl(costControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ac.IsEnd = true;
|
||||
BLL.Project_InstallationService.UpdateInstallation(ac);
|
||||
Model.Wbs_UnitProject up = BLL.UnitProjectService.GetUnitProjectIdByInstallationId(ac.InstallationId);
|
||||
if (up == null)
|
||||
{
|
||||
// 拷贝总图专业下WBS内容
|
||||
//拷贝单位工程及子单位工程
|
||||
var unitProjectInits = from x in Funs.DB.Wbs_UnitProjectInit where x.CnProfessionId == Const.ACCNProfessionalId orderby x.SuperUnitProject select x;
|
||||
foreach (var unitProjectInit in unitProjectInits)
|
||||
{
|
||||
Model.Wbs_UnitProject unitProject = new Model.Wbs_UnitProject();
|
||||
unitProject.UnitProjectId = SQLHelper.GetNewID(typeof(Model.Wbs_UnitProject));
|
||||
unitProject.UnitProjectCode = unitProjectInit.UnitProjectCode;
|
||||
unitProject.UnitProjectName = unitProjectInit.UnitProjectName;
|
||||
if (unitProjectInit.SuperUnitProject == null)
|
||||
{
|
||||
unitProject.SuperUnitProjectId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
unitProject.SuperUnitProjectId = (from x in Funs.DB.Wbs_UnitProject
|
||||
where x.UnitProjectCode == unitProjectInit.SuperUnitProject && x.InstallationId == ac.InstallationId
|
||||
select x.UnitProjectId).FirstOrDefault();
|
||||
}
|
||||
unitProject.InstallationId = ac.InstallationId;
|
||||
unitProject.ProjectId = project.ProjectId;
|
||||
unitProject.StartDate = project.StartDate;
|
||||
unitProject.EndDate = project.EndDate;
|
||||
unitProject.Remark = unitProjectInit.Remark;
|
||||
unitProject.IsIn = true;
|
||||
BLL.UnitProjectService.AddUnitProject(unitProject);
|
||||
}
|
||||
//拷贝分部/子分部/分项/子分项
|
||||
var wbsSetInits = (from x in Funs.DB.WBS_WbsSetInit where x.CnProfessionId == Const.ACCNProfessionalId orderby x.SuperWbsSetCode select x).ToList();
|
||||
foreach (var wbsSetInit in wbsSetInits)
|
||||
{
|
||||
Model.Wbs_WbsSet wbsSet = new Model.Wbs_WbsSet();
|
||||
wbsSet.WbsSetId = SQLHelper.GetNewID(typeof(Model.Wbs_WbsSet));
|
||||
wbsSet.WbsSetCode = wbsSetInit.WbsSetCode;
|
||||
wbsSet.WbsSetName = wbsSetInit.WbsSetName;
|
||||
wbsSet.InstallationId = ac.InstallationId;
|
||||
wbsSet.UnitProjectId = (from x in Funs.DB.Wbs_UnitProject where x.UnitProjectCode == wbsSetInit.UnitProjectCode && x.InstallationId == ac.InstallationId select x.UnitProjectId).FirstOrDefault();
|
||||
if (wbsSetInit.SuperWbsSetCode == null)
|
||||
{
|
||||
wbsSet.SuperWbsSetId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
wbsSet.SuperWbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetInit.SuperWbsSetCode && x.InstallationId == ac.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
}
|
||||
wbsSet.ProjectId = project.ProjectId;
|
||||
wbsSet.StartDate = project.StartDate;
|
||||
wbsSet.EndDate = project.EndDate;
|
||||
wbsSet.Flag = wbsSetInit.Flag;
|
||||
wbsSet.Way = wbsSetInit.Way;
|
||||
wbsSet.ControlItemDef = wbsSetInit.ControlItemDef;
|
||||
wbsSet.ControlPoint = wbsSetInit.ControlPoint;
|
||||
wbsSet.Remark = wbsSetInit.Remark;
|
||||
wbsSet.IsIn = true;
|
||||
BLL.WbsSetService.AddWbsSet(wbsSet);
|
||||
}
|
||||
var totalCostControlInits = from x in Funs.DB.WBS_CostControlInit orderby x.CostControlInitCode select x;
|
||||
//拷贝费用清单对应关系
|
||||
var wbsSetMatchCostControlInits = from x in Funs.DB.WBS_WbsSetMatchCostControlInit orderby x.WbsSetCode select x;
|
||||
foreach (var wbsSetMatchCostControlInit in wbsSetMatchCostControlInits)
|
||||
{
|
||||
Model.WBS_WbsSetMatchCostControl wbsSetMatchCostControl = new Model.WBS_WbsSetMatchCostControl();
|
||||
wbsSetMatchCostControl.WbsSetMatchCostControlId = SQLHelper.GetNewID();
|
||||
wbsSetMatchCostControl.WbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetMatchCostControlInit.WbsSetCode && x.InstallationId == ac.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
wbsSetMatchCostControl.CostControlCode = wbsSetMatchCostControlInit.CostControlInitCode;
|
||||
BLL.WbsSetMatchCostControlService.AddWbsSetMatchCostControl(wbsSetMatchCostControl);
|
||||
//拷贝费用清单项
|
||||
var costControlInits = from x in totalCostControlInits where x.CostControlInitCode == wbsSetMatchCostControlInit.CostControlInitCode orderby x.CostControlInitCode select x;
|
||||
foreach (var costControlInit in costControlInits)
|
||||
{
|
||||
Model.WBS_CostControl costControl = new Model.WBS_CostControl();
|
||||
costControl.ProjectId = project.ProjectId;
|
||||
costControl.WbsSetId = wbsSetMatchCostControl.WbsSetId;
|
||||
costControl.CostControlCode = costControlInit.CostControlInitCode;
|
||||
costControl.CostControlName = costControlInit.CostControlInitName;
|
||||
costControl.Unit = costControlInit.Unit;
|
||||
BLL.CostControlService.AddCostControl(costControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 初始化地勘
|
||||
private void InsertGE(Model.Base_Project project)
|
||||
{
|
||||
var ge = Funs.DB.Project_Installation.FirstOrDefault(x => x.ProjectId == project.ProjectId && x.InstallationName == "地勘");
|
||||
if (ge == null)
|
||||
{
|
||||
Model.Project_Installation installation = new Project_Installation();
|
||||
installation.InstallationId = SQLHelper.GetNewID(typeof(Model.Project_Installation));
|
||||
installation.ProjectId = project.ProjectId;
|
||||
installation.InstallationCode = "GE";
|
||||
installation.InstallationName = "地勘";
|
||||
installation.SuperInstallationId = "0";
|
||||
installation.StartDate = project.StartDate;
|
||||
installation.EndDate = project.EndDate;
|
||||
installation.IsEnd = true;
|
||||
BLL.Project_InstallationService.AddInstallation(installation);
|
||||
// 拷贝总图专业下WBS内容
|
||||
//拷贝单位工程及子单位工程
|
||||
var unitProjectInits = from x in Funs.DB.Wbs_UnitProjectInit where x.CnProfessionId == Const.GECNProfessionalId orderby x.SuperUnitProject select x;
|
||||
foreach (var unitProjectInit in unitProjectInits)
|
||||
{
|
||||
Model.Wbs_UnitProject unitProject = new Model.Wbs_UnitProject();
|
||||
unitProject.UnitProjectId = SQLHelper.GetNewID(typeof(Model.Wbs_UnitProject));
|
||||
unitProject.UnitProjectCode = unitProjectInit.UnitProjectCode;
|
||||
unitProject.UnitProjectName = unitProjectInit.UnitProjectName;
|
||||
if (unitProjectInit.SuperUnitProject == null)
|
||||
{
|
||||
unitProject.SuperUnitProjectId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
unitProject.SuperUnitProjectId = (from x in Funs.DB.Wbs_UnitProject
|
||||
where x.UnitProjectCode == unitProjectInit.SuperUnitProject && x.InstallationId == installation.InstallationId
|
||||
select x.UnitProjectId).FirstOrDefault();
|
||||
}
|
||||
unitProject.InstallationId = installation.InstallationId;
|
||||
unitProject.ProjectId = project.ProjectId;
|
||||
unitProject.StartDate = project.StartDate;
|
||||
unitProject.EndDate = project.EndDate;
|
||||
unitProject.Remark = unitProjectInit.Remark;
|
||||
unitProject.IsIn = true;
|
||||
BLL.UnitProjectService.AddUnitProject(unitProject);
|
||||
}
|
||||
//拷贝分部/子分部/分项/子分项
|
||||
var wbsSetInits = (from x in Funs.DB.WBS_WbsSetInit where x.CnProfessionId == Const.GECNProfessionalId orderby x.SuperWbsSetCode select x).ToList();
|
||||
foreach (var wbsSetInit in wbsSetInits)
|
||||
{
|
||||
Model.Wbs_WbsSet wbsSet = new Model.Wbs_WbsSet();
|
||||
wbsSet.WbsSetId = SQLHelper.GetNewID(typeof(Model.Wbs_WbsSet));
|
||||
wbsSet.WbsSetCode = wbsSetInit.WbsSetCode;
|
||||
wbsSet.WbsSetName = wbsSetInit.WbsSetName;
|
||||
wbsSet.InstallationId = installation.InstallationId;
|
||||
wbsSet.UnitProjectId = (from x in Funs.DB.Wbs_UnitProject where x.UnitProjectCode == wbsSetInit.UnitProjectCode && x.InstallationId == installation.InstallationId select x.UnitProjectId).FirstOrDefault();
|
||||
if (wbsSetInit.SuperWbsSetCode == null)
|
||||
{
|
||||
wbsSet.SuperWbsSetId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
wbsSet.SuperWbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetInit.SuperWbsSetCode && x.InstallationId == installation.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
}
|
||||
wbsSet.ProjectId = project.ProjectId;
|
||||
wbsSet.StartDate = project.StartDate;
|
||||
wbsSet.EndDate = project.EndDate;
|
||||
wbsSet.Flag = wbsSetInit.Flag;
|
||||
wbsSet.Way = wbsSetInit.Way;
|
||||
wbsSet.ControlItemDef = wbsSetInit.ControlItemDef;
|
||||
wbsSet.ControlPoint = wbsSetInit.ControlPoint;
|
||||
wbsSet.Remark = wbsSetInit.Remark;
|
||||
wbsSet.IsIn = true;
|
||||
BLL.WbsSetService.AddWbsSet(wbsSet);
|
||||
}
|
||||
var totalCostControlInits = from x in Funs.DB.WBS_CostControlInit orderby x.CostControlInitCode select x;
|
||||
//拷贝费用清单对应关系
|
||||
var wbsSetMatchCostControlInits = from x in Funs.DB.WBS_WbsSetMatchCostControlInit orderby x.WbsSetCode select x;
|
||||
foreach (var wbsSetMatchCostControlInit in wbsSetMatchCostControlInits)
|
||||
{
|
||||
Model.WBS_WbsSetMatchCostControl wbsSetMatchCostControl = new Model.WBS_WbsSetMatchCostControl();
|
||||
wbsSetMatchCostControl.WbsSetMatchCostControlId = SQLHelper.GetNewID();
|
||||
wbsSetMatchCostControl.WbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetMatchCostControlInit.WbsSetCode && x.InstallationId == installation.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
wbsSetMatchCostControl.CostControlCode = wbsSetMatchCostControlInit.CostControlInitCode;
|
||||
BLL.WbsSetMatchCostControlService.AddWbsSetMatchCostControl(wbsSetMatchCostControl);
|
||||
//拷贝费用清单项
|
||||
var costControlInits = from x in totalCostControlInits where x.CostControlInitCode == wbsSetMatchCostControlInit.CostControlInitCode orderby x.CostControlInitCode select x;
|
||||
foreach (var costControlInit in costControlInits)
|
||||
{
|
||||
Model.WBS_CostControl costControl = new Model.WBS_CostControl();
|
||||
costControl.ProjectId = project.ProjectId;
|
||||
costControl.WbsSetId = wbsSetMatchCostControl.WbsSetId;
|
||||
costControl.CostControlCode = costControlInit.CostControlInitCode;
|
||||
costControl.CostControlName = costControlInit.CostControlInitName;
|
||||
costControl.Unit = costControlInit.Unit;
|
||||
BLL.CostControlService.AddCostControl(costControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ge.IsEnd = true;
|
||||
BLL.Project_InstallationService.UpdateInstallation(ge);
|
||||
Model.Wbs_UnitProject up = BLL.UnitProjectService.GetUnitProjectIdByInstallationId(ge.InstallationId);
|
||||
if (up == null)
|
||||
{
|
||||
// 拷贝总图专业下WBS内容
|
||||
//拷贝单位工程及子单位工程
|
||||
var unitProjectInits = from x in Funs.DB.Wbs_UnitProjectInit where x.CnProfessionId == Const.GECNProfessionalId orderby x.SuperUnitProject select x;
|
||||
foreach (var unitProjectInit in unitProjectInits)
|
||||
{
|
||||
Model.Wbs_UnitProject unitProject = new Model.Wbs_UnitProject();
|
||||
unitProject.UnitProjectId = SQLHelper.GetNewID(typeof(Model.Wbs_UnitProject));
|
||||
unitProject.UnitProjectCode = unitProjectInit.UnitProjectCode;
|
||||
unitProject.UnitProjectName = unitProjectInit.UnitProjectName;
|
||||
if (unitProjectInit.SuperUnitProject == null)
|
||||
{
|
||||
unitProject.SuperUnitProjectId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
unitProject.SuperUnitProjectId = (from x in Funs.DB.Wbs_UnitProject
|
||||
where x.UnitProjectCode == unitProjectInit.SuperUnitProject && x.InstallationId == ge.InstallationId
|
||||
select x.UnitProjectId).FirstOrDefault();
|
||||
}
|
||||
unitProject.InstallationId = ge.InstallationId;
|
||||
unitProject.ProjectId = project.ProjectId;
|
||||
unitProject.StartDate = project.StartDate;
|
||||
unitProject.EndDate = project.EndDate;
|
||||
unitProject.Remark = unitProjectInit.Remark;
|
||||
unitProject.IsIn = true;
|
||||
BLL.UnitProjectService.AddUnitProject(unitProject);
|
||||
}
|
||||
//拷贝分部/子分部/分项/子分项
|
||||
var wbsSetInits = (from x in Funs.DB.WBS_WbsSetInit where x.CnProfessionId == Const.GECNProfessionalId orderby x.SuperWbsSetCode select x).ToList();
|
||||
foreach (var wbsSetInit in wbsSetInits)
|
||||
{
|
||||
Model.Wbs_WbsSet wbsSet = new Model.Wbs_WbsSet();
|
||||
wbsSet.WbsSetId = SQLHelper.GetNewID(typeof(Model.Wbs_WbsSet));
|
||||
wbsSet.WbsSetCode = wbsSetInit.WbsSetCode;
|
||||
wbsSet.WbsSetName = wbsSetInit.WbsSetName;
|
||||
wbsSet.InstallationId = ge.InstallationId;
|
||||
wbsSet.UnitProjectId = (from x in Funs.DB.Wbs_UnitProject where x.UnitProjectCode == wbsSetInit.UnitProjectCode && x.InstallationId == ge.InstallationId select x.UnitProjectId).FirstOrDefault();
|
||||
if (wbsSetInit.SuperWbsSetCode == null)
|
||||
{
|
||||
wbsSet.SuperWbsSetId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
wbsSet.SuperWbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetInit.SuperWbsSetCode && x.InstallationId == ge.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
}
|
||||
wbsSet.ProjectId = project.ProjectId;
|
||||
wbsSet.StartDate = project.StartDate;
|
||||
wbsSet.EndDate = project.EndDate;
|
||||
wbsSet.Flag = wbsSetInit.Flag;
|
||||
wbsSet.Way = wbsSetInit.Way;
|
||||
wbsSet.ControlItemDef = wbsSetInit.ControlItemDef;
|
||||
wbsSet.ControlPoint = wbsSetInit.ControlPoint;
|
||||
wbsSet.Remark = wbsSetInit.Remark;
|
||||
wbsSet.IsIn = true;
|
||||
BLL.WbsSetService.AddWbsSet(wbsSet);
|
||||
}
|
||||
var totalCostControlInits = from x in Funs.DB.WBS_CostControlInit orderby x.CostControlInitCode select x;
|
||||
//拷贝费用清单对应关系
|
||||
var wbsSetMatchCostControlInits = from x in Funs.DB.WBS_WbsSetMatchCostControlInit orderby x.WbsSetCode select x;
|
||||
foreach (var wbsSetMatchCostControlInit in wbsSetMatchCostControlInits)
|
||||
{
|
||||
Model.WBS_WbsSetMatchCostControl wbsSetMatchCostControl = new Model.WBS_WbsSetMatchCostControl();
|
||||
wbsSetMatchCostControl.WbsSetMatchCostControlId = SQLHelper.GetNewID();
|
||||
wbsSetMatchCostControl.WbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetMatchCostControlInit.WbsSetCode && x.InstallationId == ge.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
wbsSetMatchCostControl.CostControlCode = wbsSetMatchCostControlInit.CostControlInitCode;
|
||||
BLL.WbsSetMatchCostControlService.AddWbsSetMatchCostControl(wbsSetMatchCostControl);
|
||||
//拷贝费用清单项
|
||||
var costControlInits = from x in totalCostControlInits where x.CostControlInitCode == wbsSetMatchCostControlInit.CostControlInitCode orderby x.CostControlInitCode select x;
|
||||
foreach (var costControlInit in costControlInits)
|
||||
{
|
||||
Model.WBS_CostControl costControl = new Model.WBS_CostControl();
|
||||
costControl.ProjectId = project.ProjectId;
|
||||
costControl.WbsSetId = wbsSetMatchCostControl.WbsSetId;
|
||||
costControl.CostControlCode = costControlInit.CostControlInitCode;
|
||||
costControl.CostControlName = costControlInit.CostControlInitName;
|
||||
costControl.Unit = costControlInit.Unit;
|
||||
BLL.CostControlService.AddCostControl(costControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 初始化全厂地下主管网
|
||||
private void InsertUP(Model.Base_Project project)
|
||||
{
|
||||
var u = Funs.DB.Project_Installation.FirstOrDefault(x => x.ProjectId == project.ProjectId && x.InstallationName == "全厂地下主管网");
|
||||
if (u == null)
|
||||
{
|
||||
Model.Project_Installation installation = new Project_Installation();
|
||||
installation.InstallationId = SQLHelper.GetNewID(typeof(Model.Project_Installation));
|
||||
installation.ProjectId = project.ProjectId;
|
||||
installation.InstallationCode = "UP";
|
||||
installation.InstallationName = "全厂地下主管网";
|
||||
installation.SuperInstallationId = "0";
|
||||
installation.StartDate = project.StartDate;
|
||||
installation.EndDate = project.EndDate;
|
||||
installation.IsEnd = true;
|
||||
BLL.Project_InstallationService.AddInstallation(installation);
|
||||
// 拷贝总图专业下WBS内容
|
||||
//拷贝单位工程及子单位工程
|
||||
var unitProjectInits = from x in Funs.DB.Wbs_UnitProjectInit where x.CnProfessionId == Const.UPCNProfessionalId orderby x.SuperUnitProject select x;
|
||||
foreach (var unitProjectInit in unitProjectInits)
|
||||
{
|
||||
Model.Wbs_UnitProject unitProject = new Model.Wbs_UnitProject();
|
||||
unitProject.UnitProjectId = SQLHelper.GetNewID(typeof(Model.Wbs_UnitProject));
|
||||
unitProject.UnitProjectCode = unitProjectInit.UnitProjectCode;
|
||||
unitProject.UnitProjectName = unitProjectInit.UnitProjectName;
|
||||
if (unitProjectInit.SuperUnitProject == null)
|
||||
{
|
||||
unitProject.SuperUnitProjectId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
unitProject.SuperUnitProjectId = (from x in Funs.DB.Wbs_UnitProject
|
||||
where x.UnitProjectCode == unitProjectInit.SuperUnitProject && x.InstallationId == installation.InstallationId
|
||||
select x.UnitProjectId).FirstOrDefault();
|
||||
}
|
||||
unitProject.InstallationId = installation.InstallationId;
|
||||
unitProject.ProjectId = project.ProjectId;
|
||||
unitProject.StartDate = project.StartDate;
|
||||
unitProject.EndDate = project.EndDate;
|
||||
unitProject.Remark = unitProjectInit.Remark;
|
||||
unitProject.IsIn = true;
|
||||
BLL.UnitProjectService.AddUnitProject(unitProject);
|
||||
}
|
||||
//拷贝分部/子分部/分项/子分项
|
||||
var wbsSetInits = (from x in Funs.DB.WBS_WbsSetInit where x.CnProfessionId == Const.UPCNProfessionalId orderby x.SuperWbsSetCode select x).ToList();
|
||||
foreach (var wbsSetInit in wbsSetInits)
|
||||
{
|
||||
Model.Wbs_WbsSet wbsSet = new Model.Wbs_WbsSet();
|
||||
wbsSet.WbsSetId = SQLHelper.GetNewID(typeof(Model.Wbs_WbsSet));
|
||||
wbsSet.WbsSetCode = wbsSetInit.WbsSetCode;
|
||||
wbsSet.WbsSetName = wbsSetInit.WbsSetName;
|
||||
wbsSet.InstallationId = installation.InstallationId;
|
||||
wbsSet.UnitProjectId = (from x in Funs.DB.Wbs_UnitProject where x.UnitProjectCode == wbsSetInit.UnitProjectCode && x.InstallationId == installation.InstallationId select x.UnitProjectId).FirstOrDefault();
|
||||
if (wbsSetInit.SuperWbsSetCode == null)
|
||||
{
|
||||
wbsSet.SuperWbsSetId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
wbsSet.SuperWbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetInit.SuperWbsSetCode && x.InstallationId == installation.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
}
|
||||
wbsSet.ProjectId = project.ProjectId;
|
||||
wbsSet.StartDate = project.StartDate;
|
||||
wbsSet.EndDate = project.EndDate;
|
||||
wbsSet.Flag = wbsSetInit.Flag;
|
||||
wbsSet.Way = wbsSetInit.Way;
|
||||
wbsSet.ControlItemDef = wbsSetInit.ControlItemDef;
|
||||
wbsSet.ControlPoint = wbsSetInit.ControlPoint;
|
||||
wbsSet.Remark = wbsSetInit.Remark;
|
||||
wbsSet.IsIn = true;
|
||||
BLL.WbsSetService.AddWbsSet(wbsSet);
|
||||
}
|
||||
var totalCostControlInits = from x in Funs.DB.WBS_CostControlInit orderby x.CostControlInitCode select x;
|
||||
//拷贝费用清单对应关系
|
||||
var wbsSetMatchCostControlInits = from x in Funs.DB.WBS_WbsSetMatchCostControlInit orderby x.WbsSetCode select x;
|
||||
foreach (var wbsSetMatchCostControlInit in wbsSetMatchCostControlInits)
|
||||
{
|
||||
Model.WBS_WbsSetMatchCostControl wbsSetMatchCostControl = new Model.WBS_WbsSetMatchCostControl();
|
||||
wbsSetMatchCostControl.WbsSetMatchCostControlId = SQLHelper.GetNewID();
|
||||
wbsSetMatchCostControl.WbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetMatchCostControlInit.WbsSetCode && x.InstallationId == installation.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
wbsSetMatchCostControl.CostControlCode = wbsSetMatchCostControlInit.CostControlInitCode;
|
||||
BLL.WbsSetMatchCostControlService.AddWbsSetMatchCostControl(wbsSetMatchCostControl);
|
||||
//拷贝费用清单项
|
||||
var costControlInits = from x in totalCostControlInits where x.CostControlInitCode == wbsSetMatchCostControlInit.CostControlInitCode orderby x.CostControlInitCode select x;
|
||||
foreach (var costControlInit in costControlInits)
|
||||
{
|
||||
Model.WBS_CostControl costControl = new Model.WBS_CostControl();
|
||||
costControl.ProjectId = project.ProjectId;
|
||||
costControl.WbsSetId = wbsSetMatchCostControl.WbsSetId;
|
||||
costControl.CostControlCode = costControlInit.CostControlInitCode;
|
||||
costControl.CostControlName = costControlInit.CostControlInitName;
|
||||
costControl.Unit = costControlInit.Unit;
|
||||
BLL.CostControlService.AddCostControl(costControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u.IsEnd = true;
|
||||
BLL.Project_InstallationService.UpdateInstallation(u);
|
||||
Model.Wbs_UnitProject up = BLL.UnitProjectService.GetUnitProjectIdByInstallationId(u.InstallationId);
|
||||
if (up == null)
|
||||
{
|
||||
// 拷贝总图专业下WBS内容
|
||||
//拷贝单位工程及子单位工程
|
||||
var unitProjectInits = from x in Funs.DB.Wbs_UnitProjectInit where x.CnProfessionId == Const.UPCNProfessionalId orderby x.SuperUnitProject select x;
|
||||
foreach (var unitProjectInit in unitProjectInits)
|
||||
{
|
||||
Model.Wbs_UnitProject unitProject = new Model.Wbs_UnitProject();
|
||||
unitProject.UnitProjectId = SQLHelper.GetNewID(typeof(Model.Wbs_UnitProject));
|
||||
unitProject.UnitProjectCode = unitProjectInit.UnitProjectCode;
|
||||
unitProject.UnitProjectName = unitProjectInit.UnitProjectName;
|
||||
if (unitProjectInit.SuperUnitProject == null)
|
||||
{
|
||||
unitProject.SuperUnitProjectId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
unitProject.SuperUnitProjectId = (from x in Funs.DB.Wbs_UnitProject
|
||||
where x.UnitProjectCode == unitProjectInit.SuperUnitProject && x.InstallationId == u.InstallationId
|
||||
select x.UnitProjectId).FirstOrDefault();
|
||||
}
|
||||
unitProject.InstallationId = u.InstallationId;
|
||||
unitProject.ProjectId = project.ProjectId;
|
||||
unitProject.StartDate = project.StartDate;
|
||||
unitProject.EndDate = project.EndDate;
|
||||
unitProject.Remark = unitProjectInit.Remark;
|
||||
unitProject.IsIn = true;
|
||||
BLL.UnitProjectService.AddUnitProject(unitProject);
|
||||
}
|
||||
//拷贝分部/子分部/分项/子分项
|
||||
var wbsSetInits = (from x in Funs.DB.WBS_WbsSetInit where x.CnProfessionId == Const.UPCNProfessionalId orderby x.SuperWbsSetCode select x).ToList();
|
||||
foreach (var wbsSetInit in wbsSetInits)
|
||||
{
|
||||
Model.Wbs_WbsSet wbsSet = new Model.Wbs_WbsSet();
|
||||
wbsSet.WbsSetId = SQLHelper.GetNewID(typeof(Model.Wbs_WbsSet));
|
||||
wbsSet.WbsSetCode = wbsSetInit.WbsSetCode;
|
||||
wbsSet.WbsSetName = wbsSetInit.WbsSetName;
|
||||
wbsSet.InstallationId = u.InstallationId;
|
||||
wbsSet.UnitProjectId = (from x in Funs.DB.Wbs_UnitProject where x.UnitProjectCode == wbsSetInit.UnitProjectCode && x.InstallationId == u.InstallationId select x.UnitProjectId).FirstOrDefault();
|
||||
if (wbsSetInit.SuperWbsSetCode == null)
|
||||
{
|
||||
wbsSet.SuperWbsSetId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
wbsSet.SuperWbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetInit.SuperWbsSetCode && x.InstallationId == u.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
}
|
||||
wbsSet.ProjectId = project.ProjectId;
|
||||
wbsSet.StartDate = project.StartDate;
|
||||
wbsSet.EndDate = project.EndDate;
|
||||
wbsSet.Flag = wbsSetInit.Flag;
|
||||
wbsSet.Way = wbsSetInit.Way;
|
||||
wbsSet.ControlItemDef = wbsSetInit.ControlItemDef;
|
||||
wbsSet.ControlPoint = wbsSetInit.ControlPoint;
|
||||
wbsSet.Remark = wbsSetInit.Remark;
|
||||
wbsSet.IsIn = true;
|
||||
BLL.WbsSetService.AddWbsSet(wbsSet);
|
||||
}
|
||||
var totalCostControlInits = from x in Funs.DB.WBS_CostControlInit orderby x.CostControlInitCode select x;
|
||||
//拷贝费用清单对应关系
|
||||
var wbsSetMatchCostControlInits = from x in Funs.DB.WBS_WbsSetMatchCostControlInit orderby x.WbsSetCode select x;
|
||||
foreach (var wbsSetMatchCostControlInit in wbsSetMatchCostControlInits)
|
||||
{
|
||||
Model.WBS_WbsSetMatchCostControl wbsSetMatchCostControl = new Model.WBS_WbsSetMatchCostControl();
|
||||
wbsSetMatchCostControl.WbsSetMatchCostControlId = SQLHelper.GetNewID();
|
||||
wbsSetMatchCostControl.WbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetMatchCostControlInit.WbsSetCode && x.InstallationId == u.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
wbsSetMatchCostControl.CostControlCode = wbsSetMatchCostControlInit.CostControlInitCode;
|
||||
BLL.WbsSetMatchCostControlService.AddWbsSetMatchCostControl(wbsSetMatchCostControl);
|
||||
//拷贝费用清单项
|
||||
var costControlInits = from x in totalCostControlInits where x.CostControlInitCode == wbsSetMatchCostControlInit.CostControlInitCode orderby x.CostControlInitCode select x;
|
||||
foreach (var costControlInit in costControlInits)
|
||||
{
|
||||
Model.WBS_CostControl costControl = new Model.WBS_CostControl();
|
||||
costControl.ProjectId = project.ProjectId;
|
||||
costControl.WbsSetId = wbsSetMatchCostControl.WbsSetId;
|
||||
costControl.CostControlCode = costControlInit.CostControlInitCode;
|
||||
costControl.CostControlName = costControlInit.CostControlInitName;
|
||||
costControl.Unit = costControlInit.Unit;
|
||||
BLL.CostControlService.AddCostControl(costControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 初始化临时设施
|
||||
private void InsertTF(Model.Base_Project project)
|
||||
{
|
||||
var tf = Funs.DB.Project_Installation.FirstOrDefault(x => x.ProjectId == project.ProjectId && x.InstallationName == "临时设施");
|
||||
if (tf == null)
|
||||
{
|
||||
Model.Project_Installation installation = new Project_Installation();
|
||||
installation.InstallationId = SQLHelper.GetNewID(typeof(Model.Project_Installation));
|
||||
installation.ProjectId = project.ProjectId;
|
||||
installation.InstallationCode = "TF";
|
||||
installation.InstallationName = "临时设施";
|
||||
installation.SuperInstallationId = "0";
|
||||
installation.StartDate = project.StartDate;
|
||||
installation.EndDate = project.EndDate;
|
||||
installation.IsEnd = true;
|
||||
BLL.Project_InstallationService.AddInstallation(installation);
|
||||
// 拷贝总图专业下WBS内容
|
||||
//拷贝单位工程及子单位工程
|
||||
var unitProjectInits = from x in Funs.DB.Wbs_UnitProjectInit where x.CnProfessionId == Const.TFCNProfessionalId orderby x.SuperUnitProject select x;
|
||||
foreach (var unitProjectInit in unitProjectInits)
|
||||
{
|
||||
Model.Wbs_UnitProject unitProject = new Model.Wbs_UnitProject();
|
||||
unitProject.UnitProjectId = SQLHelper.GetNewID(typeof(Model.Wbs_UnitProject));
|
||||
unitProject.UnitProjectCode = unitProjectInit.UnitProjectCode;
|
||||
unitProject.UnitProjectName = unitProjectInit.UnitProjectName;
|
||||
if (unitProjectInit.SuperUnitProject == null)
|
||||
{
|
||||
unitProject.SuperUnitProjectId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
unitProject.SuperUnitProjectId = (from x in Funs.DB.Wbs_UnitProject
|
||||
where x.UnitProjectCode == unitProjectInit.SuperUnitProject && x.InstallationId == installation.InstallationId
|
||||
select x.UnitProjectId).FirstOrDefault();
|
||||
}
|
||||
unitProject.InstallationId = installation.InstallationId;
|
||||
unitProject.ProjectId = project.ProjectId;
|
||||
unitProject.StartDate = project.StartDate;
|
||||
unitProject.EndDate = project.EndDate;
|
||||
unitProject.Remark = unitProjectInit.Remark;
|
||||
unitProject.IsIn = true;
|
||||
BLL.UnitProjectService.AddUnitProject(unitProject);
|
||||
}
|
||||
//拷贝分部/子分部/分项/子分项
|
||||
var wbsSetInits = (from x in Funs.DB.WBS_WbsSetInit where x.CnProfessionId == Const.TFCNProfessionalId orderby x.SuperWbsSetCode select x).ToList();
|
||||
foreach (var wbsSetInit in wbsSetInits)
|
||||
{
|
||||
Model.Wbs_WbsSet wbsSet = new Model.Wbs_WbsSet();
|
||||
wbsSet.WbsSetId = SQLHelper.GetNewID(typeof(Model.Wbs_WbsSet));
|
||||
wbsSet.WbsSetCode = wbsSetInit.WbsSetCode;
|
||||
wbsSet.WbsSetName = wbsSetInit.WbsSetName;
|
||||
wbsSet.InstallationId = installation.InstallationId;
|
||||
wbsSet.UnitProjectId = (from x in Funs.DB.Wbs_UnitProject where x.UnitProjectCode == wbsSetInit.UnitProjectCode && x.InstallationId == installation.InstallationId select x.UnitProjectId).FirstOrDefault();
|
||||
if (wbsSetInit.SuperWbsSetCode == null)
|
||||
{
|
||||
wbsSet.SuperWbsSetId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
wbsSet.SuperWbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetInit.SuperWbsSetCode && x.InstallationId == installation.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
}
|
||||
wbsSet.ProjectId = project.ProjectId;
|
||||
wbsSet.StartDate = project.StartDate;
|
||||
wbsSet.EndDate = project.EndDate;
|
||||
wbsSet.Flag = wbsSetInit.Flag;
|
||||
wbsSet.Way = wbsSetInit.Way;
|
||||
wbsSet.ControlItemDef = wbsSetInit.ControlItemDef;
|
||||
wbsSet.ControlPoint = wbsSetInit.ControlPoint;
|
||||
wbsSet.Remark = wbsSetInit.Remark;
|
||||
wbsSet.IsIn = true;
|
||||
BLL.WbsSetService.AddWbsSet(wbsSet);
|
||||
}
|
||||
var totalCostControlInits = from x in Funs.DB.WBS_CostControlInit orderby x.CostControlInitCode select x;
|
||||
//拷贝费用清单对应关系
|
||||
var wbsSetMatchCostControlInits = from x in Funs.DB.WBS_WbsSetMatchCostControlInit orderby x.WbsSetCode select x;
|
||||
foreach (var wbsSetMatchCostControlInit in wbsSetMatchCostControlInits)
|
||||
{
|
||||
Model.WBS_WbsSetMatchCostControl wbsSetMatchCostControl = new Model.WBS_WbsSetMatchCostControl();
|
||||
wbsSetMatchCostControl.WbsSetMatchCostControlId = SQLHelper.GetNewID();
|
||||
wbsSetMatchCostControl.WbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetMatchCostControlInit.WbsSetCode && x.InstallationId == installation.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
wbsSetMatchCostControl.CostControlCode = wbsSetMatchCostControlInit.CostControlInitCode;
|
||||
BLL.WbsSetMatchCostControlService.AddWbsSetMatchCostControl(wbsSetMatchCostControl);
|
||||
//拷贝费用清单项
|
||||
var costControlInits = from x in totalCostControlInits where x.CostControlInitCode == wbsSetMatchCostControlInit.CostControlInitCode orderby x.CostControlInitCode select x;
|
||||
foreach (var costControlInit in costControlInits)
|
||||
{
|
||||
Model.WBS_CostControl costControl = new Model.WBS_CostControl();
|
||||
costControl.ProjectId = project.ProjectId;
|
||||
costControl.WbsSetId = wbsSetMatchCostControl.WbsSetId;
|
||||
costControl.CostControlCode = costControlInit.CostControlInitCode;
|
||||
costControl.CostControlName = costControlInit.CostControlInitName;
|
||||
costControl.Unit = costControlInit.Unit;
|
||||
BLL.CostControlService.AddCostControl(costControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tf.IsEnd = true;
|
||||
BLL.Project_InstallationService.UpdateInstallation(tf);
|
||||
Model.Wbs_UnitProject up = BLL.UnitProjectService.GetUnitProjectIdByInstallationId(tf.InstallationId);
|
||||
if (up == null)
|
||||
{
|
||||
// 拷贝总图专业下WBS内容
|
||||
//拷贝单位工程及子单位工程
|
||||
var unitProjectInits = from x in Funs.DB.Wbs_UnitProjectInit where x.CnProfessionId == Const.TFCNProfessionalId orderby x.SuperUnitProject select x;
|
||||
foreach (var unitProjectInit in unitProjectInits)
|
||||
{
|
||||
Model.Wbs_UnitProject unitProject = new Model.Wbs_UnitProject();
|
||||
unitProject.UnitProjectId = SQLHelper.GetNewID(typeof(Model.Wbs_UnitProject));
|
||||
unitProject.UnitProjectCode = unitProjectInit.UnitProjectCode;
|
||||
unitProject.UnitProjectName = unitProjectInit.UnitProjectName;
|
||||
if (unitProjectInit.SuperUnitProject == null)
|
||||
{
|
||||
unitProject.SuperUnitProjectId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
unitProject.SuperUnitProjectId = (from x in Funs.DB.Wbs_UnitProject
|
||||
where x.UnitProjectCode == unitProjectInit.SuperUnitProject && x.InstallationId == tf.InstallationId
|
||||
select x.UnitProjectId).FirstOrDefault();
|
||||
}
|
||||
unitProject.InstallationId = tf.InstallationId;
|
||||
unitProject.ProjectId = project.ProjectId;
|
||||
unitProject.StartDate = project.StartDate;
|
||||
unitProject.EndDate = project.EndDate;
|
||||
unitProject.Remark = unitProjectInit.Remark;
|
||||
unitProject.IsIn = true;
|
||||
BLL.UnitProjectService.AddUnitProject(unitProject);
|
||||
}
|
||||
//拷贝分部/子分部/分项/子分项
|
||||
var wbsSetInits = (from x in Funs.DB.WBS_WbsSetInit where x.CnProfessionId == Const.TFCNProfessionalId orderby x.SuperWbsSetCode select x).ToList();
|
||||
foreach (var wbsSetInit in wbsSetInits)
|
||||
{
|
||||
Model.Wbs_WbsSet wbsSet = new Model.Wbs_WbsSet();
|
||||
wbsSet.WbsSetId = SQLHelper.GetNewID(typeof(Model.Wbs_WbsSet));
|
||||
wbsSet.WbsSetCode = wbsSetInit.WbsSetCode;
|
||||
wbsSet.WbsSetName = wbsSetInit.WbsSetName;
|
||||
wbsSet.InstallationId = tf.InstallationId;
|
||||
wbsSet.UnitProjectId = (from x in Funs.DB.Wbs_UnitProject where x.UnitProjectCode == wbsSetInit.UnitProjectCode && x.InstallationId == tf.InstallationId select x.UnitProjectId).FirstOrDefault();
|
||||
if (wbsSetInit.SuperWbsSetCode == null)
|
||||
{
|
||||
wbsSet.SuperWbsSetId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
wbsSet.SuperWbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetInit.SuperWbsSetCode && x.InstallationId == tf.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
}
|
||||
wbsSet.ProjectId = project.ProjectId;
|
||||
wbsSet.StartDate = project.StartDate;
|
||||
wbsSet.EndDate = project.EndDate;
|
||||
wbsSet.Flag = wbsSetInit.Flag;
|
||||
wbsSet.Way = wbsSetInit.Way;
|
||||
wbsSet.ControlItemDef = wbsSetInit.ControlItemDef;
|
||||
wbsSet.ControlPoint = wbsSetInit.ControlPoint;
|
||||
wbsSet.Remark = wbsSetInit.Remark;
|
||||
wbsSet.IsIn = true;
|
||||
BLL.WbsSetService.AddWbsSet(wbsSet);
|
||||
}
|
||||
var totalCostControlInits = from x in Funs.DB.WBS_CostControlInit orderby x.CostControlInitCode select x;
|
||||
//拷贝费用清单对应关系
|
||||
var wbsSetMatchCostControlInits = from x in Funs.DB.WBS_WbsSetMatchCostControlInit orderby x.WbsSetCode select x;
|
||||
foreach (var wbsSetMatchCostControlInit in wbsSetMatchCostControlInits)
|
||||
{
|
||||
Model.WBS_WbsSetMatchCostControl wbsSetMatchCostControl = new Model.WBS_WbsSetMatchCostControl();
|
||||
wbsSetMatchCostControl.WbsSetMatchCostControlId = SQLHelper.GetNewID();
|
||||
wbsSetMatchCostControl.WbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetMatchCostControlInit.WbsSetCode && x.InstallationId == tf.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
wbsSetMatchCostControl.CostControlCode = wbsSetMatchCostControlInit.CostControlInitCode;
|
||||
BLL.WbsSetMatchCostControlService.AddWbsSetMatchCostControl(wbsSetMatchCostControl);
|
||||
//拷贝费用清单项
|
||||
var costControlInits = from x in totalCostControlInits where x.CostControlInitCode == wbsSetMatchCostControlInit.CostControlInitCode orderby x.CostControlInitCode select x;
|
||||
foreach (var costControlInit in costControlInits)
|
||||
{
|
||||
Model.WBS_CostControl costControl = new Model.WBS_CostControl();
|
||||
costControl.ProjectId = project.ProjectId;
|
||||
costControl.WbsSetId = wbsSetMatchCostControl.WbsSetId;
|
||||
costControl.CostControlCode = costControlInit.CostControlInitCode;
|
||||
costControl.CostControlName = costControlInit.CostControlInitName;
|
||||
costControl.Unit = costControlInit.Unit;
|
||||
BLL.CostControlService.AddCostControl(costControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 初始化总图
|
||||
private void InsertGL(Model.Base_Project project)
|
||||
{
|
||||
var gl = Funs.DB.Project_Installation.FirstOrDefault(x => x.ProjectId == project.ProjectId && x.InstallationName == "总图");
|
||||
if (gl == null)
|
||||
{
|
||||
Model.Project_Installation installation = new Project_Installation();
|
||||
installation.InstallationId = SQLHelper.GetNewID(typeof(Model.Project_Installation));
|
||||
installation.ProjectId = project.ProjectId;
|
||||
installation.InstallationCode = "GL";
|
||||
installation.InstallationName = "总图";
|
||||
installation.SuperInstallationId = "0";
|
||||
installation.StartDate = project.StartDate;
|
||||
installation.EndDate = project.EndDate;
|
||||
BLL.Project_InstallationService.AddInstallation(installation);
|
||||
// 拷贝总图专业下WBS内容
|
||||
//拷贝单位工程及子单位工程
|
||||
var unitProjectInits = from x in Funs.DB.Wbs_UnitProjectInit where x.CnProfessionId == Const.GLCNProfessionalId orderby x.SuperUnitProject select x;
|
||||
foreach (var unitProjectInit in unitProjectInits)
|
||||
{
|
||||
Model.Wbs_UnitProject unitProject = new Model.Wbs_UnitProject();
|
||||
unitProject.UnitProjectId = SQLHelper.GetNewID(typeof(Model.Wbs_UnitProject));
|
||||
unitProject.UnitProjectCode = unitProjectInit.UnitProjectCode;
|
||||
unitProject.UnitProjectName = unitProjectInit.UnitProjectName;
|
||||
if (unitProjectInit.SuperUnitProject == null)
|
||||
{
|
||||
unitProject.SuperUnitProjectId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
unitProject.SuperUnitProjectId = (from x in Funs.DB.Wbs_UnitProject
|
||||
where x.UnitProjectCode == unitProjectInit.SuperUnitProject && x.InstallationId == installation.InstallationId
|
||||
select x.UnitProjectId).FirstOrDefault();
|
||||
}
|
||||
unitProject.InstallationId = installation.InstallationId;
|
||||
unitProject.ProjectId = project.ProjectId;
|
||||
unitProject.StartDate = project.StartDate;
|
||||
unitProject.EndDate = project.EndDate;
|
||||
unitProject.Remark = unitProjectInit.Remark;
|
||||
unitProject.IsIn = true;
|
||||
BLL.UnitProjectService.AddUnitProject(unitProject);
|
||||
}
|
||||
//拷贝分部/子分部/分项/子分项
|
||||
var wbsSetInits = (from x in Funs.DB.WBS_WbsSetInit where x.CnProfessionId == Const.GLCNProfessionalId orderby x.SuperWbsSetCode select x).ToList();
|
||||
foreach (var wbsSetInit in wbsSetInits)
|
||||
{
|
||||
Model.Wbs_WbsSet wbsSet = new Model.Wbs_WbsSet();
|
||||
wbsSet.WbsSetId = SQLHelper.GetNewID(typeof(Model.Wbs_WbsSet));
|
||||
wbsSet.WbsSetCode = wbsSetInit.WbsSetCode;
|
||||
wbsSet.WbsSetName = wbsSetInit.WbsSetName;
|
||||
wbsSet.InstallationId = installation.InstallationId;
|
||||
wbsSet.UnitProjectId = (from x in Funs.DB.Wbs_UnitProject where x.UnitProjectCode == wbsSetInit.UnitProjectCode && x.InstallationId == installation.InstallationId select x.UnitProjectId).FirstOrDefault();
|
||||
if (wbsSetInit.SuperWbsSetCode == null)
|
||||
{
|
||||
wbsSet.SuperWbsSetId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
wbsSet.SuperWbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetInit.SuperWbsSetCode && x.InstallationId == installation.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
}
|
||||
wbsSet.ProjectId = project.ProjectId;
|
||||
wbsSet.StartDate = project.StartDate;
|
||||
wbsSet.EndDate = project.EndDate;
|
||||
wbsSet.Flag = wbsSetInit.Flag;
|
||||
wbsSet.Way = wbsSetInit.Way;
|
||||
wbsSet.ControlItemDef = wbsSetInit.ControlItemDef;
|
||||
wbsSet.ControlPoint = wbsSetInit.ControlPoint;
|
||||
wbsSet.Remark = wbsSetInit.Remark;
|
||||
wbsSet.IsIn = true;
|
||||
BLL.WbsSetService.AddWbsSet(wbsSet);
|
||||
}
|
||||
var totalCostControlInits = from x in Funs.DB.WBS_CostControlInit orderby x.CostControlInitCode select x;
|
||||
//拷贝费用清单对应关系
|
||||
var wbsSetMatchCostControlInits = from x in Funs.DB.WBS_WbsSetMatchCostControlInit orderby x.WbsSetCode select x;
|
||||
foreach (var wbsSetMatchCostControlInit in wbsSetMatchCostControlInits)
|
||||
{
|
||||
Model.WBS_WbsSetMatchCostControl wbsSetMatchCostControl = new Model.WBS_WbsSetMatchCostControl();
|
||||
wbsSetMatchCostControl.WbsSetMatchCostControlId = SQLHelper.GetNewID();
|
||||
wbsSetMatchCostControl.WbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetMatchCostControlInit.WbsSetCode && x.InstallationId == installation.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
wbsSetMatchCostControl.CostControlCode = wbsSetMatchCostControlInit.CostControlInitCode;
|
||||
BLL.WbsSetMatchCostControlService.AddWbsSetMatchCostControl(wbsSetMatchCostControl);
|
||||
//拷贝费用清单项
|
||||
var costControlInits = from x in totalCostControlInits where x.CostControlInitCode == wbsSetMatchCostControlInit.CostControlInitCode orderby x.CostControlInitCode select x;
|
||||
foreach (var costControlInit in costControlInits)
|
||||
{
|
||||
Model.WBS_CostControl costControl = new Model.WBS_CostControl();
|
||||
costControl.ProjectId = project.ProjectId;
|
||||
costControl.WbsSetId = wbsSetMatchCostControl.WbsSetId;
|
||||
costControl.CostControlCode = costControlInit.CostControlInitCode;
|
||||
costControl.CostControlName = costControlInit.CostControlInitName;
|
||||
costControl.Unit = costControlInit.Unit;
|
||||
BLL.CostControlService.AddCostControl(costControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gl.IsEnd = true;
|
||||
BLL.Project_InstallationService.UpdateInstallation(gl);
|
||||
Model.Wbs_UnitProject up = BLL.UnitProjectService.GetUnitProjectIdByInstallationId(gl.InstallationId);
|
||||
if (up == null)
|
||||
{
|
||||
// 拷贝总图专业下WBS内容
|
||||
//拷贝单位工程及子单位工程
|
||||
var unitProjectInits = from x in Funs.DB.Wbs_UnitProjectInit where x.CnProfessionId == Const.GLCNProfessionalId orderby x.SuperUnitProject select x;
|
||||
foreach (var unitProjectInit in unitProjectInits)
|
||||
{
|
||||
Model.Wbs_UnitProject unitProject = new Model.Wbs_UnitProject();
|
||||
unitProject.UnitProjectId = SQLHelper.GetNewID(typeof(Model.Wbs_UnitProject));
|
||||
unitProject.UnitProjectCode = unitProjectInit.UnitProjectCode;
|
||||
unitProject.UnitProjectName = unitProjectInit.UnitProjectName;
|
||||
if (unitProjectInit.SuperUnitProject == null)
|
||||
{
|
||||
unitProject.SuperUnitProjectId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
unitProject.SuperUnitProjectId = (from x in Funs.DB.Wbs_UnitProject
|
||||
where x.UnitProjectCode == unitProjectInit.SuperUnitProject && x.InstallationId == gl.InstallationId
|
||||
select x.UnitProjectId).FirstOrDefault();
|
||||
}
|
||||
unitProject.InstallationId = gl.InstallationId;
|
||||
unitProject.ProjectId = project.ProjectId;
|
||||
unitProject.StartDate = project.StartDate;
|
||||
unitProject.EndDate = project.EndDate;
|
||||
unitProject.Remark = unitProjectInit.Remark;
|
||||
unitProject.IsIn = true;
|
||||
BLL.UnitProjectService.AddUnitProject(unitProject);
|
||||
}
|
||||
//拷贝分部/子分部/分项/子分项
|
||||
var wbsSetInits = (from x in Funs.DB.WBS_WbsSetInit where x.CnProfessionId == Const.GLCNProfessionalId orderby x.SuperWbsSetCode select x).ToList();
|
||||
foreach (var wbsSetInit in wbsSetInits)
|
||||
{
|
||||
Model.Wbs_WbsSet wbsSet = new Model.Wbs_WbsSet();
|
||||
wbsSet.WbsSetId = SQLHelper.GetNewID(typeof(Model.Wbs_WbsSet));
|
||||
wbsSet.WbsSetCode = wbsSetInit.WbsSetCode;
|
||||
wbsSet.WbsSetName = wbsSetInit.WbsSetName;
|
||||
wbsSet.InstallationId = gl.InstallationId;
|
||||
wbsSet.UnitProjectId = (from x in Funs.DB.Wbs_UnitProject where x.UnitProjectCode == wbsSetInit.UnitProjectCode && x.InstallationId == gl.InstallationId select x.UnitProjectId).FirstOrDefault();
|
||||
if (wbsSetInit.SuperWbsSetCode == null)
|
||||
{
|
||||
wbsSet.SuperWbsSetId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
wbsSet.SuperWbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetInit.SuperWbsSetCode && x.InstallationId == gl.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
}
|
||||
wbsSet.ProjectId = project.ProjectId;
|
||||
wbsSet.StartDate = project.StartDate;
|
||||
wbsSet.EndDate = project.EndDate;
|
||||
wbsSet.Flag = wbsSetInit.Flag;
|
||||
wbsSet.Way = wbsSetInit.Way;
|
||||
wbsSet.ControlItemDef = wbsSetInit.ControlItemDef;
|
||||
wbsSet.ControlPoint = wbsSetInit.ControlPoint;
|
||||
wbsSet.Remark = wbsSetInit.Remark;
|
||||
wbsSet.IsIn = true;
|
||||
BLL.WbsSetService.AddWbsSet(wbsSet);
|
||||
}
|
||||
var totalCostControlInits = from x in Funs.DB.WBS_CostControlInit orderby x.CostControlInitCode select x;
|
||||
//拷贝费用清单对应关系
|
||||
var wbsSetMatchCostControlInits = from x in Funs.DB.WBS_WbsSetMatchCostControlInit orderby x.WbsSetCode select x;
|
||||
foreach (var wbsSetMatchCostControlInit in wbsSetMatchCostControlInits)
|
||||
{
|
||||
Model.WBS_WbsSetMatchCostControl wbsSetMatchCostControl = new Model.WBS_WbsSetMatchCostControl();
|
||||
wbsSetMatchCostControl.WbsSetMatchCostControlId = SQLHelper.GetNewID();
|
||||
wbsSetMatchCostControl.WbsSetId = (from x in Funs.DB.Wbs_WbsSet
|
||||
where x.WbsSetCode == wbsSetMatchCostControlInit.WbsSetCode && x.InstallationId == gl.InstallationId
|
||||
select x.WbsSetId).FirstOrDefault();
|
||||
wbsSetMatchCostControl.CostControlCode = wbsSetMatchCostControlInit.CostControlInitCode;
|
||||
BLL.WbsSetMatchCostControlService.AddWbsSetMatchCostControl(wbsSetMatchCostControl);
|
||||
//拷贝费用清单项
|
||||
var costControlInits = from x in totalCostControlInits where x.CostControlInitCode == wbsSetMatchCostControlInit.CostControlInitCode orderby x.CostControlInitCode select x;
|
||||
foreach (var costControlInit in costControlInits)
|
||||
{
|
||||
Model.WBS_CostControl costControl = new Model.WBS_CostControl();
|
||||
costControl.ProjectId = project.ProjectId;
|
||||
costControl.WbsSetId = wbsSetMatchCostControl.WbsSetId;
|
||||
costControl.CostControlCode = costControlInit.CostControlInitCode;
|
||||
costControl.CostControlName = costControlInit.CostControlInitName;
|
||||
costControl.Unit = costControlInit.Unit;
|
||||
BLL.CostControlService.AddCostControl(costControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user