0813
This commit is contained in:
@@ -0,0 +1,168 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using BLL;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace FineUIPro.Web.JDGL.WBS
|
||||
{
|
||||
public partial class CostControlDetailEdit : PageBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 控制项主键
|
||||
/// </summary>
|
||||
public string Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["Id"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["Id"] = value;
|
||||
}
|
||||
}
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.Id = Request.Params["Id"];
|
||||
Model.WBS_CostControl costControl = BLL.CostControlService.GetCostControlByCostControlId(this.Id);
|
||||
if (costControl != null)
|
||||
{
|
||||
this.txtCostControlName.Text = costControl.CostControlName;
|
||||
}
|
||||
var list = BLL.CostControlDetailService.GetCostControlDetailsByCostControlId(this.Id);
|
||||
this.Grid1.DataSource = list;
|
||||
this.Grid1.DataBind();
|
||||
}
|
||||
}
|
||||
#region 增加按钮事件
|
||||
/// <summary>
|
||||
/// 增加按钮事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnNew_Click(object sender, EventArgs e)
|
||||
{
|
||||
var list = GetDetails();
|
||||
Model.WBS_CostControlDetail detail = new Model.WBS_CostControlDetail();
|
||||
detail.CostControlDetailId = SQLHelper.GetNewID();
|
||||
list.Add(detail);
|
||||
Grid1.DataSource = list;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
#endregion
|
||||
private List<Model.WBS_CostControlDetail> GetDetails()
|
||||
{
|
||||
List<Model.WBS_CostControlDetail> details = new List<Model.WBS_CostControlDetail>();
|
||||
foreach (JObject mergedRow in Grid1.GetMergedData())
|
||||
{
|
||||
JObject values = mergedRow.Value<JObject>("values");
|
||||
int i = mergedRow.Value<int>("index");
|
||||
Model.WBS_CostControlDetail detail = new Model.WBS_CostControlDetail();
|
||||
detail.CostControlDetailId = Grid1.Rows[i].RowID;
|
||||
detail.CostControlId = this.Id;
|
||||
detail.Months = Funs.GetNewDateTime(values.Value<string>("Months") + "-01");
|
||||
detail.PlanNum = Funs.GetNewDecimal(values.Value<string>("PlanNum"));
|
||||
details.Add(detail);
|
||||
}
|
||||
return details;
|
||||
}
|
||||
#region 行点击事件
|
||||
/// <summary>
|
||||
/// Grid行点击事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
||||
{
|
||||
string detailId = Grid1.DataKeys[e.RowIndex][0].ToString();
|
||||
var list = GetDetails();
|
||||
if (e.CommandName == "del")//删除
|
||||
{
|
||||
var detail = list.FirstOrDefault(x => x.CostControlDetailId == detailId);
|
||||
Model.WBS_CostControlDetail oldDetail = BLL.CostControlDetailService.GetCostControlDetailByCostControlDetailId(detailId);
|
||||
if (detail != null)
|
||||
{
|
||||
list.Remove(detail);
|
||||
}
|
||||
if (oldDetail != null)
|
||||
{
|
||||
BLL.CostControlDetailService.DeleteCostControlDetail(detailId);
|
||||
}
|
||||
this.Grid1.DataSource = list;
|
||||
this.Grid1.DataBind();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存
|
||||
/// <summary>
|
||||
/// 保存按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
var list = GetDetails();
|
||||
foreach (var item in list)
|
||||
{
|
||||
Model.WBS_CostControlDetail oldDetail = BLL.CostControlDetailService.GetCostControlDetailByCostControlDetailId(item.CostControlDetailId);
|
||||
if (oldDetail == null)
|
||||
{
|
||||
BLL.CostControlDetailService.AddCostControlDetail(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.ThisNum = oldDetail.ThisNum;
|
||||
BLL.CostControlDetailService.UpdateCostControlDetail(item);
|
||||
}
|
||||
}
|
||||
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHideReference());
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 调整计划
|
||||
/// <summary>
|
||||
/// 调整计划按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
var list = GetDetails();
|
||||
int versionNum = BLL.CostControlDetailHistoryService.GetMaxVersionNumByCostControlId(this.Id);
|
||||
foreach (var item in list)
|
||||
{
|
||||
Model.WBS_CostControlDetailHistory detailHistory = new Model.WBS_CostControlDetailHistory();
|
||||
detailHistory.CostControlDetailHistoryId = SQLHelper.GetNewID();
|
||||
detailHistory.CostControlId = item.CostControlId;
|
||||
detailHistory.Months = item.Months;
|
||||
detailHistory.PlanNum = item.PlanNum;
|
||||
detailHistory.VersionNum = versionNum + 1;
|
||||
BLL.CostControlDetailHistoryService.AddCostControlDetailHistory(detailHistory);
|
||||
}
|
||||
ShowNotify("历史版本保存成功!", MessageBoxIcon.Success);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 查看历史版本
|
||||
/// <summary>
|
||||
/// 查看历史版本
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSee_Click(object sender, EventArgs e)
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CostControlDetailHistoryShow.aspx?Id={0}", this.Id, "编辑 - ")));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user