//treeview判断右键 打开窗口修改分组名 private void tvCats_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { if (tvCats.SelectedNode == null) { tvCats.ContextMenuStrip = null; //return; } else { //treeview添加右键菜单 tvCats.ContextMenuStrip = contextMenuStrip2; _catName = this.tvCats.SelectedNode.Text; _userID = loginfrm.UserID; TXL_Cats myObj = new TXL_Cats(); myObj.UserID = UserID; myObj.CatName = CatName; _catID = myObj.CatIds(); } } }
private void SuerBtn_Click(object sender, EventArgs e) { if (whichBtn == true) { //获取CatID号 int _catId = (int)CatsText.SelectedValue; TXL_Persons myObj = new TXL_Persons(); _personName = UserNameText.Text; _personTel = PersonTelText.Text; _personQQ = QQText.Text; _personAddress = AddressText.Text; myObj.UserID = UserID; myObj.Name = PersonName; myObj.Tel = PersonTel; myObj.QQ = PersonQQ; myObj.Address = PersonAddress; myObj.CatId = _catId; myObj.AddPersons(); MessageBox.Show("添加成功"); } else { TXL_Cats myCats = new TXL_Cats(); _cats = CatsText.Text; _userID = loginfrm.UserID; myCats.CatName = Cats; myCats.UserID = UserID; _catId = myCats.CatIds(); TXL_Persons myPerson = new TXL_Persons(); _personId = mainfrm.PersonID; _personName = UserNameText.Text; _personQQ = QQText.Text; _personTel = PersonTelText.Text; _personCel = PersonCellText.Text; _personAddress = AddressText.Text; _remark = RemarkText.Text; myPerson.PersonId = PersonId; myPerson.CatId = CatId; myPerson.PersonName = PersonName; myPerson.QQ = PersonQQ; myPerson.Tel = PersonTel; myPerson.PersonCel = PersonCel; myPerson.Address = PersonAddress; myPerson.Remark = Remark; myPerson.ChangPerson(); MessageBox.Show("修改成功!"); } }