private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dataGridView1.Columns["cDel"].Index) { if (MessageBox.Show(this, "确定要删除吗?", "警告", MessageBoxButtons.YesNo) == DialogResult.Yes) { object v = dataGridView1.Rows[e.RowIndex].Cells["cName"].Value; if (v != null) { Level no = new Level(); if (no.IsRelation(v.ToString())) { MessageBox.Show("该记录已被使用,禁止删除!"); return; } bool re = no.Delete(v.ToString()); if (re) { MessageBox.Show("删除成功!"); BindDGV(); } else { MessageBox.Show("删除失败!"); } } } } else if (e.ColumnIndex == dataGridView1.Columns["cModity"].Index) { object v = dataGridView1.Rows[e.RowIndex].Cells["cName"].Value; if (ValidateService.IsNotEmpty(v)) { Level no = new Level(); no.GetModel(v.ToString()); frmAgentNormUpdate f = new frmAgentNormUpdate(no); f.ShowDialog(); if (f._isTrue) { BindDGV(); } } } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dataGridView1.Columns["cDel"].Index) { if (MessageBox.Show(this, "确定要删除吗?", "警告", MessageBoxButtons.YesNo) == DialogResult.Yes) { object v = dataGridView1.Rows[e.RowIndex].Cells["cName"].Value; if (v!=null) { Level no = new Level(); if (no.IsRelation(v.ToString())) { MessageBox.Show("该记录已被使用,禁止删除!"); return; } bool re = no.Delete(v.ToString()); if (re) { MessageBox.Show("删除成功!"); BindDGV(); } else { MessageBox.Show("删除失败!"); } } } } else if (e.ColumnIndex == dataGridView1.Columns["cModity"].Index) { object v = dataGridView1.Rows[e.RowIndex].Cells["cName"].Value; if (ValidateService.IsNotEmpty(v)) { Level no = new Level(); no.GetModel(v.ToString()); frmAgentNormUpdate f = new frmAgentNormUpdate(no); f.ShowDialog(); if (f._isTrue) { BindDGV(); } } } }