//删除主题 void Button2Click(object sender, EventArgs e) { if (this.treeView1.SelectedNode == null) { MessageBox.Show("请选择要删除的主题"); return; } else { TestTheme theme = this.treeView1.SelectedNode.Tag as TestTheme; if (theme.Id == 99999) { MessageBox.Show("默认主题不能删除", "提示"); } else { DialogResult a = MessageBox.Show("您正准备删除主题,与之关联的缺陷将一并删除", "删除", MessageBoxButtons.OKCancel); if (DialogResult.OK == a) { TestunitthemeDao.DelGuanLianUnit(null, theme.Id.ToString()); TestThemeDao.DeleteTheme(theme.Id.ToString()); MessageBox.Show("删除成功", "提示"); getThemeTree(); } } } }
void getThemeTree() { if (unitid != null) { selthem = TestThemeDao.getTestThemeByUnitid(unitid); } List <TestTheme> ttlist = TestThemeDao.getAllTestThemeByPersonname(System.Configuration.ConfigurationManager.AppSettings["username"]); this.treeView1.Nodes.Clear(); //List<TreeNode> maintreelist = new List<TreeNode>(); TreeNode main = new TreeNode(); //默认主题 TreeNode tmp = new TreeNode("默认主题"); TestTheme default_tt = new TestTheme(); default_tt.Id = 99999; default_tt.Personid = 0; default_tt.Personname = "朱新培"; tmp.Tag = default_tt; setTreeNodeCheck(tmp); main.Nodes.Add(tmp); foreach (var element in ttlist) { TreeNode tmp1 = null; tmp1 = new TreeNode(element.Favname); tmp1.Tag = element; if (element.Parentid == 0) { main.Nodes.Add(tmp1); setTreeNodeCheck(tmp1); } else { creatTree(tmp1, main); } } TreeNode[] tn = new TreeNode[main.Nodes.Count]; main.Nodes.CopyTo(tn, 0); this.treeView1.Nodes.AddRange(tn); this.treeView1.ExpandAll(); this.treeView1.SelectedNode = treeView1.Nodes[0]; }
void getThemeTree() { List <TestTheme> ttlist = TestThemeDao.getAllTestThemeByPersonname(System.Configuration.ConfigurationManager.AppSettings["username"]); this.treeView1.Nodes.Clear(); //List<TreeNode> maintreelist = new List<TreeNode>(); TreeNode main = new TreeNode(); //默认主题 TreeNode tmp = new TreeNode("默认主题"); TestTheme default_tt = new TestTheme(); default_tt.Id = 99999; string personid = GlobalParams.UserId; default_tt.Personid = ((personid == null)?0:Int32.Parse(personid)); default_tt.Personname = GlobalParams.Username; tmp.Tag = default_tt; main.Nodes.Add(tmp); foreach (var element in ttlist) { TreeNode tmp1 = null; tmp1 = new TreeNode(element.Favname); tmp1.Tag = element; if (element.Parentid == 0) { main.Nodes.Add(tmp1); } else { creatTree(tmp1, main); } } TreeNode[] tn = new TreeNode[main.Nodes.Count]; main.Nodes.CopyTo(tn, 0); this.treeView1.Nodes.AddRange(tn); this.treeView1.SelectedNode = treeView1.Nodes[0]; //让选中项背景色呈现蓝色 treeView1.SelectedNode.BackColor = Color.SteelBlue; //前景色为白色 treeView1.SelectedNode.ForeColor = Color.White; }
/// <summary> /// 绑定数据到控件 /// </summary> void TestUnitBingData() { this.multiColumnFilterComboBox1.Items.Clear(); this.multiColumnFilterComboBox1.Items.Add(this.tu); this.multiColumnFilterComboBox1.DisplayMember = "Packagename"; this.multiColumnFilterComboBox1.ValueMember = "Packageid"; this.multiColumnFilterComboBox1.SelectedIndex = 0; this.multiColumnFilterComboBox1.Enabled = false; this.comboBox1.Text = tu.Adminname; this.comboBox2.Text = tu.Modulename; this.comboBox3.Text = tu.Projectname; this.comboBox4.Text = tu.Testorname; this.comboBox5.Text = tu.Buglevel; this.comboBox6.Text = tu.Bugtype; this.textBox9.Text = tu.Testtitle; this.textBox1.Text = tu.Unitno; this.textBox1.ReadOnly = true; MemoryStream stream = new MemoryStream(tu.Testcontent); this.richTextBox1.LoadFile(stream, RichTextBoxStreamType.RichText); if (!this.linkLabel1.IsDisposed) { if (TestThemeDao.getTestThemeByUnitid(tu.Id.ToString()).Count > 0) { this.linkLabel1.Text = "已被关注"; } else { this.linkLabel1.Text = "未被关注"; } } }
/// <summary> /// 绑定数据到控件_新建编辑 /// </summary> void TestUnitBingData_Edit() { this.multiColumnFilterComboBox1.Items.Clear(); this.multiColumnFilterComboBox1.Items.Add(this.tu); this.multiColumnFilterComboBox1.DisplayMember = "Packagename"; this.multiColumnFilterComboBox1.ValueMember = "Packageid"; this.multiColumnFilterComboBox1.SelectedIndex = 0; this.multiColumnFilterComboBox1.Enabled = false; //绑定主管 foreach (DataRow element in this.Source_Person.Rows) { string tempid = element["id"].ToString(); if (Int32.Parse(tempid) == tu.Adminid) { int sel = this.Source_Person.Rows.IndexOf(element); this.comboBox1.SelectedIndex = sel; break; } } //绑定模块(平台) foreach (DataRow element in this.Source_Module.Rows) { string tempid = element["id"].ToString(); if (Int32.Parse(tempid) == tu.Moduleid) { int sel = this.Source_Module.Rows.IndexOf(element); this.comboBox2.SelectedIndex = sel; break; } } //绑定项目 foreach (DataRow element in this.Source_Project.Rows) { string tempid = element["id"].ToString(); if (Int32.Parse(tempid) == tu.Projectid) { int sel = this.Source_Project.Rows.IndexOf(element); this.comboBox3.SelectedIndex = sel; break; } } //绑定测试者 foreach (DataRow element in this.Source_testor.Rows) { string tempid = element["id"].ToString(); if (Int32.Parse(tempid) == tu.Testorid) { int sel = this.Source_Project.Rows.IndexOf(element); this.comboBox4.SelectedIndex = sel; break; } } //绑定BUG等级 foreach (var element in CommonConst.BUGLEVEL) { if (element.Equals(tu.Buglevel)) { this.comboBox5.SelectedItem = element; break; } } //绑定BUG类型 foreach (var element in CommonConst.BUGTYPE) { if (element.Equals(tu.Bugtype)) { this.comboBox6.SelectedItem = element; break; } } this.textBox9.Text = tu.Testtitle; this.textBox1.Text = tu.Unitno; this.textBox1.ReadOnly = true; MemoryStream stream = new MemoryStream(tu.Testcontent); this.richTextBox1.LoadFile(stream, RichTextBoxStreamType.RichText); if (!this.linkLabel1.IsDisposed) { if (TestThemeDao.getTestThemeByUnitid(tu.Id.ToString()).Count > 0) { this.linkLabel1.Text = "已被关注"; } else { this.linkLabel1.Text = "未被关注"; } } }