修改进度与合同关联
This commit is contained in:
@@ -16,6 +16,36 @@ namespace FineUIPro.Web.PHTGL.ContractCompile
|
||||
set { ViewState["ContractTrackId"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 被选择项列表
|
||||
/// </summary>
|
||||
public List<string> SelectedList
|
||||
{
|
||||
get
|
||||
{
|
||||
return (List<string>)ViewState["SelectedList"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["SelectedList"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 未被选择项列表
|
||||
/// </summary>
|
||||
public List<string> NoSelectedList
|
||||
{
|
||||
get
|
||||
{
|
||||
return (List<string>)ViewState["NoSelectedList"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["NoSelectedList"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
#region 页面加载
|
||||
/// <summary>
|
||||
/// 页面加载
|
||||
@@ -27,7 +57,8 @@ namespace FineUIPro.Web.PHTGL.ContractCompile
|
||||
if (!IsPostBack)
|
||||
{
|
||||
ContractTrackId = Request.Params["ContractTrackId"];
|
||||
|
||||
this.SelectedList = new List<string>();
|
||||
this.NoSelectedList = new List<string>();
|
||||
InitTreeMenu();
|
||||
}
|
||||
}
|
||||
@@ -358,6 +389,21 @@ namespace FineUIPro.Web.PHTGL.ContractCompile
|
||||
/// <param name="e"></param>
|
||||
protected void trWBS_NodeCommand(object sender, TreeCommandEventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIDArray.Length > 0)
|
||||
{
|
||||
var Ids = Grid1.SelectedRowIDArray;
|
||||
for (int i = 0; i < this.Grid1.Rows.Count; i++)
|
||||
{
|
||||
if (Ids.Contains(this.Grid1.Rows[i].RowID))
|
||||
{
|
||||
SelectedList.Add(this.Grid1.Rows[i].RowID);
|
||||
}
|
||||
else
|
||||
{
|
||||
NoSelectedList.Add(this.Grid1.Rows[i].RowID);
|
||||
}
|
||||
}
|
||||
}
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
@@ -407,7 +453,7 @@ namespace FineUIPro.Web.PHTGL.ContractCompile
|
||||
/// </summary>
|
||||
private void BindGrid()
|
||||
{
|
||||
string strSql = @"SELECT ControlItemAndCycleId,ControlItemAndCycleCode,InitControlItemCode,ControlItemContent,ControlPoint,ControlItemDef,HGForms,SHForms,Standard,ClauseNo,CheckNum"
|
||||
string strSql = @"SELECT ControlItemAndCycleId,ControlItemAndCycleCode,InitControlItemCode,ControlItemContent,ControlPoint,ControlItemDef,HGForms,SHForms,Standard,ClauseNo,CheckNum,Weights"
|
||||
+ @" FROM WBS_ControlItemAndCycle ";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
strSql += " where WorkPackageId = @WorkPackageId and IsApprove=1 ";
|
||||
@@ -463,10 +509,53 @@ namespace FineUIPro.Web.PHTGL.ContractCompile
|
||||
|
||||
protected void btnAccept_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIDArray.Length>0)
|
||||
if (Grid1.SelectedRowIDArray.Length > 0)
|
||||
{
|
||||
var Ids=Grid1.SelectedRowIDArray;
|
||||
foreach (var item in Ids)
|
||||
var Ids = Grid1.SelectedRowIDArray;
|
||||
for (int i = 0; i < this.Grid1.Rows.Count; i++)
|
||||
{
|
||||
if (Ids.Contains(this.Grid1.Rows[i].RowID))
|
||||
{
|
||||
SelectedList.Add(this.Grid1.Rows[i].RowID);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SelectedList.Contains(this.Grid1.Rows[i].RowID))
|
||||
{
|
||||
SelectedList.Remove(this.Grid1.Rows[i].RowID);
|
||||
}
|
||||
NoSelectedList.Add(this.Grid1.Rows[i].RowID);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SelectedList.Count > 0)
|
||||
{
|
||||
SelectedList = SelectedList.Distinct().ToList();
|
||||
decimal estimatedAmount = 0;
|
||||
var contractTrack = PhtglContractTrackService.GetPHTGL_ContractTrackById(ContractTrackId);
|
||||
if (contractTrack != null && contractTrack.EstimatedAmount.HasValue)
|
||||
{
|
||||
estimatedAmount = contractTrack.EstimatedAmount.Value;
|
||||
}
|
||||
decimal totalWeights = 0;
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
var totalControlItemAndCycles = from x in db.WBS_ControlItemAndCycle
|
||||
where x.ProjectId == this.CurrUser.LoginProjectId
|
||||
select x;
|
||||
var unitWorks = from x in db.WBS_UnitWork
|
||||
where x.ProjectId == this.CurrUser.LoginProjectId
|
||||
select x;
|
||||
var workPackages = (from x in db.WBS_WorkPackage
|
||||
where x.ProjectId == this.CurrUser.LoginProjectId
|
||||
select x).ToList();
|
||||
var controlItemAndCycles = from x in totalControlItemAndCycles
|
||||
where SelectedList.Contains(x.ControlItemAndCycleId)
|
||||
select x;
|
||||
foreach (var controlItemAndCycle in controlItemAndCycles)
|
||||
{
|
||||
totalWeights += controlItemAndCycle.Weights ?? 0;
|
||||
}
|
||||
foreach (var item in SelectedList)
|
||||
{
|
||||
var querymodel = new Model.PHTGL_ContractTrackMatchWBS
|
||||
{
|
||||
@@ -484,7 +573,34 @@ namespace FineUIPro.Web.PHTGL.ContractCompile
|
||||
ControlItemAndCycleId = item,
|
||||
|
||||
};
|
||||
var c = controlItemAndCycles.First(x => x.ControlItemAndCycleId == item);
|
||||
decimal oldPlanCost = c.PlanCost ?? 0;
|
||||
decimal changePlanCost = 0;
|
||||
if (estimatedAmount > 0 && totalWeights > 0 && c.Weights.HasValue)
|
||||
{
|
||||
//工作包概算费用
|
||||
newtable.WorkPackageEstimate = decimal.Round(c.Weights.Value / totalWeights * estimatedAmount, 2);
|
||||
}
|
||||
BLL.PhtglContracttrackmatchwbsService.AddPHTGL_ContractTrackMatchWBS(newtable);
|
||||
c.PlanCost = newtable.WorkPackageEstimate ?? 0;
|
||||
changePlanCost += (newtable.WorkPackageEstimate ?? 0) - oldPlanCost;
|
||||
BLL.ControlItemAndCycleService.UpdateControlItemAndCycle(c);
|
||||
//更新上级WBS内容概算费用
|
||||
BLL.WorkPackageService.UpdateWorkPackagesPlanCost(workPackages, c.WorkPackageId, changePlanCost);
|
||||
var workPackage = workPackages.FirstOrDefault(x=>x.WorkPackageId== c.WorkPackageId);
|
||||
if (workPackage != null)
|
||||
{
|
||||
var unitWork = unitWorks.FirstOrDefault(x => x.UnitWorkId == workPackage.UnitWorkId);
|
||||
if (unitWork.PlanCost == null)
|
||||
{
|
||||
unitWork.PlanCost = changePlanCost;
|
||||
}
|
||||
else
|
||||
{
|
||||
unitWork.PlanCost += changePlanCost;
|
||||
}
|
||||
}
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
ShowNotify("添加成功", MessageBoxIcon.Success);
|
||||
@@ -492,7 +608,7 @@ namespace FineUIPro.Web.PHTGL.ContractCompile
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("请选择需要添加的数据",MessageBoxIcon.Information);
|
||||
ShowNotify("请选择需要添加的数据", MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,7 +624,7 @@ namespace FineUIPro.Web.PHTGL.ContractCompile
|
||||
if (queryResult.Any())
|
||||
{
|
||||
e.RowCssClass = "color3";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user