344 lines
15 KiB
C#
344 lines
15 KiB
C#
|
using BLL;
|
|||
|
using System;
|
|||
|
|
|||
|
namespace FineUIPro.Web.CQMS.WBS.Control
|
|||
|
{
|
|||
|
public partial class DivisionSubProjectsNewEdit :PageBase
|
|||
|
{
|
|||
|
#region 定义变量
|
|||
|
/// <summary>
|
|||
|
/// 主键
|
|||
|
/// </summary>
|
|||
|
public string DivisionId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["DivisionId"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["DivisionId"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 上级Id
|
|||
|
/// </summary>
|
|||
|
public string ParentId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["ParentId"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["ParentId"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 1-分部,2-分项
|
|||
|
/// </summary>
|
|||
|
public string Type
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["Type"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["Type"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 加载页面
|
|||
|
/// <summary>
|
|||
|
/// 加载页面
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
GetButtonPower();
|
|||
|
this.Type = Request.Params["type"];
|
|||
|
this.DivisionId = Request.Params["DivisionId"];
|
|||
|
this.ParentId = Request.Params["ParentId"];
|
|||
|
if (!string.IsNullOrEmpty(this.ParentId))
|
|||
|
{
|
|||
|
Model.Division_SubProjects subProjects = BLL.SubProjectsService.GetSubProjectsById(this.ParentId);
|
|||
|
if (subProjects != null)
|
|||
|
{
|
|||
|
this.txtBranchEngineeringCode.Text = subProjects.BranchEngineeringCode;
|
|||
|
this.txtBranchEngineeringName.Text = subProjects.BranchEngineeringName;
|
|||
|
|
|||
|
if (this.Type == "1")//子分部工程
|
|||
|
{
|
|||
|
this.txtSubBranchEngineeringName.Required = true;
|
|||
|
this.txtSubBranchEngineeringName.ShowRedStar = true;
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(this.DivisionId))
|
|||
|
{
|
|||
|
var divis = BLL.SubProjectsService.GetSubProjectsById(this.DivisionId);
|
|||
|
if (divis != null)
|
|||
|
{
|
|||
|
this.txtSubBranchEngineeringName.Text = divis.SubBranchEngineeringName;
|
|||
|
this.txtSort.Text = divis.Sort.HasValue ? divis.Sort.ToString() : "";
|
|||
|
this.txtRemark.Text = divis.Remark;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//自动获取排序号
|
|||
|
int sort = BLL.SubProjectsService.GetSubProjectsByProjectId(this.CurrUser.LoginProjectId);
|
|||
|
if (sort > 0)
|
|||
|
{
|
|||
|
this.txtSort.Text = (sort + 1).ToString();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else if (this.Type == "2")//分项工程
|
|||
|
{
|
|||
|
this.txtSubBranchEngineeringName.Required = true;
|
|||
|
this.txtSubBranchEngineeringName.ShowRedStar = true;
|
|||
|
this.txtProEngineeringName.Required = true;
|
|||
|
this.txtProEngineeringName.ShowRedStar = true;
|
|||
|
this.txtProEngineeringCode.Required = true;
|
|||
|
this.txtProEngineeringCode.ShowRedStar = true;
|
|||
|
this.txtProEngineeringNum.Required = true;
|
|||
|
this.txtProEngineeringNum.ShowRedStar = true;
|
|||
|
|
|||
|
var sub = BLL.SubProjectsService.GetSubProjectsById(subProjects.ParentId);
|
|||
|
if (sub != null)
|
|||
|
{
|
|||
|
this.txtBranchEngineeringName.Text = sub.BranchEngineeringName;
|
|||
|
}
|
|||
|
this.txtSubBranchEngineeringName.Text = subProjects.SubBranchEngineeringName;
|
|||
|
if (!string.IsNullOrEmpty(this.DivisionId))
|
|||
|
{
|
|||
|
var divis = BLL.SubProjectsService.GetSubProjectsById(this.DivisionId);
|
|||
|
if (divis != null)
|
|||
|
{
|
|||
|
this.txtProEngineeringName.Text = divis.ProEngineeringName;
|
|||
|
this.txtProEngineeringCode.Text = divis.ProEngineeringCode;
|
|||
|
this.txtProEngineeringNum.Text = divis.ProEngineeringNum;
|
|||
|
this.txtSort.Text = divis.Sort.HasValue ? divis.Sort.ToString() : "";
|
|||
|
this.txtRemark.Text = divis.Remark;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//自动获取排序号
|
|||
|
int sort = BLL.SubProjectsService.GetSubProjectsByProjectId(this.CurrUser.LoginProjectId);
|
|||
|
if (sort > 0)
|
|||
|
{
|
|||
|
this.txtSort.Text = (sort + 1).ToString();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else //分部工程
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(this.DivisionId))
|
|||
|
{
|
|||
|
Model.Division_SubProjects subProjects = BLL.SubProjectsService.GetSubProjectsById(this.DivisionId);
|
|||
|
if (subProjects != null)
|
|||
|
{
|
|||
|
this.txtBranchEngineeringCode.Text = subProjects.BranchEngineeringCode;
|
|||
|
this.txtBranchEngineeringName.Text = subProjects.BranchEngineeringName;
|
|||
|
this.txtRemark.Text = subProjects.Remark;
|
|||
|
this.txtSort.Text = subProjects.Sort.HasValue ? subProjects.Sort.ToString() : "";
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//自动获取排序号
|
|||
|
int sort = BLL.SubProjectsService.GetSubProjectsByProjectId(this.CurrUser.LoginProjectId);
|
|||
|
if (sort > 0)
|
|||
|
{
|
|||
|
this.txtSort.Text = (sort + 1).ToString();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.txtSort.Text = "1";
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(this.ParentId))
|
|||
|
{
|
|||
|
this.txtBranchEngineeringCode.Readonly = true;
|
|||
|
this.txtBranchEngineeringName.Readonly = true;
|
|||
|
if (this.Type == "1")//子分部工程
|
|||
|
{
|
|||
|
this.Panel1.Hidden = true;
|
|||
|
this.childBra.Hidden = false;
|
|||
|
}
|
|||
|
else if (this.Type == "2")//分项工程
|
|||
|
{
|
|||
|
var pare = BLL.SubProjectsService.GetSubProjectsById(this.ParentId);
|
|||
|
if (pare != null)
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(pare.ParentId))
|
|||
|
{
|
|||
|
this.childBra.Hidden = false;
|
|||
|
this.txtSubBranchEngineeringName.Readonly = true;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.childBra.Hidden = true;
|
|||
|
}
|
|||
|
}
|
|||
|
this.Panel1.Hidden = false;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.Panel1.Hidden = true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 保存
|
|||
|
/// <summary>
|
|||
|
/// 保存按钮
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnSave_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Model.Division_SubProjects newSubProjects = new Model.Division_SubProjects();
|
|||
|
newSubProjects.ProjectId = this.CurrUser.LoginProjectId;
|
|||
|
newSubProjects.BranchEngineeringCode = this.txtBranchEngineeringCode.Text.Trim();
|
|||
|
newSubProjects.Remark = this.txtRemark.Text.Trim();
|
|||
|
newSubProjects.AddUser = this.CurrUser.UserId;
|
|||
|
newSubProjects.OperateTime = DateTime.Now;
|
|||
|
newSubProjects.Sort = Funs.GetNewInt(this.txtSort.Text.Trim());
|
|||
|
if (!string.IsNullOrEmpty(this.ParentId))
|
|||
|
{
|
|||
|
newSubProjects.ParentId = this.ParentId;
|
|||
|
if (this.Type == "1")//子分部工程
|
|||
|
{
|
|||
|
newSubProjects.SubBranchEngineeringName = this.txtSubBranchEngineeringName.Text.Trim();
|
|||
|
if (!string.IsNullOrEmpty(this.DivisionId))
|
|||
|
{
|
|||
|
var div = BLL.SubProjectsService.GetSubProjectsById(this.DivisionId);
|
|||
|
if(div!=null)
|
|||
|
{
|
|||
|
newSubProjects.DivisionLevel = div.DivisionLevel;
|
|||
|
}
|
|||
|
newSubProjects.DivisionId = this.DivisionId;
|
|||
|
BLL.SubProjectsService.UpdateSubProjects(newSubProjects);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var sub = BLL.SubProjectsService.GetSubProjectsById(this.ParentId);
|
|||
|
if (sub.DivisionLevel == 1)
|
|||
|
{
|
|||
|
newSubProjects.DivisionLevel = 2;
|
|||
|
}
|
|||
|
newSubProjects.ProEngineeringName = this.txtProEngineeringName.Text.Trim();
|
|||
|
newSubProjects.DivisionId = SQLHelper.GetNewID(typeof(Model.Division_SubProjects));
|
|||
|
this.DivisionId = newSubProjects.DivisionId;
|
|||
|
BLL.SubProjectsService.AddSubProjects(newSubProjects);
|
|||
|
}
|
|||
|
}
|
|||
|
else if (this.Type == "2")//分项工程
|
|||
|
{
|
|||
|
newSubProjects.ProEngineeringName = this.txtProEngineeringName.Text.Trim();
|
|||
|
newSubProjects.ProEngineeringCode = this.txtProEngineeringCode.Text.Trim();
|
|||
|
newSubProjects.ProEngineeringNum = this.txtProEngineeringNum.Text.Trim();
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(this.DivisionId))
|
|||
|
{
|
|||
|
var div = BLL.SubProjectsService.GetSubProjectsById(this.DivisionId);
|
|||
|
if (div != null)
|
|||
|
{
|
|||
|
newSubProjects.DivisionLevel = div.DivisionLevel;
|
|||
|
}
|
|||
|
newSubProjects.DivisionId = this.DivisionId;
|
|||
|
BLL.SubProjectsService.UpdateSubProjects(newSubProjects);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var sub = BLL.SubProjectsService.GetSubProjectsById(this.ParentId);
|
|||
|
if (sub.DivisionLevel == 1)
|
|||
|
{
|
|||
|
newSubProjects.DivisionLevel = 2;
|
|||
|
}
|
|||
|
else if (sub.DivisionLevel==2)
|
|||
|
{
|
|||
|
newSubProjects.DivisionLevel = 3;
|
|||
|
}
|
|||
|
newSubProjects.DivisionId = SQLHelper.GetNewID(typeof(Model.Division_SubProjects));
|
|||
|
this.DivisionId = newSubProjects.DivisionId;
|
|||
|
BLL.SubProjectsService.AddSubProjects(newSubProjects);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else //分部工程
|
|||
|
{
|
|||
|
newSubProjects.BranchEngineeringName = this.txtBranchEngineeringName.Text.Trim();
|
|||
|
newSubProjects.DivisionLevel = 1;
|
|||
|
newSubProjects.ProEngineeringCode = "00";
|
|||
|
newSubProjects.ProEngineeringNum = newSubProjects.BranchEngineeringCode + "00";
|
|||
|
if (!string.IsNullOrEmpty(this.DivisionId))
|
|||
|
{
|
|||
|
newSubProjects.DivisionId = this.DivisionId;
|
|||
|
BLL.SubProjectsService.UpdateSubProjects(newSubProjects);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
newSubProjects.DivisionId = SQLHelper.GetNewID(typeof(Model.Division_SubProjects));
|
|||
|
this.DivisionId = newSubProjects.DivisionId;
|
|||
|
BLL.SubProjectsService.AddSubProjects(newSubProjects);
|
|||
|
}
|
|||
|
}
|
|||
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|||
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 分项工程编号触发事件
|
|||
|
/// <summary>
|
|||
|
/// 分项工程编号触发事件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void txtProEngineeringCode_TextChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
this.txtProEngineeringNum.Text = string.Empty;
|
|||
|
if (!string.IsNullOrEmpty(this.txtBranchEngineeringCode.Text.Trim())&&!string.IsNullOrEmpty(this.txtProEngineeringCode.Text.Trim()))
|
|||
|
{
|
|||
|
this.txtProEngineeringNum.Text = this.txtBranchEngineeringCode.Text.Trim() + this.txtProEngineeringCode.Text.Trim();
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 获取按钮权限
|
|||
|
/// <summary>
|
|||
|
/// 获取按钮权限
|
|||
|
/// </summary>
|
|||
|
/// <param name="button"></param>
|
|||
|
/// <returns></returns>
|
|||
|
private void GetButtonPower()
|
|||
|
{
|
|||
|
if (Request.Params["value"] == "0")
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.DivisionSubProjectsMenuId);
|
|||
|
if (buttonList.Count > 0)
|
|||
|
{
|
|||
|
if (buttonList.Contains(BLL.Const.BtnSave))
|
|||
|
{
|
|||
|
this.btnSave.Hidden = false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|