private void btnDel_Click(object sender, EventArgs e) { List <int> listids = new List <int>(); string ids = ","; foreach (DataGridViewRow x in dataGridView1.Rows) { DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)x.Cells[0]; Boolean flag = Convert.ToBoolean(cell.Value); if (flag) { ids += x.Cells["id"].Value.ToString() + ","; listids.Add(Convert.ToInt32(x.Cells["id"].Value.ToString())); } } if (listids.Count <= 0) { MessageBox.Show(string.Format("请选择要删除的数据"), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (MessageBox.Show(string.Format("您将要删除复选框选中的 【{0}】 条专题库", listids.Count), "确认删除", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK) { ids = ids.Trim(','); if (ZTHelper.DelZTDB(ids)) { bind(); } } }
private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 0) { MessageBox.Show(string.Format("请选择要删除的数据"), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DataGridViewRow datarow = dataGridView1.SelectedRows[0]; string name = (datarow.Cells["name"].Value == null ? "" : datarow.Cells["name"].Value.ToString()); string des = (datarow.Cells["des"].Value == null ? "" : datarow.Cells["des"].Value.ToString()); string type = (datarow.Cells["type"].Value == null ? "CPRS" : datarow.Cells["type"].Value.ToString()); if (MessageBox.Show("您确定要删除专题库 【" + name + "】 吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes) { try { if (ZTHelper.DelZTDB(datarow.Cells["Id"].Value.ToString(), name)) { bind(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "错误"); } } }
private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { DataGridViewRow datarow = dataGridView1.SelectedRows[0]; string name = (datarow.Cells["name"].Value == null ? "" : datarow.Cells["name"].Value.ToString()); string des = (datarow.Cells["des"].Value == null ? "" : datarow.Cells["des"].Value.ToString()); string type = (datarow.Cells["type"].Value == null ? "CPRS" : datarow.Cells["type"].Value.ToString()); if (MessageBox.Show("您确定要删除专题库 【" + name + "】 吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes) { if (ZTHelper.DelZTDB(datarow.Cells["id"].Value.ToString())) { bind(); } } }