/// <summary> /// 获取PNode集合并为其设置WBSCode编码 /// 2017/05/08(zhuguanjun) /// </summary> /// <param name="ProjectID">项目ID</param> /// <returns></returns> public List <PNode> SetWBSNo(string ProjectID) { int step = 0;//层级 List <PNode> listNode = new WBSBLL().GetNodes(ProjectID, null); IEnumerable <PNode> parentNode = null; parentNode = listNode.Where(t => string.IsNullOrEmpty(t.ParentID)).OrderBy(t => t.No); DataTable dt = GetWBSCodeList(ProjectID); //WBSCode集合 DomainDLL.WBSCode[] wbscodeArray = JsonHelper.TableToList <DomainDLL.WBSCode>(dt).OrderBy(t => t.CREATED).ToArray(); //dt转array if (wbscodeArray == null || wbscodeArray.Count() == 0) { return(null); } foreach (PNode parent in parentNode) { DomainDLL.WBSCode wc = wbscodeArray[step]; byte[] array = SetStepNo(wc.LengthName, wc.Orderr, parent.No); parent.WBSNo = Ascii2Str(array) + wc.BreakName; SetChildWBSNo(listNode, parent, step, wbscodeArray); } return(listNode); }
/// <summary> /// 添加 /// 2017/05/05(zhuguanjun) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { #region 检查 if (string.IsNullOrEmpty(ProjectId)) { MessageHelper.ShowMsg(MessageID.W000000002, MessageType.Alert, "项目"); return; } if (cmbOrder.SelectedIndex == -1) { MessageHelper.ShowMsg(MessageID.W000000002, MessageType.Alert, "序列"); return; } if (cmbLength.SelectedIndex == -1) { MessageHelper.ShowMsg(MessageID.W000000002, MessageType.Alert, "长度"); return; } if (cmbBreak.SelectedIndex == -1) { MessageHelper.ShowMsg(MessageID.W000000002, MessageType.Alert, "分隔符"); return; } #endregion DomainDLL.WBSCode code = new DomainDLL.WBSCode(); ComboItem item = (ComboItem)cmbOrder.SelectedItem; if (item != null) { code.Orderr = int.Parse(item.Value.ToString()); } ComboItem item1 = (ComboItem)cmbLength.SelectedItem; if (item1 != null) { code.Length = int.Parse(item1.Value.ToString()); } ComboItem item2 = (ComboItem)cmbBreak.SelectedItem; if (item2 != null) { code.Breakk = int.Parse(item2.Value.ToString()); } code.PID = ProjectId; JsonResult json = bll.SaveWBSCode(code); MessageHelper.ShowRstMsg(json.result); if (json.result) { btnClear_Click(null, null); } DataBind(); }