protected override void AddObject() { CodeEditWindow form = new CodeEditWindow(2, CharacterCasing.Upper, false); form.FormClosed += (o, e) => { if (form.DialogResult == System.Windows.Forms.DialogResult.OK) { T_CodeType codeType = new T_CodeType() { Code = form.Code, Desc = form.Desc }; if (this.MatCodeTreeList.DataSource != null) { List<T_CodeType> codeList = this.MatCodeTreeList.DataSource as List<T_CodeType>; codeType.Id = codeList.Select(t => t.Id).Max() + 1; } else { codeType.Id = 0; } if (this.MatCodeTreeList.FocusedNode == null) { codeType.ParentId = -1; } else { codeType.ParentId = Convert.ToInt16(this.MatCodeTreeList.FocusedNode.GetValue("Id")); } //_Proxy.AddCodeType(codeType); this.MatCodeTreeList.BeginUnboundLoad(); DevExpress.XtraTreeList.Nodes.TreeListNode node = this.MatCodeTreeList.AppendNode(codeType, this.MatCodeTreeList.FocusedNode); node.SetValue("Id", codeType.Id); node.SetValue("Code", codeType.Code); node.SetValue("Desc", codeType.Desc); this.MatCodeTreeList.EndUnboundLoad(); } }; form.ShowDialog(); }
private void InitCodeTypeList() { CodeTypeList = new List<T_CodeType>(); T_CodeType typeA0 = new T_CodeType() { Code = "A0", Desc = "大类", ParentId = -1, Id = 0 }; T_CodeType typeA1 = new T_CodeType() { Code = "A1", Desc = "大类", ParentId = -1, Id = 1 }; T_CodeType typeB0 = new T_CodeType() { Code = "B0", Desc = "中类", ParentId = 0, Id = 2 }; T_CodeType typeB1 = new T_CodeType() { Code = "B1", Desc = "中类", ParentId = 0, Id = 3 }; T_CodeType typeC0 = new T_CodeType() { Code = "C1", Desc = "小类", ParentId = 2, Id = 4 }; T_CodeType typeC1 = new T_CodeType() { Code = "C2", Desc = "小类", ParentId = 2, Id = 5 }; CodeTypeList.Add(typeA0); CodeTypeList.Add(typeA1); CodeTypeList.Add(typeB0); CodeTypeList.Add(typeB1); CodeTypeList.Add(typeC0); CodeTypeList.Add(typeC1); }
public void UpdateCodeType(T_CodeType codeType) { CodeTypeList.Remove(CodeTypeList.Find(o => o.Id == codeType.Id)); CodeTypeList.Add(codeType); }
public void AddCodeType(T_CodeType codeType) { CodeTypeList.Add(codeType); }
protected override void EditObject() { if (this.StockCodeTreeList.FocusedNode == null) return; CodeEditWindow form = new CodeEditWindow(2, CharacterCasing.Upper, false); form.Code = this.StockCodeTreeList.FocusedNode.GetValue("Code").ToString(); form.Desc = this.StockCodeTreeList.FocusedNode.GetValue("Desc").ToString(); form.FormClosed += (o, e) => { T_CodeType codeType = new T_CodeType() { Code = form.Code, Desc = form.Desc, Id = Convert.ToInt16(this.StockCodeTreeList.FocusedNode.GetValue("Id")), ParentId = Convert.ToInt16(this.StockCodeTreeList.FocusedNode.GetValue("ParentId")) }; _Proxy.UpdateCodeType(codeType); this.StockCodeTreeList.FocusedNode.SetValue("Code", codeType.Code); this.StockCodeTreeList.FocusedNode.SetValue("Desc", codeType.Desc); }; form.ShowDialog(); }