private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { var user = dataGridView1.Rows[e.RowIndex].DataBoundItem as TB_User; if (e.ColumnIndex < 0 || dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null) { return; } string buttonText = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); HandleData(() => { switch (buttonText) { case "重置密码": var succeed = BLLOperate.ModifyPassword(user.Id, "1"); MessageBox.Show(this, succeed ? "重置成功!" : "重置失败"); break; case "删除用户": var id = BLLOperate.DeleteItem <TB_User>(user.Id); MessageBox.Show(this, id > 0 ? "删除成功!" : "删除失败"); LoadUsers(); break; } }, s => MessageBox.Show(this, s)); }
/// <summary> /// 删除照片 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MIDeletePhoto_Click(object sender, EventArgs e) { HandleData(() => { foreach (ListViewItem item in listView1.SelectedItems) { var gallery = item.Tag as TB_Gallery; BLLOperate.DeleteItem <TB_Gallery>(gallery.Id); listView1.Items.Remove(listView1.SelectedItems[0]); } }, s => MessageBox.Show(this, s)); }
/// <summary> /// 删除联系人 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeleteContactPerson(object sender, EventArgs e) { if (tvItems.SelectedNode != null) { var contactPerson = tvItems.SelectedNode.Tag as TB_ContactPerson; HandleData(() => { BLLOperate.DeleteItem <TB_ContactPerson>(contactPerson.Id); tvItems.SelectedNode.Parent.Nodes.Remove(tvItems.SelectedNode); GetContactPersonsByUIdAndTypeId(contactPerson.UType); }, s => MessageBox.Show(this, s)); } }
/// <summary> /// 删除联系人组 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeleteGroup(object sender, EventArgs e) { if (tvItems.SelectedNode != null) { var contactPersonGroup = tvItems.SelectedNode.Tag as TB_ContactPersonGroup; HandleData(() => { BLLOperate.DeleteItem <TB_ContactPersonGroup>(contactPersonGroup.Id); if (tvItems.SelectedNode.Parent == null) { tvItems.Nodes.Remove(tvItems.SelectedNode); } else { tvItems.SelectedNode.Parent.Nodes.Remove(tvItems.SelectedNode); } }, s => MessageBox.Show(this, s)); } }
/// <summary> /// 删除选中 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelSelected_Click(object sender, EventArgs e) { if (cDataGridView.SelectedRows.Count == 0) { return; } if (MessageBox.Show(this, "确定删除选中的联系人?", "删除联系人", MessageBoxButtons.OKCancel) == DialogResult.OK) { HandleData(() => { foreach (DataGridViewRow selectedRow in cDataGridView.SelectedRows) { var contactPerson = selectedRow.DataBoundItem as TB_ContactPerson; BLLOperate.DeleteItem <TB_ContactPerson>(contactPerson.Id); } MessageBox.Show(this, "删除成功!"); tvItems_AfterSelect(null, null); }, s => MessageBox.Show(this, s)); } }
private void cDataGridView_CellClick(object sender, DataGridViewCellEventArgs e) { var contactPerson = cDataGridView.Rows[e.RowIndex].DataBoundItem as TB_ContactPerson; if (e.ColumnIndex < 0 || cDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value == null) { return; } string buttonText = cDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); HandleData(() => { switch (buttonText) { case "修改": var g = new ContactPersonOperate() { Text = "修改联系人", ContactPerson = contactPerson }; if (g.ShowDialog(this) == DialogResult.OK) { tvItems_AfterSelect(null, null); } break; case "删除": if (MessageBox.Show(this, "确定删除联系人?", "删除联系人", MessageBoxButtons.OKCancel) == DialogResult.OK) { var id = BLLOperate.DeleteItem <TB_ContactPerson>(contactPerson.Id); MessageBox.Show(this, id > 0 ? "删除成功!" : "删除失败"); tvItems_AfterSelect(null, null); } break; } }, s => MessageBox.Show(this, s)); }