//搜索 public void Searchs() { lvPerson.ContextMenuStrip = null; lvPerson.Items.Clear(); _personName = SearchName.Text; _personTel = SearchTel.Text; _personCel = SearchCel.Text; _userID = loginfrm.UserID; TXL_Persons myPerson = new TXL_Persons(); myPerson.UserID = UserID; myPerson.PersonName = PersonName; myPerson.Tel = PersonTel; myPerson.PersonCel = PersonCel; OleDbDataReader myReader = myPerson.Search(); while (myReader.Read()) { ListViewItem myItem = new ListViewItem(); myItem.Text = myReader["PersonName"].ToString(); myItem.ImageIndex = 0; myItem.SubItems.Add(myReader["PersonTel"].ToString()); myItem.SubItems.Add(myReader["PersonQQ"].ToString()); lvPerson.Items.Add(myItem); } myReader.Close(); }
//删除分组 private void DeleteCats_Click(object sender, EventArgs e) { System.Windows.Forms.DialogResult dr; dr = MessageBox.Show(this, "删除分组会将分组内的联系人删除!确定要删除吗?", "删除", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); switch (dr) { case System.Windows.Forms.DialogResult.Yes: TXL_Cats myObj = new TXL_Cats(); _catName = this.tvCats.SelectedNode.Text; _userID = loginfrm.UserID; myObj.UserID = UserID; myObj.CatName = CatName; myObj.Delete(); _catID = myObj.GetCatID(); TXL_Persons myPerson = new TXL_Persons(); myPerson.CatId = CatID; myPerson.UserID = UserID; MessageBox.Show("删除成功"); this.tvCats.SelectedNode.Remove(); break; } }
private void AddPersons_Load(object sender, EventArgs e) { //加载分类 TXL_Cats myCats = new TXL_Cats(); _userID = loginfrm.UserID; myCats.UserID = UserID; CatsText.DisplayMember = "CatName"; CatsText.ValueMember = "CatId"; CatsText.DataSource = myCats.GetAllTXLCatsDS().Tables[0]; if (whichBtn == true) { SuerBtn.Text = "添加联系人"; this.Text = "添加联系人"; } else { this.Text = "修改联系人"; SuerBtn.Text = "修改联系人"; //在文本框中赋值 TXL_Persons myPerson = new TXL_Persons(); _personId = mainfrm.PersonID; myPerson.PersonId = PersonId; OleDbDataReader myReader = myPerson.GetAllPerson(); while (myReader.Read()) { _personName = myReader["PersonName"].ToString(); _catId = int.Parse(myReader["CatId"].ToString()); _personTel = myReader["PersonTel"].ToString(); _personCel = myReader["PersonCel"].ToString(); _personQQ = myReader["PersonQQ"].ToString(); _personAddress = myReader["PersonAddress"].ToString(); _remark = myReader["Remark"].ToString(); myPerson.CatId = CatId; _cats = myPerson.GetCatName(); UserNameText.Text = PersonName; CatsText.Text = Cats; QQText.Text = PersonQQ; PersonTelText.Text = PersonTel; PersonCellText.Text = PersonCel; AddressText.Text = PersonAddress; RemarkText.Text = Remark; } } }
//鼠标单击树节点发生 private void tvCats_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { TXL_Cats myObj = (TXL_Cats)e.Node.Tag; lvPerson.Items.Clear(); TXL_Persons myPerson = new TXL_Persons(); OleDbDataReader myReader = myPerson.GetAllTXLCatsDR(myObj.CatId); //得到catID _catID = (int)myObj.CatId; while (myReader.Read()) { ListViewItem myItem = new ListViewItem(); myItem.Text = myReader["PersonName"].ToString(); myItem.ImageIndex = 0; myItem.SubItems.Add(myReader["PersonTel"].ToString()); myItem.SubItems.Add(myReader["PersonQQ"].ToString()); lvPerson.Items.Add(myItem); } myReader.Close(); }
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("修改成功!"); } }
private void AddPersons_Load(object sender, EventArgs e) { //加载分类 TXL_Cats myCats = new TXL_Cats(); _userID = loginfrm.UserID; myCats.UserID = UserID; CatsText.DisplayMember = "CatName"; CatsText.ValueMember = "CatId"; CatsText.DataSource=myCats.GetAllTXLCatsDS().Tables[0]; if (whichBtn == true) { SuerBtn.Text = "添加联系人"; this.Text = "添加联系人"; } else { this.Text = "修改联系人"; SuerBtn.Text = "修改联系人"; //在文本框中赋值 TXL_Persons myPerson = new TXL_Persons(); _personId = mainfrm.PersonID; myPerson.PersonId = PersonId; OleDbDataReader myReader = myPerson.GetAllPerson(); while (myReader.Read()) { _personName = myReader["PersonName"].ToString(); _catId = int.Parse(myReader["CatId"].ToString()); _personTel=myReader["PersonTel"].ToString(); _personCel=myReader["PersonCel"].ToString(); _personQQ=myReader["PersonQQ"].ToString(); _personAddress=myReader["PersonAddress"].ToString(); _remark = myReader["Remark"].ToString(); myPerson.CatId = CatId; _cats = myPerson.GetCatName(); UserNameText.Text = PersonName; CatsText.Text = Cats; QQText.Text = PersonQQ; PersonTelText.Text = PersonTel; PersonCellText.Text = PersonCel; AddressText.Text = PersonAddress; RemarkText.Text = Remark; } } }