public JsonResult SaveNodes(string ListData, string VersionID) { var list = JsonHelper.ToList(ListData); Action action = () => { var versionDic = this.GetDataDicByID("S_EP_BudgetVersion", VersionID); if (versionDic == null) { throw new Formula.Exceptions.BusinessValidationException("没有找到指定的预算版本信息,保存失败"); } var version = new S_EP_BudgetVersion(versionDic); foreach (var item in list) { if (item.GetValue("_state").ToLower() == "removed") { continue; } var lastVersionValue = String.IsNullOrEmpty(item.GetValue("LastVersionValue")) ? 0m : Convert.ToDecimal(item.GetValue("LastVersionValue")); var currentValue = String.IsNullOrEmpty(item.GetValue("TotalValue")) ? 0m : Convert.ToDecimal(item.GetValue("TotalValue")); if (item.GetValue("CustomEdit") == "True") { if (Convert.ToInt32(this.SQLDB.ExecuteScalar(@"SELECT COUNT(ID) FROM S_EP_BudgetVersion_Detail WHERE CBSParentID='" + item.GetValue("CBSID") + "' AND S_EP_BudgetVersionID='" + VersionID + "'")) > 0) { item.SetValue("CustomEdit", "True"); } else { item.SetValue("CustomEdit", "False"); } } if (currentValue == lastVersionValue && item.GetValue("ModifyState") == ModifyState.Modified.ToString()) { item.SetValue("ModifyState", ModifyState.Normal.ToString()); } else if (item.GetValue("ModifyState") == ModifyState.Normal.ToString()) { item.SetValue("ModifyState", ModifyState.Modified.ToString()); } item.UpdateDB(this.SQLDB, "S_EP_BudgetVersion_Detail", item.GetValue("ID")); } version.SummaryTotalValue(); }; this.ExecuteAction(action); return(Json("")); }
public JsonResult Revert(string VersionID) { Action action = () => { var versionDic = this.GetDataDicByID("S_EP_BudgetVersion", VersionID); var budget = new S_EP_BudgetVersion(versionDic); if (versionDic.GetValue("FlowPhase") != "Start") { throw new Formula.Exceptions.BusinessValidationException("禁止删除已经发起流程的预算"); } this.SQLDB.ExecuteNonQuery(String.Format("DELETE FROM S_EP_BudgetVersion WHERE ID='{0}'", VersionID)); }; this.ExecuteAction(action); return(Json("")); }