public JsonResult DelProduct(string id) { productServices.DelProduct(id, out DefaultError outError); ResultHandler <Object> result = new ResultHandler <object>(outError.ErrorMessage); return(Json(result, JsonRequestBehavior.AllowGet)); }
private void button4_Click(object sender, EventArgs e) { string str = MessageBox.Show("你确定要删除选中项目吗?", "警告", MessageBoxButtons.YesNo).ToString(); if (str == "Yes") { if (this.dataGridView1.SelectedRows.Count > 0) { for (int i = 0; i < dataGridView1.SelectedRows.Count; i++) { DataGridViewRow dr = dataGridView1.SelectedRows[i]; int ret = ProductServices.DelProduct(int.Parse(dr.Cells[6].Value.ToString())); if (ret > 0) { } else { MessageBox.Show(string.Format("第{0}条删除失败!", i + 1)); } } } else { DataGridViewCell dc = this.dataGridView1.SelectedCells[0]; // DataGridViewRow dr = dc.RowNumber; // dc = dr.Cells[0]; DataGridViewRow dr = dc.OwningRow; // MessageBox.Show(dr.Cells[0].Value.ToString()); // MessageBox.Show(dr.Cells[6].Value.ToString()); // MessageBox.Show(pd.Pdid.ToString()); int ret = ProductServices.DelProduct(int.Parse(dr.Cells[6].Value.ToString())); if (ret > 0) { } else { MessageBox.Show("操作失败!"); } } MessageBox.Show("操作成功!"); this.dataGridView1.DataSource = ProductServices.GetAllProduct(); } }