private void btnSelect_Click(object sender, EventArgs e) { string typeid = cboType.SelectedValue.ToString(); List <Friends> friend = FriendsOp.GetFriendsByTypeId(typeid); dgvAllFriends.DataSource = friend; }
private void btnSave_Click(object sender, EventArgs e) { bool result = FriendsOp.IxExist(txtName.Text); if (result) { MessageBox.Show("联系人" + txtName.Text + "已存在!\n", "提示", MessageBoxButtons.OK); } else { Friends friend = new Friends(); friend.Name = txtName.Text; friend.Fid = Convert.ToInt32(cboType.SelectedValue); friend.Tel = txtTel.Text; friend.Email = txtEmail.Text; friend.Address = txtAdress.Text; int cnt = FriendsOp.InsertFriend(friend); if (cnt > 0) { if (MessageBox.Show("保存成功,是否继续", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { txtName.Text = ""; txtAdress.Text = ""; txtEmail.Text = ""; txtTel.Text = ""; cboType.SelectedIndex = -1; } else { Application.Exit(); } } else { MessageBox.Show("保存失败,是否继续", "提示"); } } }