private void btnDelete_Click(object sender, EventArgs e) { DialogResult dg = new DialogResult(); dg = MessageBox.Show(string.Format("Are you sure you want to delete the equipment {0} ?", textBox2.Text), "Delete", MessageBoxButtons.YesNo); if (dg == DialogResult.Yes) { service.Delete(textBox3.Text); RefreshData(); MessageBox.Show("Deleted Successfuly"); } }
public ActionResult Delete(KeyValuesViewModel data) { HomeService service = new HomeService(); bool res = service.Delete(data, out string errMsg); if (res) { var result = JsonConvert.SerializeObject(new { IsOk = true, Message = "刪除成功" }, new JsonSerializerSettings() { DateTimeZoneHandling = DateTimeZoneHandling.Utc }); return(Content(result, "application/json")); } else { var result = JsonConvert.SerializeObject(new { IsOk = false, Message = "刪除失敗" + errMsg }, new JsonSerializerSettings() { DateTimeZoneHandling = DateTimeZoneHandling.Utc }); return(Content(result, "application/json")); } }