CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/ProjectData/ProjectSetSave.aspx.cs

1676 lines
100 KiB
C#

using BLL;
using Model;
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
namespace FineUIPro.Web.ProjectData
{
public partial class ProjectSetSave : PageBase
{
/// <summary>
/// 定义项
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
ProjectTypeService.InitProjectTypeDropDownList(this.drpProjectType, true);
CountryService.InitCountryDropDownList(this.drpCountry, true);
Funs.FineUIPleaseSelect(this.drpProvince);
this.ProjectId = Request.QueryString["ProjectId"];
if (string.IsNullOrEmpty(this.ProjectId))
{
this.ProjectId = this.CurrUser.LoginProjectId;
}
///项目经理
UserService.InitUserDropDownList(this.drpProjectManager, string.Empty, true);
///施工经理
UserService.InitUserDropDownList(this.drpConstructionManager, string.Empty, true);
///安全经理
UserService.InitUserDropDownList(this.drpHSSEManager, string.Empty, true);
///质量经理
UserService.InitUserDropDownList(this.drpQAManager, string.Empty, true);
///开车经理
UserService.InitUserDropDownList(this.drpDriveManager, string.Empty, true);
UnitService.InitBranchUnitDropDownList(this.drpUnit, true, true);
ConstValue.InitConstValueDropDownList(this.drpProjectState2, ConstValue.GroupId_ProjectState, true);
this.drpUnit.SelectedValue = Const.UnitId_CWCEC;
if (!String.IsNullOrEmpty(this.ProjectId))
{
var project = BLL.ProjectService.GetProjectByProjectId(this.ProjectId);
if (project != null)
{
this.txtProjectCode.Text = project.ProjectCode;
this.txtJTProjectCode.Text = project.JTProjectCode;
this.txtProjectName.Text = project.ProjectName;
this.txtProjectAddress.Text = project.ProjectAddress;
this.txtWorkRange.Text = project.WorkRange;
this.txtContractNo.Text = project.ContractNo;
this.txtRemark.Text = project.Remark;
if (project.Duration != null)
{
this.txtDuration.Text = project.Duration.ToString();
}
if (project.StartDate.HasValue)
{
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", project.StartDate);
}
if (project.EndDate.HasValue)
{
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", project.EndDate);
}
this.txtShortName.Text = project.ShortName;
if (!string.IsNullOrEmpty(project.ProjectType))
{
this.drpProjectType.SelectedValue = project.ProjectType;
}
var getPUser = Funs.DB.Project_ProjectUser.Where(x => x.ProjectId == this.ProjectId);
if (getPUser.Count() > 0)
{
///项目经理
var m = getPUser.FirstOrDefault(x => x.RoleId.Contains(BLL.Const.ProjectManager));
if (m != null)
{
this.drpProjectManager.SelectedValue = m.UserId;
}
///施工经理
var c = getPUser.FirstOrDefault(x => x.RoleId.Contains(BLL.Const.ConstructionManager));
if (c != null)
{
this.drpConstructionManager.SelectedValue = c.UserId;
}
////安全经理
var h = getPUser.FirstOrDefault(x => x.RoleId.Contains(BLL.Const.HSSEManager));
if (h != null)
{
this.drpHSSEManager.SelectedValue = h.UserId;
}
////质量经理
var qa = getPUser.FirstOrDefault(x => x.RoleId.Contains(BLL.Const.QAManager));
if (qa != null)
{
this.drpQAManager.SelectedValue = qa.UserId;
}
////开车经理
var Drive = getPUser.FirstOrDefault(x => x.RoleId.Contains(BLL.Const.DriveManager));
if (Drive != null)
{
this.drpDriveManager.SelectedValue = Drive.UserId;
}
}
this.drpProjectState.SelectedValue = project.ProjectState;
if (!string.IsNullOrEmpty(project.ProjectState2))
{
this.drpProjectState2.SelectedValue = project.ProjectState2;
}
//if (project.ProjectState == BLL.Const.ProjectState_2)
//{
// this.txtProjectState.Text = "暂停中";
//}
//else if (project.ProjectState == BLL.Const.ProjectState_3)
//{
// this.txtProjectState.Text = "已完工";
//}
//else
//{
// this.txtProjectState.Text = "施工中";
//}
if (!string.IsNullOrEmpty(project.UnitId))
{
this.drpUnit.SelectedValue = project.UnitId;
}
this.ckIsUpTotalMonth.Checked = project.IsUpTotalMonth.Value;
if (project.IsForeign == true)
{
this.ckbIsForeign.Checked = true;
}
this.txtMapCoordinates.Text = project.MapCoordinates;
this.txtProjectMoney.Text = project.ProjectMoney.ToString();
this.txtConstructionMoney.Text = project.ConstructionMoney.ToString();
this.txtTelephone.Text = project.Telephone;
if (!string.IsNullOrEmpty(project.Country))
{
this.drpCountry.SelectedValue = project.Country;
this.drpProvince.Items.Clear();
CityService.InitCityDropDownList(this.drpProvince, this.drpCountry.SelectedValue, true);
if (!string.IsNullOrEmpty(project.Province))
{
this.drpProvince.SelectedValue = project.Province;
}
}
this.txtCity.Text = project.City;
this.txtEnglishRemark.Text = project.EnglishRemark;
this.txtHJProjectCode.Text = project.HJProjectCode;
this.txtKZProjectCode.Text = project.KZProjectCode;
if (project.Progress != null)
{
this.txtProgress.Text = project.Progress.ToString();
}
}
}
}
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
SaveData();
}
private void SaveData()
{
Base_Project project = new Base_Project
{
ProjectCode = this.txtProjectCode.Text.Trim(),
JTProjectCode = this.txtJTProjectCode.Text.Trim(),
ProjectName = Regex.Replace(this.txtProjectName.Text, @"\s", ""),
ProjectAddress = this.txtProjectAddress.Text.Trim(),
WorkRange = this.txtWorkRange.Text.Trim(),
ContractNo = this.txtContractNo.Text.Trim(),
Duration = Funs.GetNewDecimal(this.txtDuration.Text.Trim()),
MapCoordinates = this.txtMapCoordinates.Text.Trim(),
ProjectState = this.drpProjectState.SelectedValue,
ProjectMoney = Funs.GetNewDecimal(this.txtProjectMoney.Text),
ConstructionMoney = Funs.GetNewDecimal(this.txtConstructionMoney.Text),
Remark = this.txtRemark.Text.Trim(),
Telephone = this.txtTelephone.Text.Trim(),
HJProjectCode = this.txtHJProjectCode.Text.Trim(),
KZProjectCode = this.txtKZProjectCode.Text.Trim(),
City = this.txtCity.Text.Trim(),
EnglishRemark = this.txtEnglishRemark.Text.Trim(),
Progress = Funs.GetNewDecimal(this.txtProgress.Text),
};
if (string.IsNullOrEmpty(project.JTProjectCode))
{
project.JTProjectCode = project.ProjectCode;
}
//Country = this.txtCountry.Text.Trim(),
/// Province = this.drpProvince.SelectedValue,
if (this.drpCountry.SelectedValue != Const._Null)
{
project.Country = this.drpCountry.SelectedValue;
}
if (this.drpProvince.SelectedValue != Const._Null && !string.IsNullOrEmpty(this.drpProvince.SelectedValue))
{
project.Province = this.drpProvince.SelectedValue;
}
if (!string.IsNullOrEmpty(txtStartDate.Text.Trim()))
{
project.StartDate = Funs.GetNewDateTime(this.txtStartDate.Text.Trim());
}
if (!string.IsNullOrEmpty(txtEndDate.Text.Trim()))
{
project.EndDate = Funs.GetNewDateTime(this.txtEndDate.Text.Trim());
}
project.ShortName = this.txtShortName.Text.Trim();
if (this.drpProjectType.SelectedValue != BLL.Const._Null)
{
project.ProjectType = this.drpProjectType.SelectedValue;
}
if (this.drpUnit.SelectedValue != BLL.Const._Null)
{
project.UnitId = this.drpUnit.SelectedValue;
}
if (this.drpProjectState2.SelectedValue != BLL.Const._Null)
{
project.ProjectState2 = this.drpProjectState2.SelectedValue;
}
//project.PostCode = this.txtPostCode.Text.Trim();
project.IsUpTotalMonth = Convert.ToBoolean(this.ckIsUpTotalMonth.Checked);
project.IsForeign = Convert.ToBoolean(this.ckbIsForeign.Checked);
if (String.IsNullOrEmpty(this.ProjectId))
{
project.ProjectId = SQLHelper.GetNewID(typeof(Model.Base_Project));
project.ProjectState = BLL.Const.ProjectState_1;
this.ProjectId = project.ProjectId;
ProjectService.AddProject(project);
// 初始化焊接环境变量设置
BLL.Project_SysSetService.InsertHjglInit(project.ProjectId);
LogService.AddSys_Log(this.CurrUser, project.ProjectCode, project.ProjectId, BLL.Const.ProjectSetMenuId,
BLL.Const.BtnAdd);
}
else
{
var getProject = BLL.ProjectService.GetProjectByProjectId(this.ProjectId);
if (getProject != null)
{
project.FromProjectId = getProject.FromProjectId;
}
project.ProjectId = this.ProjectId;
ProjectService.UpdateProject(project);
LogService.AddSys_Log(this.CurrUser, project.ProjectCode, project.ProjectId, BLL.Const.ProjectSetMenuId,
BLL.Const.BtnModify);
}
this.SetProjectManager(project.ProjectId); /// 设置项目、施工、安全经理
this.InsertDataTypeToProject(project.ProjectId); ////初始化资料类别数据
this.InsertConstructionStandardListToProject(project.ProjectId); ////初始化项目标准规范清单
this.InsertITPListProject(project.ProjectId); // 初始化ITP列表
//this.InsertAC(project); //初始化防腐绝热
//this.InsertGE(project); //初始化地勘
//this.InsertUP(project); //初始化全厂地下主管网
//this.InsertTF(project); //初始化临时设施
//this.InsertGL(project); //初始化总图
ShowNotify("保存数据成功!", MessageBoxIcon.Success);
// 2. 关闭本窗体,然后刷新父窗体
// PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
// 2. 关闭本窗体,然后回发父窗体
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
//PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(wedId) + ActiveWindow.GetHideReference());
}
#region id增加资料类别初始化数据
/// <summary>
/// 根据新增项目id增加资料类别初始化数据
/// </summary>
/// <param name="projectId"></param>
private void InsertDataTypeToProject(string projectId)
{
var dataTypeProject = Funs.DB.DataBase_DataTypeProject.FirstOrDefault(x => x.ProjectId == projectId);
if (dataTypeProject == null) //项目还未拷贝资料库数据
{
////增加到项目一级类别
var dataType1 = from x in Funs.DB.DataBase_DataType where x.SuperDataTypeId == "0" select x;
foreach (var d1 in dataType1)
{
if (d1.SuperDataTypeId != Const.DataTypeNewConstructId && d1.DataTypeId != Const.DataTypeConstructId)
{
Model.DataBase_DataTypeProject newDataTypeProject = new Model.DataBase_DataTypeProject();
newDataTypeProject.DataTypeProjectId = SQLHelper.GetNewID(typeof(Model.DataBase_DataTypeProject));
newDataTypeProject.ProjectId = projectId;
newDataTypeProject.DataTypeCode = d1.DataTypeCode;
newDataTypeProject.DataTypeName = d1.DataTypeName;
newDataTypeProject.SuperDataTypeId = "0";
newDataTypeProject.SortIndex = d1.SortIndex;
newDataTypeProject.Pages = d1.Pages;
newDataTypeProject.Remark = d1.Remark;
newDataTypeProject.IsRelatedWBS = d1.IsRelatedWBS;
newDataTypeProject.SourceDataTypeId = d1.DataTypeId;
BLL.DataTypeProjectService.AddDataTypeProject(newDataTypeProject);
List<Model.DataBase_DataType> dataType2 = (from x in Funs.DB.DataBase_DataType where x.SuperDataTypeId == d1.DataTypeId select x).ToList();
if (dataType2.Count() > 0)
{
this.InsertDataTypeDetail(dataType2, newDataTypeProject.DataTypeProjectId, projectId);
}
}
}
}
}
/// <summary>
/// 循环拷贝子级类别
/// </summary>
/// <param name="dataTypes"></param>
private void InsertDataTypeDetail(List<Model.DataBase_DataType> dataTypes, string superDataTypeId, string projectId)
{
foreach (var d in dataTypes)
{
if (d.SuperDataTypeId != Const.DataTypeNewConstructId && d.DataTypeId != Const.DataTypeConstructId)
{
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;
BLL.DataTypeProjectService.AddDataTypeProject(newDataTypeProject);
List<Model.DataBase_DataType> childDataTypes = BLL.DataTypeService.GetDataTypesBySuperDataTypeId(d.DataTypeId);
if (childDataTypes.Count > 0)
{
InsertDataTypeDetail(childDataTypes, newDataTypeProject.DataTypeProjectId, projectId);
}
}
}
}
#endregion
#region
/// <summary>
/// 验证项目名称、项目编号是否存在
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TextBox_TextChanged(object sender, EventArgs e)
{
var q = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectCode == this.txtProjectCode.Text.Trim() && (x.ProjectId != this.ProjectId || (this.ProjectId == null && x.ProjectId != null)));
if (q != null)
{
ShowNotify("输入的项目编号已存在!", MessageBoxIcon.Warning);
}
var q2 = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectName == this.txtProjectName.Text.Trim() && (x.ProjectId != this.ProjectId || (this.ProjectId == null && x.ProjectId != null)));
if (q2 != null)
{
ShowNotify("输入的项目名称已存在!", MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
/// 设置项目、施工、安全经理
/// </summary>
/// <param name="projectId"></param>
private void SetProjectManager(string projectId)
{
string newProjectManager = this.drpProjectManager.SelectedValue;
string newConstructionManager = this.drpConstructionManager.SelectedValue;
string newHSSEManager = this.drpHSSEManager.SelectedValue;
string newQAManager = this.drpQAManager.SelectedValue;
string newDriveManager = this.drpDriveManager.SelectedValue;
var project = BLL.ProjectService.GetProjectByProjectId(projectId);
if (project != null)
{
string OldProjectManager = string.Empty; ////项目经理
var m = Funs.DB.Project_ProjectUser.FirstOrDefault(x => x.ProjectId == projectId && x.RoleId.Contains(BLL.Const.ProjectManager));
if (m != null)
{
OldProjectManager = m.UserId;
}
////此人不在项目中
if (!string.IsNullOrEmpty(newProjectManager) && newProjectManager != Const._Null && newProjectManager != OldProjectManager)
{
BLL.ProjectUserService.DeleteProjectUserByProjectIdUserId(projectId, newProjectManager);
BLL.ProjectUserService.DeleteProjectUserByProjectIdUserId(projectId, OldProjectManager);
var user = BLL.UserService.GetUserByUserId(newProjectManager);
if (user != null && !string.IsNullOrEmpty(user.UnitId))
{
var punit = BLL.ProjectUnitService.GetProjectUnitByUnitIdProjectId(projectId, user.UnitId);
if (punit == null) ///项目单位为空时要增加项目单位
{
Model.Project_ProjectUnit newProjectUnit = new Project_ProjectUnit
{
ProjectId = projectId,
UnitId = user.UnitId,
InTime = System.DateTime.Now
};
BLL.ProjectUnitService.AddProjectUnit(newProjectUnit);
}
Model.Project_ProjectUser newProjectUser = new Model.Project_ProjectUser
{
ProjectId = projectId,
UserId = newProjectManager,
UnitId = user.UnitId,
RoleId = BLL.Const.ProjectManager,
IsPost = true
};
BLL.ProjectUserService.AddProjectUser(newProjectUser);
}
}
////施工经理
string OldConstructionManager = string.Empty;
var c = Funs.DB.Project_ProjectUser.FirstOrDefault(x => x.ProjectId == projectId && x.RoleId.Contains(BLL.Const.ConstructionManager));
if (c != null)
{
OldConstructionManager = c.UserId;
}
////此人不在项目中
if (!string.IsNullOrEmpty(newConstructionManager) && newConstructionManager != Const._Null && newConstructionManager != BLL.Const._Null && newConstructionManager != OldConstructionManager)
{
BLL.ProjectUserService.DeleteProjectUserByProjectIdUserId(projectId, newConstructionManager);
BLL.ProjectUserService.DeleteProjectUserByProjectIdUserId(projectId, OldConstructionManager);
var user = BLL.UserService.GetUserByUserId(newConstructionManager);
if (user != null && !string.IsNullOrEmpty(user.UnitId))
{
var punit = BLL.ProjectUnitService.GetProjectUnitByUnitIdProjectId(projectId, user.UnitId);
if (punit == null) ///项目单位为空时要增加项目单位
{
Model.Project_ProjectUnit newProjectUnit = new Project_ProjectUnit
{
ProjectId = projectId,
UnitId = user.UnitId,
InTime = System.DateTime.Now
};
BLL.ProjectUnitService.AddProjectUnit(newProjectUnit);
}
Model.Project_ProjectUser newProjectUser = new Model.Project_ProjectUser
{
ProjectId = projectId,
UserId = newConstructionManager,
UnitId = user.UnitId,
RoleId = BLL.Const.ConstructionManager,
IsPost = true
};
BLL.ProjectUserService.AddProjectUser(newProjectUser);
}
}
///安全经理
string OldHSSEManager = string.Empty;
var h = Funs.DB.Project_ProjectUser.FirstOrDefault(x => x.ProjectId == projectId && x.RoleId.Contains(BLL.Const.HSSEManager));
if (h != null)
{
OldHSSEManager = h.UserId;
}
////此人不在项目中
if (!string.IsNullOrEmpty(newHSSEManager) && newHSSEManager != BLL.Const._Null && newHSSEManager != OldHSSEManager)
{
BLL.ProjectUserService.DeleteProjectUserByProjectIdUserId(projectId, newHSSEManager);
BLL.ProjectUserService.DeleteProjectUserByProjectIdUserId(projectId, OldHSSEManager);
var user = BLL.UserService.GetUserByUserId(newHSSEManager);
if (user != null && !string.IsNullOrEmpty(user.UnitId))
{
var punit = BLL.ProjectUnitService.GetProjectUnitByUnitIdProjectId(projectId, user.UnitId);
if (punit == null) ///项目单位为空时要增加项目单位
{
Model.Project_ProjectUnit newProjectUnit = new Project_ProjectUnit
{
ProjectId = projectId,
UnitId = user.UnitId,
InTime = System.DateTime.Now
};
BLL.ProjectUnitService.AddProjectUnit(newProjectUnit);
}
Model.Project_ProjectUser newProjectUser = new Model.Project_ProjectUser
{
ProjectId = projectId,
UserId = newHSSEManager,
UnitId = user.UnitId,
RoleId = BLL.Const.HSSEManager,
IsPost = true
};
BLL.ProjectUserService.AddProjectUser(newProjectUser);
}
}
///质量经理
string OldQAManager = string.Empty;
var qa = Funs.DB.Project_ProjectUser.FirstOrDefault(x => x.ProjectId == projectId && x.RoleId.Contains(BLL.Const.QAManager));
if (qa != null)
{
OldQAManager = qa.UserId;
}
////此人不在项目中
if (!string.IsNullOrEmpty(newQAManager) && newQAManager != BLL.Const._Null && newQAManager != OldQAManager)
{
BLL.ProjectUserService.DeleteProjectUserByProjectIdUserId(projectId, newQAManager);
BLL.ProjectUserService.DeleteProjectUserByProjectIdUserId(projectId, OldQAManager);
var user = BLL.UserService.GetUserByUserId(newQAManager);
if (user != null && !string.IsNullOrEmpty(user.UnitId))
{
var punit = BLL.ProjectUnitService.GetProjectUnitByUnitIdProjectId(projectId, user.UnitId);
if (punit == null) ///项目单位为空时要增加项目单位
{
Model.Project_ProjectUnit newProjectUnit = new Project_ProjectUnit
{
ProjectId = projectId,
UnitId = user.UnitId,
InTime = System.DateTime.Now
};
BLL.ProjectUnitService.AddProjectUnit(newProjectUnit);
}
Model.Project_ProjectUser newProjectUser = new Model.Project_ProjectUser
{
ProjectId = projectId,
UserId = newQAManager,
UnitId = user.UnitId,
RoleId = BLL.Const.QAManager,
IsPost = true
};
BLL.ProjectUserService.AddProjectUser(newProjectUser);
}
}
///开车经理
string OldDriveManager = string.Empty;
var Drive = Funs.DB.Project_ProjectUser.FirstOrDefault(x => x.ProjectId == projectId && x.RoleId.Contains(BLL.Const.DriveManager));
if (Drive != null)
{
OldDriveManager = Drive.UserId;
}
////此人不在项目中
if (!string.IsNullOrEmpty(newDriveManager) && newDriveManager != BLL.Const._Null && newDriveManager != OldDriveManager)
{
BLL.ProjectUserService.DeleteProjectUserByProjectIdUserId(projectId, newDriveManager);
BLL.ProjectUserService.DeleteProjectUserByProjectIdUserId(projectId, OldDriveManager);
var user = BLL.UserService.GetUserByUserId(newDriveManager);
if (user != null && !string.IsNullOrEmpty(user.UnitId))
{
var punit = BLL.ProjectUnitService.GetProjectUnitByUnitIdProjectId(projectId, user.UnitId);
if (punit == null) ///项目单位为空时要增加项目单位
{
Model.Project_ProjectUnit newProjectUnit = new Project_ProjectUnit
{
ProjectId = projectId,
UnitId = user.UnitId,
InTime = System.DateTime.Now
};
BLL.ProjectUnitService.AddProjectUnit(newProjectUnit);
}
Model.Project_ProjectUser newProjectUser = new Model.Project_ProjectUser
{
ProjectId = projectId,
UserId = newDriveManager,
UnitId = user.UnitId,
RoleId = BLL.Const.DriveManager,
IsPost = true
};
BLL.ProjectUserService.AddProjectUser(newProjectUser);
}
}
}
}
#endregion
#region id增加标准规范清单初始化数据
/// <summary>
/// 根据新增项目id增加标准规范清单初始化数据
/// </summary>
/// <param name="projectId"></param>
private void InsertConstructionStandardListToProject(string projectId)
{
var constructionStandardListProject = Funs.DB.CQMS_Law_ConstructionStandardListProject.FirstOrDefault(x => x.ProjectId == projectId);
if (constructionStandardListProject == null) //项目还未拷贝标准规范清单数据
{
////增加到项目一级类别
var constructionStandardLists = from x in Funs.DB.CQMS_Law_ConstructionStandardList select x;
foreach (var c in constructionStandardLists)
{
Model.CQMS_Law_ConstructionStandardListProject newConstructionStandardListProject = new Model.CQMS_Law_ConstructionStandardListProject();
newConstructionStandardListProject.StandardCode = c.StandardCode;
newConstructionStandardListProject.ProjectId = projectId;
newConstructionStandardListProject.StandardGrade = c.StandardGrade;
newConstructionStandardListProject.StandardNo = c.StandardNo;
newConstructionStandardListProject.StandardName = c.StandardName;
newConstructionStandardListProject.AttachUrl = c.AttachUrl;
newConstructionStandardListProject.StandardType = c.StandardType;
newConstructionStandardListProject.Memo = c.Memo;
newConstructionStandardListProject.PubDate = c.PubDate;
newConstructionStandardListProject.ImpDate = c.ImpDate;
newConstructionStandardListProject.UseLevel = c.UseLevel;
newConstructionStandardListProject.Status = c.Status;
newConstructionStandardListProject.ReplaceStandard = c.ReplaceStandard;
newConstructionStandardListProject.IsSelected1 = c.IsSelected1;
newConstructionStandardListProject.IsSelected2 = c.IsSelected2;
newConstructionStandardListProject.IsSelected3 = c.IsSelected3;
newConstructionStandardListProject.IsSelected4 = c.IsSelected4;
newConstructionStandardListProject.IsSelected5 = c.IsSelected5;
newConstructionStandardListProject.IsSelected6 = c.IsSelected6;
newConstructionStandardListProject.IsSelected7 = c.IsSelected7;
newConstructionStandardListProject.IsSelected8 = c.IsSelected8;
newConstructionStandardListProject.IsSelected9 = c.IsSelected9;
newConstructionStandardListProject.IsSelected10 = c.IsSelected10;
BLL.ConstructionStandardListProjectService.AddConstructionStandardListProject(newConstructionStandardListProject);
}
}
}
#endregion
#region ITP信息
/// <summary>
/// 添加ITP信息
/// </summary>
/// <param name="iTP"></param>
private void InsertITPListProject(string projectId)
{
var ITPListProject = Funs.DB.CQMS_Foreign_ITPListProject.FirstOrDefault(x => x.ProjectId == projectId);
if (ITPListProject == null) //项目还未拷贝ITP数据
{
string strSql = @"insert into dbo.CQMS_Foreign_ITPListProject(ITPListId,ProjectId,Name,AttachUrl,CompileMan,CompileDate)
select NEWID(),'" + projectId + "',ITPName,'',CompileMan,CompileDate from dbo.CQMS_Foreign_ITPList";
BLL.SQLHelper.ExecutSql(strSql);
}
}
#endregion
#region
private void InsertAC(Model.Base_Project project)
{
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 = "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 == 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 == 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.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 = 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
{
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
protected void txtStartDate_Blur(object sender, EventArgs e)
{
var sDate = Funs.GetNewDateTime(this.txtStartDate.Text);
var eDate = Funs.GetNewDateTime(this.txtEndDate.Text);
if (sDate.HasValue && eDate.HasValue && eDate.Value > sDate.Value)
{
int m1 = sDate.Value.Year * 12 + sDate.Value.Month;
int m2 = eDate.Value.Year * 12 + eDate.Value.Month;
int a = m2 - m1;
TimeSpan ts1 = new TimeSpan(sDate.Value.Ticks);
TimeSpan ts2 = new TimeSpan(eDate.Value.AddMonths(0 - a).Ticks);
TimeSpan ts = ts1.Subtract(ts2).Duration();
this.txtDuration.Text = (Math.Round((ts.Days * 1.0 / 30), 1) + a).ToString();
}
}
protected void drpCountry_SelectedIndexChanged(object sender, EventArgs e)
{
this.drpProvince.Items.Clear();
CityService.InitCityDropDownList(this.drpProvince, this.drpCountry.SelectedValue, true);
}
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(ProjectId))
{
SaveData();
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/ProjectAttachUrl&menuId={1}", this.ProjectId, BLL.Const.ProjectSetMenuId)));
}
}
}