Example #1
0
        protected override void AddObject()
        {
            CodeEditWindow form = new CodeEditWindow(3, CharacterCasing.Upper, false);
            form.FormClosed += (o, e) =>
            {
                if (form.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    T_StockCode stockCode =new T_StockCode() { Code = form.Code, Desc = form.Desc };

                    if (this.StockCodeTreeList.DataSource != null)
                    {
                        List<T_StockCode> codeList = this.StockCodeTreeList.DataSource as List<T_StockCode>;
                        stockCode.Id = codeList.Select(t => t.Id).Max() + 1;
                    }
                    else
                    {
                        stockCode.Id = 0;
                    }

                    if (this.StockCodeTreeList.FocusedNode == null)
                    {
                        stockCode.ParentId = -1;
                    }
                    else
                    {
                        stockCode.ParentId = Convert.ToInt16(this.StockCodeTreeList.FocusedNode.GetValue("Id"));
                    }

                    //_Proxy.AddStockCode(stockCode);

                    this.StockCodeTreeList.BeginUnboundLoad();
                    DevExpress.XtraTreeList.Nodes.TreeListNode node = this.StockCodeTreeList.AppendNode(stockCode, this.StockCodeTreeList.FocusedNode);
                    node.SetValue("Id", stockCode.Id);
                    node.SetValue("Code", stockCode.Code);
                    node.SetValue("Desc", stockCode.Desc);
                    this.StockCodeTreeList.EndUnboundLoad();
                }
            };

            form.ShowDialog();
        }
Example #2
0
        private void InitStockCodeList()
        {
            StockCodeList = new List<T_StockCode>();

            T_StockCode codeA00 = new T_StockCode() { Code = "A00", Desc = "A区", ParentId = -1, Id = 0 };
            T_StockCode codeA01 = new T_StockCode() { Code = "A01", Desc = "A区01", ParentId = 0, Id = 3 };
            T_StockCode codeA02 = new T_StockCode() { Code = "A02", Desc = "A区02", ParentId = 0, Id = 4 };
            T_StockCode codeA03 = new T_StockCode() { Code = "A03", Desc = "A区03", ParentId = 0, Id = 5 };
            T_StockCode codeB00 = new T_StockCode() { Code = "B00", Desc = "B区", ParentId = -1, Id = 1 };
            T_StockCode codeB01 = new T_StockCode() { Code = "B01", Desc = "B区01", ParentId = 1, Id = 6 };
            T_StockCode codeC00 = new T_StockCode() { Code = "C00", Desc = "C区", ParentId = -1, Id = 2 };
            T_StockCode codeC01 = new T_StockCode() { Code = "C01", Desc = "C区01", ParentId = 2, Id = 7 };

            StockCodeList.Add(codeA00);
            StockCodeList.Add(codeA01);
            StockCodeList.Add(codeA02);
            StockCodeList.Add(codeA03);
            StockCodeList.Add(codeB00);
            StockCodeList.Add(codeB01);
            StockCodeList.Add(codeC00);
            StockCodeList.Add(codeC01);
        }
Example #3
0
 public void UpdateStockCode(T_StockCode stockCode)
 {
     StockCodeList.Remove(StockCodeList.Find(o => o.Id == stockCode.Id));
     StockCodeList.Add(stockCode);
 }
Example #4
0
 public void AddStockCode(T_StockCode stockCode)
 {
     StockCodeList.Add(stockCode);
 }