/// <summary> /// 获取可增加的下层子节点类型 /// </summary> /// <returns>枚举DataTable</returns> public DataTable GetChildWBSType() { var result = new DataTable(); result.Columns.Add("text"); result.Columns.Add("value"); var children = this.ChildCode.Split(','); foreach (var item in children) { var row = result.NewRow(); row["value"] = item; row["text"] = EnumBaseHelper.GetEnumDescription(typeof(WBSNodeType), item); result.Rows.Add(row); } return(result); }
/// <summary> /// 获取校审流程启动参数 /// </summary> /// <param name="auditForm"></param> /// <param name="auditFormUrl"></param> /// <param name="stepList"></param> /// <returns></returns> public virtual AuditFlowStartParam GetAuditFlowStartParam(T_AE_Audit auditForm, string auditFormUrl, List <S_E_Product> productList, S_W_WBS wbs, S_I_ProjectInfo projectInfo) { var startParam = new AuditFlowStartParam(); startParam.DisplayName = EnumBaseHelper.GetEnumDescription(typeof(ActivityType), ActivityType.Design.ToString()) + "(" + auditForm.Name + ")"; startParam.AuditFormUrl = auditFormUrl; startParam.AuditFormID = auditForm.ID; startParam.WBSID = auditForm.WBSID; //参与校审的人员 var userInfo = GetAuditRoleUser(auditForm.WBSID); //本次校审的环节 var stepList = GetAuditSteps(userInfo, productList, wbs, projectInfo); foreach (var auditStep in stepList) { startParam.AddStep(auditStep); } return(startParam); }
private Dictionary <string, object> createChartOption(DataTable dt, string field) { FillDataSourceWithChart(dt, field); var result = new Dictionary <string, object>(); var chart = new Dictionary <string, object>(); chart.SetValue("zoomType", "xy"); result.SetValue("chart", chart); var title = new Dictionary <string, object>(); title.SetValue("text", ""); result.SetValue("title", title); var xAxisis = new List <Dictionary <string, object> >(); var xAxis = new Dictionary <string, object>(); var categories = new string[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { categories[i] = dt.Rows[i]["Name"].ToString(); } xAxis.SetValue("categories", categories); xAxisis.Add(xAxis); result.SetValue("xAxis", xAxisis); result.SetValue("credits", new { enabled = false }); var yAxisis = new List <Dictionary <string, object> >(); yAxisis.Add(this.CreateYAxis("#4572A7", EnumBaseHelper.GetEnumDescription(typeof(CustomerAnlysisType), field), "{value}", false)); yAxisis.Add(this.CreateYAxis("#89A54E", "", "{value} %", true)); result.SetValue("yAxis", yAxisis); var tooltip = new Dictionary <string, object>(); tooltip.SetValue("shared", true); result.SetValue("tooltip", tooltip); var series = new List <Dictionary <string, object> >(); series.Add(this.CreateSeries(dt, field, EnumBaseHelper.GetEnumDescription(typeof(CustomerAnlysisType), field), "column", "元", "#4572A7")); series.Add(this.CreateSeries(dt, "Rate", "累计比例", "spline", "%", "#89A54E", 1)); result.SetValue("series", series); return(result); }
public ActionResult WBSAddWithAttrDefine() { string childType = this.Request["Type"]; ViewBag.NameTitle = EnumBaseHelper.GetEnumDescription(typeof(WBSNodeType), childType); if (String.IsNullOrEmpty(childType)) { throw new Formula.Exceptions.BusinessException("未指定需要增加的WBS节点类型,无法增加节点"); } //项目策划-专业、阶段根据策划及业务类型过滤 string projectInfoID = this.GetQueryString("ProjectInfoID"); var project = this.entities.Set <S_I_ProjectInfo>().Find(projectInfoID); var prjClass = string.Empty; if (project != null) { prjClass = project.ProjectClass; } var list = BaseConfigFO.GetWBSEnum(childType, prjClass); ViewBag.DefineAttr = JsonHelper.ToJson(list); var allDefineAttr = BaseConfigFO.GetWBSEnum(childType, ""); ViewBag.AllDefineAttr = JsonHelper.ToJson(allDefineAttr); var prjClassDt = EnumBaseHelper.GetEnumTable("Base.ProjectClass"); var projectClassRows = prjClassDt.Select("value='" + prjClass + "'"); if (projectClassRows != null && projectClassRows.Count() > 0) { ViewBag.ProjectClassName = projectClassRows[0]["text"].ToString(); } else { ViewBag.ProjectClassName = ""; } ViewBag.WBSType = childType; return(this.View()); }
public JsonResult GetMenu(string ID) { var wbs = this.GetEntityByID <S_D_WBSTemplateNode>(ID); if (wbs == null) { throw new Formula.Exceptions.BusinessException("未能找到ID为【" + ID + "】的WBS对象"); } if (wbs.StructNodeInfo == null) { throw new Formula.Exceptions.BusinessException("WBS节点未定义类别,无法显示菜单"); } var childNodeCodes = wbs.StructNodeInfo.ChildCode.Split(','); List <Dictionary <string, object> > result = new List <Dictionary <string, object> >(); foreach (var item in childNodeCodes) { var menuItem = new Dictionary <string, object>(); var name = EnumBaseHelper.GetEnumDescription(typeof(WBSNodeType), item); menuItem["name"] = item; menuItem["text"] = "增加" + name; menuItem["iconCls"] = "icon-add"; menuItem["onClick"] = "addNode"; var attrDefineList = BaseConfigFO.GetWBSAttrList(item); if (attrDefineList.Count > 0) { menuItem["attrDefine"] = "true"; } else { menuItem["attrDefine"] = "false"; } result.Add(menuItem); } string json = JsonHelper.ToJson(result); return(Json(result)); }
public void SynchWorkDaysBySingleUserId(string userId, string roleCode, float workDay = 0) { var entities = FormulaHelper.GetEntities <ProjectEntities>(); var currentUserInfo = FormulaHelper.GetUserInfo(); if (!this.IsUserExistedOfRoleCode(userId, roleCode)) { var user = FormulaHelper.GetUserInfoByID(userId); S_W_StandardWorkTimeDetail detail = entities.Set <S_W_StandardWorkTimeDetail>().Create(); detail.ID = FormulaHelper.CreateGuid(); detail.UserID = user.UserID; detail.UserName = user.UserName; detail.WBSID = this.WBSID; detail.TaskWorkID = this.TaskWorkID; detail.ProjectInfoID = this.ProjectInfoID; detail.RoleCode = roleCode; var roleName = EnumBaseHelper.GetEnumDescription(typeof(Project.Logic.AuditRoles), roleCode); detail.RoleName = roleName; detail.WorkDay = workDay; detail.CreateDate = DateTime.Now; if (currentUserInfo != null) { detail.CreateUser = currentUserInfo.UserName; detail.CreateUserID = currentUserInfo.UserID; } this.S_W_StandardWorkTimeDetail.Add(detail); } else { var detail = entities.Set <S_W_StandardWorkTimeDetail>().SingleOrDefault(c => c.FormID == this.ID && c.UserID == userId && c.RoleCode == roleCode); detail.WorkDay = workDay; detail.ModifyDate = DateTime.Now; if (currentUserInfo != null) { detail.ModifyUser = currentUserInfo.UserName; detail.ModifyUserID = currentUserInfo.UserID; } } }
public JsonResult GetProjectList(QueryBuilder qb, string EngineeringID) { var list = this.entities.Set <S_I_ProjectInfo>().Where(d => d.EngineeringInfoID == EngineeringID).ToList(); var result = new List <Dictionary <string, object> >(); foreach (var projectInfo in list) { var item = FormulaHelper.ModelToDic <S_I_ProjectInfo>(projectInfo); if (this.entities.Set <S_E_Product>().Where(d => d.ProjectInfoID == projectInfo.ID).Count() > 0) { var printCount = this.entities.Set <S_E_Product>().Where(d => d.ProjectInfoID == projectInfo.ID).Sum(d => d.PrintCount); item.SetValue("PrintCount", printCount.HasValue ? printCount.Value : 0); } else { item.SetValue("PrintCount", 0); } var majors = String.Join(",", projectInfo.S_W_WBS.Where(d => d.WBSType == WBSNodeType.Major.ToString()).Select(d => d.Name).Distinct().ToList()); item.SetValue("Major", majors); item.SetValue("StateName", EnumBaseHelper.GetEnumDescription(typeof(Project.Logic.ProjectCommoneState), projectInfo.State)); result.Add(item); } return(Json(result)); }
public ActionResult WBSAddWithAttrDefine() { string childType = this.Request["Type"]; ViewBag.NameTitle = EnumBaseHelper.GetEnumDescription(typeof(WBSNodeType), childType); if (String.IsNullOrEmpty(childType)) { throw new Formula.Exceptions.BusinessException("未指定需要增加的WBS节点类型,无法增加节点"); } //项目策划-专业、阶段根据策划及业务类型过滤 string projectInfoID = this.GetQueryString("ProjectInfoID"); var project = this.entities.Set <S_I_ProjectInfo>().Find(projectInfoID); var prjClass = string.Empty; if (project != null) { prjClass = project.ProjectClass; } var list = BaseConfigFO.GetWBSEnum(childType, prjClass); ViewBag.DefineAttr = JsonHelper.ToJson(list); return(this.View()); }
private Dictionary <string, object> GetChartData(string xAxisType, string anlysisValue, string analysisType, int startYear, int endYear) { string series = string.Empty; string serieFields = string.Empty; string sql = @"select Sum(DataValue) as Value,BelongYear {0} from (select isnull(ThisContractRMBAmount,0) as DataValue,BelongYear,BelongQuarter,BelongMonth from S_C_ManageContract where IsSigned='" + ContractIsSigned.Signed + @"' union all select isnull(SupplementaryRMBAmount,0) as DataValue,ad.BelongYear,ad.BelongQuarter,ad.BelongMonth from S_C_ManageContract_Supplementary ad inner join S_C_ManageContract con on ad.ContractInfoID=con.ID where IsSigned='" + ContractIsSigned.Signed + @"' )tb where BelongYear>='" + startYear + "' and BelongYear<='" + endYear + "' group by BelongYear {0}"; if (anlysisValue == AnlysisValue.ReceiptValue.ToString()) { sql = @"select Sum(Amount) as Value,BelongYear {0} from S_C_Receipt where BelongYear>='" + startYear + "' and BelongYear<='" + endYear + "' group by BelongYear {0}"; } #region 月为X轴统计图表 if (xAxisType == XAxisType.Month.ToString()) { sql = String.Format(sql, ",BelongMonth"); var dt = this.SqlHelper.ExecuteDataTable(sql); var dataSource = new DataTable(); dataSource.Columns.Add("Month", typeof(string)); for (int i = startYear; i <= endYear; i++) { series += i.ToString() + "年,"; serieFields += i.ToString() + ","; dataSource.Columns.Add(i.ToString(), typeof(decimal)); } for (int i = 1; i <= 12; i++) { var row = dataSource.NewRow(); row["Month"] = i + "月"; for (int j = startYear; j <= endYear; j++) { var data = dt.Select("BelongMonth='" + i + "' and BelongYear='" + j + "'").FirstOrDefault(); if (analysisType == AnalysisType.Month.ToString()) { if (data == null || data["Value"] == null || data["Value"] == DBNull.Value) { row[j.ToString()] = 0; } else { row[j.ToString()] = data["Value"]; } } else { var value = 0M; if (j == DateTime.Now.Year && i > DateTime.Now.Month) { row[j.ToString()] = value; } else { if (data != null && data["Value"] != null && data["Value"] != DBNull.Value) { value = Convert.ToDecimal(data["Value"]); } if (i == 1) { row[j.ToString()] = value; } else { var preDataRow = dataSource.Select("Month='" + (i - 1) + "月'").FirstOrDefault(); var preValue = 0M; if (preDataRow != null) { preValue = Convert.ToDecimal(preDataRow[j.ToString()]); value += preValue; } } } row[j.ToString()] = value; } } dataSource.Rows.Add(row); } series = series.TrimEnd(','); serieFields = serieFields.TrimEnd(','); var columChart = HighChartHelper.CreateColumnChart("", dataSource, "Month", series.Split(','), serieFields.Split(',')); return(columChart.Render()); } #endregion #region 年统计图表 else { sql = String.Format(sql, ""); var dt = this.SqlHelper.ExecuteDataTable(sql); var dataSource = new DataTable(); dataSource.Columns.Add("Value", typeof(decimal)); dataSource.Columns.Add("Year", typeof(string)); for (int i = startYear; i <= endYear; i++) { var row = dataSource.NewRow(); row["Year"] = i; var data = dt.Select(" BelongYear='" + i + "' ").FirstOrDefault(); //单月统计 if (analysisType == AnalysisType.Month.ToString()) { if (data == null || data["Value"] == null || data["Value"] == DBNull.Value) { row["Value"] = 0; } else { row["Value"] = data["Value"]; } dataSource.Rows.Add(row); } else //累计统计 { var value = 0M; if (data == null || data["Value"] == null || data["Value"] == DBNull.Value) { value = 0; } else { value = Convert.ToDecimal(data["Value"]); } if (i == startYear) { row["Value"] = value; } else { var preRow = dataSource.Select("Year='" + (i - 1) + "'").FirstOrDefault(); var preValue = 0M; if (preRow != null && preRow["Value"] != null && preRow["Value"] != DBNull.Value) { preValue = Convert.ToDecimal(preRow["Value"]); } row["Value"] = preValue + value; } dataSource.Rows.Add(row); } } series = EnumBaseHelper.GetEnumDescription(typeof(AnlysisValue), anlysisValue); serieFields = "Value"; var columChart = HighChartHelper.CreateColumnChart("", dataSource, "Year", series.Split(','), serieFields.Split(',')); return(columChart.Render()); } #endregion }
/// <summary> /// 执行校审 /// </summary> /// <param name="exeParam">流程执行参数</param> /// <returns>执行结果对象</returns> public virtual ExeResult Execute(S_W_Activity activity, AuditFlowExecuteParam exeParam) { var exeResult = new ExeResult(); var wbs = this.instanceEnitites.S_W_WBS.SingleOrDefault(d => d.ID == exeParam.WBSID); if (wbs == null) { throw new Exception("未能找到ID为【" + exeParam.WBSID + "】的WBS对象,无法执行校审"); } //结束当前步骤 activity.ExeucteOption = exeParam.ExecuteOption.ToString(); activity.Finish(); //结束属于一组的所有活动 string state = ProjectCommoneState.Finish.ToString(); instanceEnitites.S_W_Activity.Where(c => c.BusniessID == activity.BusniessID && c.GroupID == activity.GroupID).Update(c => c.State = state); string createState = ProjectCommoneState.Create.ToString(); var currentStep = activity.GetCurrentStep(); //如果是打回,结束所有本环节流程 if (exeParam.ExecuteOption == AuditOption.Back || exeParam.ExecuteOption == AuditOption.Return) { instanceEnitites.S_W_Activity.Where(c => c.BusniessID == activity.BusniessID && c.ActivityKey == activity.ActivityKey).Update(c => c.State = state); }//并签时,查找本环节是否还有未结束的活动,如果有,直接返回 else if (currentStep.AuditModel == AuditModel.multi && instanceEnitites.S_W_Activity.Where(c => c.BusniessID == activity.BusniessID && c.State == createState && c.ActivityKey == activity.ActivityKey && c.GroupID != activity.GroupID).Count() > 0) { exeResult.IsComplete = false; exeResult.ExecStatus = "Wait"; return(exeResult); }//串签时,如果还有等待的环节,直接把等待环节new出来 else if (currentStep.AuditModel == AuditModel.Follow && instanceEnitites.S_W_Activity.Where(c => c.BusniessID == activity.BusniessID && c.State == "Wait" && c.ActivityKey == activity.ActivityKey && c.GroupID != activity.GroupID).Count() > 0) { var waitAct = instanceEnitites.S_W_Activity.Where(c => c.BusniessID == activity.BusniessID && c.State == "Wait" && c.ActivityKey == activity.ActivityKey && c.GroupID != activity.GroupID).OrderBy("ID", true).FirstOrDefault(); waitAct.State = ProjectCommoneState.Create.ToString(); exeResult.IsComplete = false; exeResult.ExecStatus = "Wait"; return(exeResult); } //活动环节上定义的所有校审步骤 var steps = activity.GetSteps(); var lastStep = steps.OrderByDescending(d => d.StepIndex).FirstOrDefault(); //如果执行参数中的执行结果为结束校审,则直接结束校审 if (exeParam.ExecuteOption == AuditOption.Over) { //如果是第一步直接结束,则认为是设计人直接撤回校审单 if (activity.ActivityKey == ActivityType.Design.ToString()) { exeResult.IsCancel = true; } exeResult.IsComplete = true; } //如果当前步骤是活动步骤定义中的最后一个步骤,并且执行参数中的执行结果是通过的,则直接结束校审 else if (lastStep.StepKey.ToString() == activity.ActivityKey && exeParam.ExecuteOption == AuditOption.Pass) { exeResult.IsComplete = true; } else { //正常向下执行校审 //活动执行参数中的下一步骤对象 var nextStep = exeParam.NextStep; if (nextStep == null) { throw new Exception("下一环节的活动未找到,无法执行校审流程"); } if (nextStep.UserID == "SelectOneUser" || nextStep.UserID == "SelectMultiUser" || string.IsNullOrEmpty(nextStep.UserID)) { throw new Exception("未指定下环节[" + nextStep.StepName + "]人员,不能执行到下一步。"); } exeResult.IsComplete = false; var nextUserIDs = nextStep.UserID.Split(','); var nextUserNames = nextStep.UserName.Split(','); //步骤上可存在多人,如果步骤中定义的是单签,则创建相同GroupID的活动,否则GroupID不相同 string groupID = FormulaHelper.CreateGuid(); for (int i = 0; i < nextUserIDs.Length; i++) { var userID = nextUserIDs[i]; var userName = nextUserNames[i]; var nextActivity = new S_W_Activity(); if (String.IsNullOrEmpty(exeParam.DisplayName)) { nextActivity.DisplayName = activity.DisplayName; } else { nextActivity.DisplayName = exeParam.DisplayName; } nextActivity.ActvityName = EnumBaseHelper.GetEnumDescription(typeof(ActivityType), exeParam.NextStep.StepKey.ToString()); nextActivity.ActivityKey = nextStep.StepKey.ToString(); nextActivity.OwnerUserID = userID; nextActivity.OwnerUserName = userName; nextActivity.DefSteps = activity.DefSteps; nextActivity.AuditPatchID = activity.AuditPatchID; nextActivity.BusniessID = activity.BusniessID; nextActivity.LinkUrl = activity.LinkUrl; nextActivity.Params = activity.Params; //单签 if (nextStep.AuditModel == AuditModel.single) { nextActivity.GroupID = groupID; } else { nextActivity.GroupID = FormulaHelper.CreateGuid(); //如果是串签,则除去第一个外,都为等待状态 if (nextStep.AuditModel == AuditModel.Follow && i != 0) { nextActivity.State = "Wait"; } } if (nextStep.StepKey == ActivityType.Design) { if (exeParam.ExecuteOption == AuditOption.Return) { //如果存在中间必须经过的环节,则取必须经过的环节 var mustStep = steps.Where(c => c.StepIndex < currentStep.StepIndex && c.MustStep == "是").FirstOrDefault(); if (mustStep != null) { nextActivity.NextStep = JsonHelper.ToJson(mustStep.ToDic()); } else { nextActivity.NextStep = JsonHelper.ToJson(activity.GetCurrentStep().ToDic()); } } else { var nextActivityStep = steps.FirstOrDefault(d => d.StepKey.ToString() == nextActivity.ActivityKey); var afterStepIndex = steps.IndexOf(nextActivityStep) + 1; if (afterStepIndex >= steps.Count) { throw new Exception(""); } nextStep = steps[afterStepIndex]; nextActivity.NextStep = JsonHelper.ToJson(nextStep.ToDic()); } } wbs.AddActivity(nextActivity); exeResult.Activities.Add(nextActivity); } } return(exeResult); }
public static string CreatePortal(string templetID, string portalID, bool isNew, string json) { try { var entities = FormulaHelper.GetEntities <BaseEntities>(); var templet = entities.Set <S_A_PortalTemplet>().SingleOrDefault(c => c.ID == templetID); if (templet != null) { var html = templet.Items; Dictionary <string, object> list = JsonHelper.ToObject(json); string type = list.GetValue("Type"); if (type != PortalType.Now.ToString()) { if (isNew) { string linkUrl = list.GetValue("LinkUrl"); string moreUrl = list.GetValue("MoreUrl"); S_A_Portal portal = new S_A_Portal(); portalID = FormulaHelper.CreateGuid(); portal.ID = portalID; portal.Title = list.GetValue("Title"); portal.Type = type; if (string.IsNullOrEmpty(linkUrl)) { portal.LinkUrl = "/Base/UI/Portal/Views?ID={ID}&portalID=" + portalID; } else { portal.LinkUrl = list.GetValue("LinkUrl"); } if (string.IsNullOrEmpty(moreUrl)) { portal.MoreUrl = "/Base/UI/Portal/ListView?portalID=" + portalID; } else { portal.MoreUrl = list.GetValue("MoreUrl"); } portal.Height = list.GetValue("Height").Trim(); portal.DisplayType = list.GetValue("DisplayType").Trim(); portal.ConnName = list.GetValue("ConnName"); portal.SQL = list.GetValue("SQL"); entities.Set <S_A_Portal>().Add(portal); } else { if (!string.IsNullOrEmpty(portalID)) { var portal = entities.Set <S_A_Portal>().SingleOrDefault(c => c.ID == portalID); if (portal != null) { portal.ID = portalID; portal.Title = list.GetValue("Title"); portal.Type = type; portal.ConnName = list.GetValue("ConnName"); portal.SQL = list.GetValue("SQL"); portal.LinkUrl = list.GetValue("LinkUrl"); portal.MoreUrl = list.GetValue("MoreUrl"); portal.Height = list.GetValue("Height").Trim(); portal.DisplayType = list.GetValue("DisplayType").Trim(); } } } } else { Regex preg = new Regex(@"\{PORTALS}(.+?){/PORTALS}"); SQLHelper sqlHelper = SQLHelper.CreateSqlHelper(ConnEnum.Base); List <string> portalIDs = new List <string>(); foreach (Match m in preg.Matches(templet.Items)) { string portals = m.Value; string result = Regex.Match(portals, "(?<={PORTALS}).*?(?={/PORTALS})").Value; if (!string.IsNullOrEmpty(result)) { portalIDs.Add(result); } } List <string> nowPortal = new List <string>(); portalID = list.GetValue("Portal"); foreach (string item in portalID.Split(',')) { if (portalIDs.Count > 0) { var query = sqlHelper.ExecuteScalar(string.Format("select 1 from S_A_Portal where ID In ({0}) and LinkUrl like '%{1}.cshtml%'", PortalHelper.SplitCondition(string.Join(",", portalIDs.ToArray())), item)); if (Convert.ToInt32(query) > 0) { throw new Exception("不能添加重复的块,请点击块后进行修改!"); } } var nowID = FormulaHelper.CreateGuid(); if (!html.Contains(nowID)) { entities.Set <S_A_Portal>().Add(new S_A_Portal() { ID = nowID, Title = EnumBaseHelper.GetEnumDescription(typeof(Base.Logic.DefaultPortal), item), Type = PortalType.Link.ToString(), LinkUrl = string.Format("/PortalLTE/Views/Main/{0}.cshtml", item) }); nowPortal.Add(nowID); } } portalID = string.Join(",", nowPortal.ToArray()); } int indexOf = html.IndexOf("</section>"); string reg = "(?<={PORTALS}).*?(?={/PORTALS})"; string firstHtml = html.Substring(0, indexOf); string lastHtml = html.Substring(indexOf, html.Length - indexOf); string MatchValue = Regex.Match(firstHtml, reg).Value; if (string.IsNullOrEmpty(MatchValue)) { if (!lastHtml.Contains(portalID)) { templet.Items = firstHtml + ("{PORTALS}" + portalID + "{/PORTALS}") + lastHtml; } } else { List <string> values = new List <string>(); foreach (Match m in Regex.Matches(firstHtml, reg)) { values.Add(m.Value); } var target = string.Join(",", values.ToArray()); if (!firstHtml.Contains(portalID) && !lastHtml.Contains(portalID)) { values.Add(portalID); } firstHtml = firstHtml.Replace(target, string.Join(",", values.ToArray())); templet.Items = firstHtml + lastHtml; } entities.SaveChanges(); } } catch (Exception e) { } return(portalID); }
public void AddWBSChildWithAdo(DataRow parentWBSNode, DataRow childWBSNode, DataTable wbsDt, List <S_T_WBSStructInfo> structList) { if (!childWBSNode.Table.Columns.Contains("AddState")) { childWBSNode.Table.Columns.Add("AddState"); } if (parentWBSNode["WBSType"] == null || parentWBSNode["WBSType"] == DBNull.Value || String.IsNullOrEmpty(parentWBSNode["WBSType"].ToString())) { throw new Formula.Exceptions.BusinessValidationException("必须指定父WBS节点的类型"); } if (childWBSNode["WBSType"] == null || childWBSNode["WBSType"] == DBNull.Value || String.IsNullOrEmpty(childWBSNode["WBSType"].ToString())) { throw new Formula.Exceptions.BusinessValidationException("必须指定WBS节点的类型"); } var stNode = structList.FirstOrDefault(c => c.Code == parentWBSNode["WBSType"].ToString()); if (stNode == null) { throw new Formula.Exceptions.BusinessException("【" + parentWBSNode["Name"].ToString() + "】未获取WBS结构定义对象,无法新增子节点"); } if (!stNode.ValidateChildren(childWBSNode["WBSType"].ToString())) { throw new Formula.Exceptions.BusinessException("【" + EnumBaseHelper.GetEnumDescription(typeof(WBSNodeType), parentWBSNode["WBSType"].ToString()) + "】节点下不包含【" + EnumBaseHelper.GetEnumDescription(typeof(WBSNodeType), childWBSNode["WBSType"].ToString()) + "】的子节点定义,无法新增子节点"); } if (childWBSNode["ID"] == null || childWBSNode["ID"] == DBNull.Value || String.IsNullOrEmpty(childWBSNode["ID"].ToString())) { childWBSNode["ID"] = FormulaHelper.CreateGuid(); } childWBSNode["ProjectInfoID"] = parentWBSNode["ProjectInfoID"]; childWBSNode["ParentID"] = parentWBSNode["ID"]; childWBSNode["PhaseCode"] = parentWBSNode["PhaseCode"]; childWBSNode["FullID"] = parentWBSNode["FullID"].ToString() + "." + childWBSNode["ID"].ToString(); childWBSNode["Level"] = childWBSNode["FullID"].ToString().Split('.').Length; childWBSNode["WBSStructCode"] = childWBSNode["WBSType"]; childWBSNode["AddState"] = true.ToString().ToLower(); var brothers = wbsDt.AsEnumerable().Where(c => c["ParentID"] != DBNull.Value && c["ParentID"].ToString() == parentWBSNode["ID"].ToString()).ToList(); if (brothers.Count == 0) { childWBSNode["CodeIndex"] = 1; } else { var maxCodeIndex = brothers.Where(c => c["CodeIndex"] != DBNull.Value && c["CodeIndex"] != null).Max(c => c["CodeIndex"]); if (maxCodeIndex != null) { childWBSNode["CodeIndex"] = Convert.ToInt32(maxCodeIndex) + 1; } else { childWBSNode["CodeIndex"] = 1; } } childWBSNode["State"] = ProjectCommoneState.Plan.ToString(); childWBSNode["SortIndex"] = childWBSNode["FullID"].ToString().Split('.').Length * 1000 + 0; if ((childWBSNode["WBSValue"] == null || childWBSNode["WBSValue"] == DBNull.Value || String.IsNullOrEmpty(childWBSNode["WBSValue"].ToString())) && stNode.IsDefineNode) { throw new Formula.Exceptions.BusinessException("枚举类WBS节点,必须指定WBSValue"); } //获取所有的上级节点,填充WBS类别属性字段 var ancestors = wbsDt.AsEnumerable().Where(c => childWBSNode["FullID"].ToString().StartsWith(c["FullID"].ToString())); foreach (var ancestor in ancestors) { var fieldName = ancestor["WBSType"].ToString() + "Code"; if (childWBSNode.Table.Columns.Contains(fieldName)) { childWBSNode[fieldName] = ancestor["WBSValue"]; } } if (childWBSNode.Table.Columns.Contains(childWBSNode["WBSType"].ToString() + "Code")) { childWBSNode[childWBSNode["WBSType"].ToString() + "Code"] = childWBSNode["WBSValue"]; } wbsDt.Rows.Add(childWBSNode); }
private string[] createPieSql() { string queryData = this.Request["QueryData"]; string DeptID = Config.Constant.OrgRootID; var type = PieAnlysisType.CurrentYearReceiptValue; string group = GraphicPieGroupType.Industry.ToString(); var result = new string[3]; if (!String.IsNullOrEmpty(queryData)) { var query = JsonHelper.ToObject(queryData); if (!String.IsNullOrEmpty(query.GetValue("PieDept"))) { DeptID = query.GetValue("PieDept"); } if (!String.IsNullOrEmpty(query.GetValue("PieAnlysisValue"))) { type = (PieAnlysisType)Enum.Parse(typeof(PieAnlysisType), query.GetValue("PieAnlysisValue")); } if (!String.IsNullOrEmpty(query.GetValue("PieDept"))) { DeptID = query.GetValue("PieDept"); } if (!String.IsNullOrEmpty(query.GetValue("PieDimensionType"))) { group = query.GetValue("PieDimensionType"); } } //查询当年实际收款 string receiptSql = @"select top 10 Sum(ReceiptValue) as valueField,{1} as nameField from (select Sum(Amount) as ReceiptValue,CustomerID from dbo.S_C_Receipt where CustomerID is not null {0} group by CustomerID) ReceiptInfo left join S_F_Customer on ReceiptInfo.CustomerID = S_F_Customer.ID group by {1}"; //合同 string contractSql = @"select top 10 Sum(ContractValue) as valueField,{1} as nameField from ( select Sum(ContractRMBAmount) as ContractValue,PartyAID from S_C_ManageContract where PartyAID is not null {0} group by PartyAID) TableInfo left join S_F_Customer on PartyAID = S_F_Customer.ID group by {1}"; //合同余额 string remainContractSql = @"select top 10 Sum(ContractValue) as valueField,{1} as nameField from ( select Sum( isnull(ContractRMBAmount,0)-isnull(SummaryReceiptValue,0)-isnull(SummaryBadDebtValue,0)) as ContractValue,PartyAID from S_C_ManageContract where PartyAID is not null {0} group by PartyAID) TableInfo left join S_F_Customer on PartyAID = S_F_Customer.ID group by {1}"; //应收款 string recivableSql = @"select top 10 case when Sum(ContractValue)<0 then 0 else Sum(ContractValue) end as valueField,{1} as nameField from ( select Sum(isnull(SummaryInvoiceValue,0)-isnull(SummaryReceiptValue,0)-isnull(SummaryBadDebtValue,0)) as ContractValue,PartyAID from S_C_ManageContract where PartyAID is not null {0} group by PartyAID) TableInfo left join S_F_Customer on PartyAID = S_F_Customer.ID group by {1}"; string whereStr = ""; result[1] = EnumBaseHelper.GetEnumDescription(typeof(PieAnlysisType), type.ToString()); result[2] = EnumBaseHelper.GetEnumDescription(typeof(PieAnlysisType), type.ToString()); switch (type) { default: case PieAnlysisType.CurrentYearReceiptValue: whereStr = " and BelongYear='" + DateTime.Now.Year + "' "; if (DeptID != Config.Constant.OrgRootID) { whereStr += " and ReceiptMasterUnitID='" + DeptID + "'"; } result[0] = String.Format(receiptSql, whereStr, group); break; case PieAnlysisType.CurrentYearSignContractValue: whereStr = " and IsSigned = '" + ContractIsSigned.Signed + "' and BelongYear='" + DateTime.Now.Year + "' "; if (DeptID != Config.Constant.OrgRootID) { whereStr += " and HeadOfSalesDeptID='" + DeptID + "'"; } result[0] = String.Format(contractSql, whereStr, group); break; case PieAnlysisType.ReceivableValue: whereStr = " and IsSigned = '" + ContractIsSigned.Signed + "' "; if (DeptID != Config.Constant.OrgRootID) { whereStr += " and HeadOfSalesDeptID='" + DeptID + "'"; } result[0] = String.Format(recivableSql, whereStr, group); break; case PieAnlysisType.RemainContractValue: whereStr = " and IsSigned = '" + ContractIsSigned.Signed + "' "; if (DeptID != Config.Constant.OrgRootID) { whereStr += " and HeadOfSalesDeptID='" + DeptID + "'"; } result[0] = String.Format(remainContractSql, whereStr, group); break; case PieAnlysisType.UnSignContractValue: whereStr = " and (IsSigned != '" + ContractIsSigned.Signed + "' or IsSigned is null) "; if (DeptID != Config.Constant.OrgRootID) { whereStr += " and HeadOfSalesDeptID='" + DeptID + "'"; } result[0] = String.Format(contractSql, whereStr, group); break; } return(result); }
protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew) { List <Dictionary <string, object> > lostReplenishList = null; List <Dictionary <string, object> > replenishList = new List <Dictionary <string, object> >(); S_NodeInfo nodeInfo = null; S_FileInfo fileInfo = null; //遗失登记 if (dic.ContainsKey("LostDetail")) { lostReplenishList = JsonHelper.ToList(dic["LostDetail"]); //遗失损毁数量校验 LostDamageVerifica(dic, lostReplenishList); } else { lostReplenishList = JsonHelper.ToList(dic["Detail"]);//补录 } if (lostReplenishList.Count <= 0) { throw new Formula.Exceptions.BusinessException("请添加内容之后,再保存!"); } var entities = Formula.FormulaHelper.GetEntities <DocConstEntities>(); InventoryType stateType = new InventoryType(); foreach (var lostReplenishDetail in lostReplenishList) { string relateID = lostReplenishDetail.ContainsKey("RelateDocID") ? lostReplenishDetail["RelateDocID"].ToString() : "";//文件或节点ID string spaceID = lostReplenishDetail.ContainsKey("SpaceID") ? lostReplenishDetail["SpaceID"].ToString() : ""; S_DOC_Space space = Formula.FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(spaceID)); string relateDocType = lostReplenishDetail.ContainsKey("RelateDocType") ? lostReplenishDetail["RelateDocType"].ToString() : "";//文件或结点 string state = ""; if (dic.ContainsKey("LostDetail")) { state = lostReplenishDetail.ContainsKey("LoseDamageState") ? lostReplenishDetail["LoseDamageState"].ToString() : "";//遗失损毁状态 } //遗失或损毁补录份数 #region 库存数量的增减 int LostReplenishCount = 0; int datilCount = 0;//补录份数可能为负数 if (state.Equals(InventoryType.Destroy.ToString()) || state.Equals(InventoryType.Lose.ToString())) { stateType = state.Equals(InventoryType.Destroy.ToString()) ? InventoryType.Destroy : InventoryType.Lose; LostReplenishCount = Convert.ToInt32(lostReplenishDetail["LoseCount"]); LostReplenishCount = -LostReplenishCount; } else { stateType = InventoryType.Replenish; LostReplenishCount = Convert.ToInt32(lostReplenishDetail["ReplenishCount"]); } datilCount = stateType == InventoryType.Replenish? LostReplenishCount:-LostReplenishCount; if (relateDocType == "Node") { nodeInfo = new S_NodeInfo(relateID, space); InventoryFO.CreateInventoryLedger(nodeInfo, stateType, LostReplenishCount, LostReplenishCount, "", "", "", EnumBaseHelper.GetEnumDescription(stateType.GetType(), stateType.ToString()) + "份数:" + datilCount + "份");//入库 } else { fileInfo = new S_FileInfo(relateID, space); InventoryFO.CreateInventoryLedger(fileInfo, stateType, LostReplenishCount, LostReplenishCount, "", "", "", EnumBaseHelper.GetEnumDescription(stateType.GetType(), stateType.ToString()) + "份数:" + datilCount + "份"); } #endregion if (dic.ContainsKey("LostDetail")) { AddLostDamage(dic, lostReplenishDetail, entities);//遗失 } else { AddReplenish(dic, lostReplenishDetail, entities, ref replenishList);//补录 } } if (dic.ContainsKey("Detail")) { dic["Detail"] = JsonHelper.ToJson(replenishList).ToString(); } entities.SaveChanges(); }
private void Lost(Dictionary <string, object> row) { var lostNumber = 0; int.TryParse(row.GetValue("LostNumber"), out lostNumber); var id = row.GetValue("ID"); var borrowDetail = this.entities.Set <S_BorrowDetail>().FirstOrDefault(a => a.ID == id); if (lostNumber > 0 && borrowDetail != null) { borrowDetail.LostUserID = row.GetValue("LostUserID"); borrowDetail.LostUserName = row.GetValue("LostUserName"); borrowDetail.LostDeptID = row.GetValue("LostDeptID"); borrowDetail.LostDeptName = row.GetValue("LostDeptName"); borrowDetail.LostNumber = (borrowDetail.LostNumber ?? 0) + lostNumber; borrowDetail.LostDate = Convert.ToDateTime(row.GetValue("LostDate")); borrowDetail.LostRemarks = row.GetValue("LostRemarks"); var isFinish = ((borrowDetail.LendNumber ?? 0) - (borrowDetail.ReturnNumber ?? 0) - (borrowDetail.LostNumber ?? 0)) == 0; if (isFinish) { borrowDetail.BorrowState = BorrowDetailState.Finish.ToString(); } if (borrowDetail.DetailType == NodeType.Node.ToString()) { var space = DocConfigHelper.CreateConfigSpaceByID(borrowDetail.SpaceID); var nodeInfo = new S_NodeInfo(borrowDetail.RelateID, space); InventoryFO.CreateInventoryLedger(nodeInfo, InventoryType.Lose, 0 - lostNumber, 0, borrowDetail.ID, borrowDetail.LostUserID, borrowDetail.LostUserName, EnumBaseHelper.GetEnumDescription(InventoryType.Lose.GetType(), InventoryType.Lose.ToString()) + "份数:" + lostNumber + "份"); if (isFinish) { nodeInfo.DataEntity.SetValue("BorrowState", BorrowReturnState.Return.ToString()); } nodeInfo.Save(false); } else { var space = DocConfigHelper.CreateConfigSpaceByID(borrowDetail.SpaceID); var fileInfo = new S_FileInfo(borrowDetail.RelateID, space); InventoryFO.CreateInventoryLedger(fileInfo, InventoryType.Lose, 0 - lostNumber, 0, borrowDetail.ID, borrowDetail.LostUserID, borrowDetail.LostUserName, EnumBaseHelper.GetEnumDescription(InventoryType.Lose.GetType(), InventoryType.Lose.ToString()) + "份数:" + lostNumber + "份"); if (isFinish) { fileInfo.DataEntity.SetValue("BorrowState", BorrowReturnState.Return.ToString()); } fileInfo.Save(false); } CreateLoseReplenish(borrowDetail); } }
private void Lend(Dictionary <string, object> row) { var lendNumber = 0; int.TryParse(row.GetValue("LendNumber"), out lendNumber); var id = row.GetValue("ID"); var borrowDetail = this.entities.Set <S_BorrowDetail>().FirstOrDefault(a => a.ID == id); var isNew = false; if (lendNumber > 0) { #region 部分借阅 if (borrowDetail == null) { if (string.IsNullOrEmpty(id)) { id = FormulaHelper.CreateGuid(); } borrowDetail = new S_BorrowDetail { ID = id, SpaceID = row.GetValue("SpaceID"), SpaceName = row.GetValue("SpaceName"), DataType = row.GetValue("DataType"), DetailType = row.GetValue("DetailType"), RelateID = row.GetValue("RelateID"), ConfigID = row.GetValue("ConfigID"), Name = row.GetValue("Name"), Code = row.GetValue("Code"), LendUserID = row.GetValue("LendUserID"), LendUserName = row.GetValue("LendUserName"), LendDeptID = row.GetValue("LendDeptID"), LendDeptName = row.GetValue("LendDeptName"), ParentID = row.GetValue("ParentID") }; var applyNumber = 0; int.TryParse(row.GetValue("ApplyNumber"), out applyNumber); borrowDetail.ApplyNumber = applyNumber; this.entities.Set <S_BorrowDetail>().Add(borrowDetail); isNew = true; var parent = this.entities.Set <S_BorrowDetail>().FirstOrDefault(a => a.ID == borrowDetail.ParentID); if (parent != null) { parent.HasChild = TrueOrFalse.True.ToString(); } } #endregion borrowDetail.LendUserID = row.GetValue("LendUserID"); borrowDetail.LendUserName = row.GetValue("LendUserName"); borrowDetail.LendDeptID = row.GetValue("LendDeptID"); borrowDetail.LendDeptName = row.GetValue("LendDeptName"); borrowDetail.LendNumber = (borrowDetail.LendNumber ?? 0) + lendNumber; if (borrowDetail.LendDate == null) { borrowDetail.LendDate = Convert.ToDateTime(row.GetValue("LendDate")); borrowDetail.BorrowExpireDate = Convert.ToDateTime(row.GetValue("BorrowExpireDate")); } borrowDetail.BorrowState = BorrowDetailState.ToReturn.ToString(); if (borrowDetail.DetailType == NodeType.Node.ToString()) { var space = DocConfigHelper.CreateConfigSpaceByID(borrowDetail.SpaceID); var nodeInfo = new S_NodeInfo(borrowDetail.RelateID, space); InventoryFO.CreateInventoryLedger(nodeInfo, InventoryType.Lend, 0, (0 - lendNumber), borrowDetail.ID, borrowDetail.LendUserID, borrowDetail.LendUserName, EnumBaseHelper.GetEnumDescription(InventoryType.Lend.GetType(), InventoryType.Lend.ToString()) + "份数:" + lendNumber + "份"); nodeInfo.DataEntity.SetValue("BorrowState", BorrowReturnState.Borrow.ToString()); nodeInfo.Save(false); if (isNew) { borrowDetail.Name = nodeInfo.CreateCarName(); } } else { var space = DocConfigHelper.CreateConfigSpaceByID(borrowDetail.SpaceID); var fileInfo = new S_FileInfo(borrowDetail.RelateID, space); InventoryFO.CreateInventoryLedger(fileInfo, InventoryType.Lend, 0, (0 - lendNumber), borrowDetail.ID, borrowDetail.LendUserID, borrowDetail.LendUserName, EnumBaseHelper.GetEnumDescription(InventoryType.Lend.GetType(), InventoryType.Lend.ToString()) + "份数:" + lendNumber + "份"); fileInfo.DataEntity.SetValue("BorrowState", BorrowReturnState.Borrow.ToString()); fileInfo.Save(false); if (isNew) { borrowDetail.Name = fileInfo.CreateCarName(); } } } else if (borrowDetail != null) { if (borrowDetail.LendDate == null) { borrowDetail.LendDate = Convert.ToDateTime(row.GetValue("LendDate")); } if (borrowDetail.BorrowExpireDate == null) { borrowDetail.BorrowExpireDate = Convert.ToDateTime(row.GetValue("BorrowExpireDate")); } } }