private TreeNode BuildNodeFromDr(DataRow dr) { TreeNode node = new TreeNode(); int type = Convert.ToInt32(dr[5].ToString()); Thing thing = new Thing(); thing.Id = Convert.ToInt32(dr[0].ToString()); thing.NodeType = type; thing.NoteDate = Convert.ToDateTime(dr[2].ToString()); thing.Title = dr[1].ToString(); thing.ParentId = Convert.ToInt32(dr[4].ToString()); thing.Context = dr[3].ToString(); node.ToolTipText = dr[2].ToString(); node.Text = thing.Title; node.Tag = thing; int imageindex = 1; if (type == (int)ThingType.Folder) { imageindex = 2; string sql = "select count(*) from table_things where i_parent_id='" + thing.Id + "'"; object obj = FT.DAL.DataAccessFactory.GetDataAccess().SelectScalar(sql); int tmp = Convert.ToInt32(obj); if (tmp > 0) { node.Text += "(" + tmp + ")"; } } else if (type == (int)ThingType.Schedule) { imageindex = 3; } else if (type == (int)ThingType.Task) { imageindex = 4; } else if (type == (int)ThingType.JustThing) { imageindex = 5; } node.ImageIndex = imageindex; node.SelectedImageIndex = imageindex; return node; }
private TreeNode CreateSubNode(TreeNode parent,ThingType type,string text) { TreeNode temp; temp = new TreeNode(); temp.Text = text; Thing thing = new Thing(); thing.NoteDate = System.DateTime.Now; Thing tmp = parent.Tag as Thing; thing.ParentId = tmp.Id; thing.Title = text; thing.NodeType = (int)type; int imageindex = 1; if (type == ThingType.Folder) { imageindex = 2; } else if (type == ThingType.Schedule) { imageindex = 3; thing.Context=this.editor1.GetTemplateContext("�ҵļƻ�����.html"); } else if (type == ThingType.Task) { imageindex = 4; thing.Context = this.editor1.GetTemplateContext("�ҵĴ�������.html"); } else if (type == ThingType.JustThing) { imageindex = 5; thing.Context = this.editor1.GetTemplateContext("�ҵļ���.html"); } FT.DAL.Orm.SimpleOrmOperator.Create(thing); temp.Tag =thing; temp.ImageIndex = imageindex; temp.SelectedImageIndex = imageindex; this.ShowThing(temp); return temp; }
private void ShowThing(TreeNode temp) { if (temp != null) { Thing thing = temp.Tag as Thing; if(this.currentThing==null) { //this.currentThing = thing; //this.currentNode = temp; } else { //this.currentNode.BackColor = this.treeView1.BackColor; this.currentThing.Context = this.editor1.DocumentText; if (this.currentThing.Id < 1) { if (FT.DAL.Orm.SimpleOrmOperator.Create(this.currentThing)) { this.currentNode.Tag = this.currentThing; } } else { if (FT.DAL.Orm.SimpleOrmOperator.Update(this.currentThing)) { this.currentNode.Tag = this.currentThing; } } } this.currentNode = temp; this.currentThing = thing; this.editor1.DocumentText = thing.Context; //this.currentNode.BackColor = this.treeView1.BackColor; } }
private TreeNode CreateSecondNode(string type,int parentid) { TreeNode temp; temp = new TreeNode(); temp.Text = type; Thing tmp = new Thing(); tmp.Id = parentid; temp.Tag = tmp; temp.ImageIndex = 1; temp.SelectedImageIndex = 1; return temp; }