tj
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using BLL;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
@@ -7,11 +9,214 @@ using System.Web.UI.WebControls;
|
||||
|
||||
namespace FineUIPro.Web.CQMS.WBS.Control
|
||||
{
|
||||
public partial class DivisionSubProjectsEdit : System.Web.UI.Page
|
||||
public partial class DivisionSubProjectsEdit : PageBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 上级主键
|
||||
/// </summary>
|
||||
public string ParentId
|
||||
{
|
||||
get { return (string)ViewState["ParentId"]; }
|
||||
set { ViewState["ParentId"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
public string DivisionId
|
||||
{
|
||||
get { return (string)ViewState["DivisionId"]; }
|
||||
set { ViewState["DivisionId"] = value; }
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.DivisionId = Request.Params["DivisionId"];
|
||||
this.ParentId = Request.Params["ParentId"];
|
||||
//绑定数据
|
||||
PageIn();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定数据
|
||||
/// </summary>
|
||||
/// <param name="runId">主键</param>
|
||||
/// <param name="parentId">上级主键</param>
|
||||
public void PageIn()
|
||||
{
|
||||
var num = 0;
|
||||
if (!string.IsNullOrWhiteSpace(this.ParentId))
|
||||
{
|
||||
var parenLs = GetAllCropping(this.ParentId);
|
||||
if (parenLs.Count > 0)
|
||||
{
|
||||
var itemModel = parenLs.FirstOrDefault(p => p.DivisionId == this.ParentId);
|
||||
if (itemModel != null)
|
||||
{
|
||||
if (itemModel.DivisionLevel == 1)
|
||||
{
|
||||
one.Hidden = false;
|
||||
var oneModel = parenLs.FirstOrDefault(p => p.DivisionLevel == 1);
|
||||
if (oneModel != null)
|
||||
{
|
||||
txtBranchEngineeringCode.Text = oneModel.BranchEngineeringCode;
|
||||
txtBranchEngineeringName.Text = oneModel.BranchEngineeringName;
|
||||
if (string.IsNullOrWhiteSpace(this.DivisionId))
|
||||
{
|
||||
num = Funs.DB.Division_SubProjects.Count() + 1;
|
||||
txtSort.Text = num.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (itemModel.DivisionLevel == 2)
|
||||
{
|
||||
one.Hidden = false;
|
||||
two.Hidden = false;
|
||||
var oneModel = parenLs.FirstOrDefault(p => p.DivisionLevel == 1);
|
||||
if (oneModel != null)
|
||||
{
|
||||
txtBranchEngineeringCode.Text = oneModel.BranchEngineeringCode;
|
||||
txtBranchEngineeringName.Text = oneModel.BranchEngineeringName;
|
||||
}
|
||||
var twoModel = parenLs.FirstOrDefault(p => p.DivisionLevel == 2);
|
||||
if (twoModel != null)
|
||||
{
|
||||
txtSubBranchEngineeringName.Text = twoModel.SubBranchEngineeringName;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(this.DivisionId))
|
||||
{
|
||||
num = Funs.DB.Division_SubProjects.Count() + 1;
|
||||
txtSort.Text = num.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(this.DivisionId))
|
||||
{
|
||||
num = Funs.DB.Division_SubProjects.Count() + 1;
|
||||
txtSort.Text = num.ToString();
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(this.DivisionId))
|
||||
{
|
||||
var itemModel = Funs.DB.Division_SubProjects.FirstOrDefault(p => p.DivisionId == this.DivisionId);
|
||||
if (itemModel != null)
|
||||
{
|
||||
txtRemark.Text = itemModel.Remark;
|
||||
txtSort.Text = itemModel.Sort.ToString();
|
||||
txtBranchEngineeringCode.Text = itemModel.BranchEngineeringCode;
|
||||
txtBranchEngineeringName.Text = itemModel.BranchEngineeringName;
|
||||
txtSubBranchEngineeringName.Text = itemModel.SubBranchEngineeringName;
|
||||
txtProEngineeringCode.Text = itemModel.ProEngineeringCode;
|
||||
txtProEngineeringName.Text = itemModel.ProEngineeringName;
|
||||
txtProEngineeringNum.Text = itemModel.ProEngineeringNum;
|
||||
txtRemark.Text = itemModel.Remark;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存
|
||||
/// </summary>
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
var model = new Division_SubProjects();
|
||||
model.DivisionId = Guid.NewGuid().ToString();
|
||||
var oneDivisionId = string.Empty;
|
||||
var twoDivisionId = string.Empty;
|
||||
if (!string.IsNullOrWhiteSpace(this.DivisionId))
|
||||
{
|
||||
model = Funs.DB.Division_SubProjects.FirstOrDefault(p => p.DivisionId == this.DivisionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
model.Status = 1;
|
||||
model.ProjectId = CurrUser.LoginProjectId;
|
||||
}
|
||||
if (model == null)
|
||||
{
|
||||
ShowNotify("传递参数错误!", MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(this.ParentId))
|
||||
{
|
||||
var parenLs = GetAllCropping(this.ParentId);
|
||||
if (parenLs.Count > 0)
|
||||
{
|
||||
var oneModel = parenLs.FirstOrDefault(p => p.DivisionLevel == 1);
|
||||
if (oneModel != null)
|
||||
{
|
||||
model.ParentId = oneModel.DivisionId;
|
||||
model.DivisionLevel = 2;
|
||||
}
|
||||
var twoModel = parenLs.FirstOrDefault(p => p.DivisionLevel == 2);
|
||||
if (twoModel != null)
|
||||
{
|
||||
model.ParentId = twoModel.DivisionId;
|
||||
model.DivisionLevel = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
model.DivisionLevel = 1;
|
||||
}
|
||||
model.AddUser = this.CurrUser.UserId;
|
||||
model.OperateTime = DateTime.Now;
|
||||
model.Sort = !string.IsNullOrEmpty(txtSort.Text) ? int.Parse(txtSort.Text) : Funs.DB.Division_SubProjects.Count() + 1;
|
||||
model.BranchEngineeringCode = txtBranchEngineeringCode.Text;
|
||||
model.BranchEngineeringName = txtBranchEngineeringName.Text;
|
||||
model.SubBranchEngineeringName = txtSubBranchEngineeringName.Text;
|
||||
model.ProEngineeringCode = txtProEngineeringCode.Text;
|
||||
model.ProEngineeringName = txtProEngineeringName.Text;
|
||||
model.ProEngineeringNum = txtProEngineeringNum.Text;
|
||||
model.Remark = txtRemark.Text;
|
||||
if (string.IsNullOrWhiteSpace(this.DivisionId)) Funs.DB.Division_SubProjects.InsertOnSubmit(model);
|
||||
Funs.DB.SubmitChanges();
|
||||
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
||||
}
|
||||
|
||||
#region 私有方法
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键获取所有节点
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<Division_SubProjects> GetAllCropping(string parentId)
|
||||
{
|
||||
var result = new List<Division_SubProjects>();
|
||||
|
||||
var ids = new List<string>();
|
||||
var itemSubPro = Funs.DB.Division_SubProjects.FirstOrDefault(p => p.DivisionId == parentId);
|
||||
if (itemSubPro != null)
|
||||
{
|
||||
ids.Add(itemSubPro.DivisionId);
|
||||
if (itemSubPro.DivisionLevel == 2)
|
||||
{
|
||||
ids.Add(itemSubPro.ParentId);
|
||||
}
|
||||
if (itemSubPro.DivisionLevel == 3)
|
||||
{
|
||||
ids.Add(itemSubPro.ParentId);
|
||||
var twoSubPro = Funs.DB.Division_SubProjects.FirstOrDefault(p => p.DivisionId == itemSubPro.ParentId);
|
||||
if (twoSubPro != null)
|
||||
{
|
||||
ids.Add(twoSubPro.ParentId);
|
||||
}
|
||||
}
|
||||
result = Funs.DB.Division_SubProjects.Where(p => ids.Contains(p.DivisionId)).ToList();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user