2021-09-15 14:50:52 +08:00
|
|
|
|
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 CostControlWeekItemDetailEdit : 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_CostControlDetail costControlDetail = BLL.CostControlDetailService.GetCostControlDetailByCostControlDetailId(this.Id);
|
|
|
|
|
string name = string.Empty;
|
|
|
|
|
if (costControlDetail != null)
|
|
|
|
|
{
|
|
|
|
|
Model.WBS_CostControl costControl = BLL.CostControlService.GetCostControlByCostControlId(costControlDetail.CostControlId);
|
|
|
|
|
if (costControl != null)
|
|
|
|
|
{
|
|
|
|
|
this.txtCostControlName.Text = costControl.CostControlName;
|
|
|
|
|
}
|
|
|
|
|
if (costControlDetail.Months != null)
|
|
|
|
|
{
|
|
|
|
|
this.txtMonths.Text = " 月份:" + string.Format("{0:yyyy-MM}", costControlDetail.Months);
|
|
|
|
|
}
|
|
|
|
|
if (costControlDetail.PlanNum != null)
|
|
|
|
|
{
|
|
|
|
|
this.txtTotalPlanNum.Text = " 本月计划完成量:" + costControlDetail.PlanNum.Value.ToString("F0");
|
|
|
|
|
}
|
|
|
|
|
var list = BLL.CostControlDetailService.GetWeekCostControlDetailsByCostControlId(costControlDetail.CostControlId, costControlDetail.Months.Value);
|
|
|
|
|
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();
|
|
|
|
|
Model.WBS_CostControlDetail costControlDetail = BLL.CostControlDetailService.GetCostControlDetailByCostControlDetailId(this.Id);
|
|
|
|
|
detail.CostControlDetailId = SQLHelper.GetNewID();
|
|
|
|
|
detail.Months = costControlDetail.Months;
|
2021-09-17 16:04:52 +08:00
|
|
|
|
detail.StartDate= costControlDetail.Months;
|
|
|
|
|
detail.EndDate = costControlDetail.Months.Value.AddMonths(1).AddDays(-1);
|
2021-09-15 14:50:52 +08:00
|
|
|
|
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>();
|
|
|
|
|
Model.WBS_CostControlDetail costControlDetail = BLL.CostControlDetailService.GetCostControlDetailByCostControlDetailId(this.Id);
|
|
|
|
|
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 = costControlDetail.CostControlId;
|
|
|
|
|
detail.Months = Funs.GetNewDateTime(values.Value<string>("Months"));
|
|
|
|
|
detail.StartDate = Funs.GetNewDateTime(values.Value<string>("StartDate"));
|
|
|
|
|
detail.EndDate = Funs.GetNewDateTime(values.Value<string>("EndDate"));
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
bool hasDate = true;
|
|
|
|
|
decimal totalNum = 0;
|
|
|
|
|
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();
|
|
|
|
|
if (string.IsNullOrEmpty(values.Value<string>("StartDate")) || string.IsNullOrEmpty(values.Value<string>("EndDate")))
|
|
|
|
|
{
|
|
|
|
|
hasDate = false;
|
|
|
|
|
}
|
|
|
|
|
totalNum += Funs.GetNewDecimalOrZero(values.Value<string>("PlanNum"));
|
|
|
|
|
}
|
|
|
|
|
if (!hasDate)
|
|
|
|
|
{
|
|
|
|
|
ShowNotify("开始、结束日期不能为空!", MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Model.WBS_CostControlDetail costControlDetail = BLL.CostControlDetailService.GetCostControlDetailByCostControlDetailId(this.Id);
|
|
|
|
|
if (costControlDetail.PlanNum != totalNum)
|
|
|
|
|
{
|
|
|
|
|
ShowNotify("周计划累计值必须等于"+ costControlDetail.PlanNum.Value.ToString("F0") + "!", MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
Model.WBS_CostControlDetail costControlDetail = BLL.CostControlDetailService.GetCostControlDetailByCostControlDetailId(this.Id);
|
|
|
|
|
int versionNum = BLL.CostControlDetailHistoryService.GetWeekMaxVersionNumByCostControlId(costControlDetail.CostControlId, costControlDetail.Months.Value);
|
|
|
|
|
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.StartDate = item.StartDate;
|
|
|
|
|
detailHistory.EndDate = item.EndDate;
|
|
|
|
|
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("CostControlWeekDetailHistoryShow.aspx?Id={0}", this.Id, "编辑 - ")));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|