protected void btnDelete_Click(object sender, EventArgs e) { int id = 0; try { id = int.Parse(hdfnodeID.Value); } catch { Msg.Show("没有选择栏目"); } if (id != 0) { if (!bll.HasChild(id)) { int pid = bll.GetModel(id).parentID; bll.Delete(id); bll.UpdateOrderByDel(int.Parse(hdfparentID.Value), int.Parse(hdforderID.Value)); Msg.ShowAndRedirect("删除成功!", "Default.aspx?id=" + pid); } else { Msg.Show("该类含有子分类,请先删除子分类!"); } } }
public ActionResult Delete(int id) { var info = CategoryBLL.GetList(p => p.ID == id).FirstOrDefault(); if (null == info) { return(Json(new APIJson(-1, "删除失败,参数有误"))); } if (CategoryBLL.Delete(info)) { return(Json(new APIJson(0, "删除成功"))); } return(Json(new APIJson(-1, "删除失败,请重试"))); }
public JsonResult DeleteCate(int CateId) { var msg = new MsgBase(); try { int i = cateBll.Delete(CateId); msg.Message = i > 0 ? MsgBase.SuccessMessage : MsgBase.FailMessage; msg.Code = i > 0 ? 1 : 0; } catch (Exception) { msg.Code = -1; msg.Message = MsgBase.ErrMessage; } return(Json(msg)); }
private void silToolStripMenuItem_Click(object sender, EventArgs e) { int id = (int)dgvCategories.SelectedRows[0].Cells[0].Value; Category cat = _categoryBLL.Get(id); bool result = _categoryBLL.Delete(cat); if (result) { MessageBox.Show("Silme gerçekleşti."); } else { MessageBox.Show("SİLİNEMEDİ."); } dgvCategories.DataSource = _categoryBLL.GetAll(); }
protected void CategoryDisplayGrid_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { CategoryBLL categoryManager = new CategoryBLL(); Label ID = (Label)CategoryDisplayGrid.Rows[e.RowIndex].FindControl("lblCat_ID"); int selectedId = int.Parse(ID.Text); Category categoryToDelete = new Category();//= empid.Text; categoryToDelete.CategoryID = selectedId; categoryManager.Delete(categoryToDelete); } catch (Exception exp) { } finally { CategoryDisplayGrid.EditIndex = -1; BindGrid(false); } }
public ActionResult Delete(List <int> id) { if (string.IsNullOrEmpty(id.ToString())) { TempData["Error"] = "Data has already been deleted by other user!"; return(RedirectToAction("Index")); } List <string> lstMsg = new List <string>(); int returnCode = _categoryBLL.Delete(id, out lstMsg); if (((int)Common.ReturnCode.Succeed == returnCode)) { return(Json(new { Message = true }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Message = false }, JsonRequestBehavior.AllowGet)); } }
private void btnDelete_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(txtID.Text)) { if (MessageBox.Show("Are you sure to delete it?", "Notice", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { CategoryBLL categoryBLL = new CategoryBLL(); if (categoryBLL.Delete(txtID.Text)) { MessageBox.Show("Success"); } else { MessageBox.Show("Cannot delete cuz foreign key "); } } } LoadData(); }
private void btnDelete_Click(object sender, EventArgs e) { if (detail.ID == 0) { MessageBox.Show("Please select a category from table"); } else { DialogResult result = MessageBox.Show("Are you sure", "Warning", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { if (bll.Delete(detail)) { MessageBox.Show("Category was deleted"); bll = new CategoryBLL(); dto = bll.Select(); dataGridView1.DataSource = dto.Categories; txtCategoryName.Clear(); } } } }
public async Task <IActionResult> Delete([FromServices] CategoryBLL service, int id = 0) { return(Json(await service.Delete(id))); }
protected void gridViewCategory_RowDeleting(object sender, GridViewDeleteEventArgs e) { categoryDTO.Id = Convert.ToInt32(gridViewCategory.DataKeys[e.RowIndex].Value.ToString()); categoryBLL.Delete(categoryDTO); ShowGridViewCategory(); }
private void btnSave_Click(object sender, EventArgs e) { try { if (op == Operation.Insert) { foreach (Control con in gbInfo.Controls) { if (con is TextBox && con.Text == "") { MessageBox.Show("请输入所有值!"); con.Focus(); return; } } c = new Category(); c.CategoryID = txtCategoryID.Text.Trim(); c.CategoryName = txtCategoryName.Text.Trim(); if (cBLL.Insert(c)) { MessageBox.Show("新增成功!"); BindDate(); for (int i = 0; i < list.Count; i++) { if (list[i].CategoryID == c.CategoryID) { dgCategoryInfo.Rows[i].Selected = true; break; } } } else { MessageBox.Show("新增失败!"); } } else if (op == Operation.Update) { if (c == null) { MessageBox.Show("请选择要修改的记录!"); return; } c.CategoryName = txtCategoryName.Text.Trim(); if (cBLL.Update(c)) { MessageBox.Show("修改成功!"); BindDate(); dgCategoryInfo.Rows[currentIndex].Selected = true; } else { MessageBox.Show("修改失败!"); } } else if (op == Operation.Delete) { if (c == null) { MessageBox.Show("请选择要删除的记录!"); return; } if (cBLL.Delete(c)) { MessageBox.Show("删除成功!"); BindDate(); c = null; } else { MessageBox.Show("删除失败!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//新增、更新和删除时,存盘的工作 private void btnSave_Click(object sender, EventArgs e) { switch (op) { case EnumOperation.Insert: _categoryObj = new Category() { CategoryName = txtCategoryName.Text.Trim() }; //检测是否有重复的分类 if (_list.FirstOrDefault(x => x.CategoryName == _categoryObj.CategoryName) != null) { MessageBox.Show("不能添加重复的分类"); return; } if (_categoryBll.Add(_categoryObj)) { //重新查询数据,并对正处理的数据记录进行定位 QueryData(); var id = _list.FirstOrDefault(x => x.CategoryName == _categoryObj.CategoryName).CategoryID; LocationNewRow(id); } break; case EnumOperation.Update: if (_categoryObj != null) { _categoryObj.CategoryName = txtCategoryName.Text.Trim(); if (_categoryBll.Edit(_categoryObj)) { //重新查询数据,并对正处理的数据记录进行定位 QueryData(); var id = _list.FirstOrDefault(x => x.CategoryName == _categoryObj.CategoryName).CategoryID; LocationNewRow(id); } } else { MessageBox.Show("请先选择一条分类记录"); return; } break; case EnumOperation.Delete: if (_categoryObj != null) { if (_categoryBll.Delete(_categoryObj)) { MessageBox.Show("删除成功"); QueryData(); } } else { MessageBox.Show("请先选择一条分类记录"); return; } break; case EnumOperation.None: default: break; } }
private void btnSave_Click(object sender, EventArgs e) //存盘按钮事件 { if (op == Operation.INSERT) //新增按钮被点击 { //判断是否输入了所有的值 if (txtCategoryID.Text == "" || txtCategoryName.Text == "") { MessageBox.Show("请输入所有的值", "提示"); } //获取文本框的值给对象的属性赋值 cate = new Category(); cate.CategoryID = txtCategoryID.Text.Trim(); cate.CategoryName = txtCategoryName.Text.Trim(); try { //判断执行是否成功(新增) if (categoryBll.Insert(cate)) { MessageBox.Show("新增成功!", "提示"); txtCategoryID.Text = string.Empty; //清空文本框的值(效率比clear高) txtCategoryName.Text = string.Empty; //清空文本框的值(效率比clear高) BindDateGridView(); //调用填充方法 重新填充DateGridView的数据(刷新结果) dgCategroy.CurrentRow.Selected = false; //取消行的选中状态(第一行) for (int i = 0; i < list.Count; i++) //新增的当前行被选中 { if (list[i].CategoryID == cate.CategoryID) { dgCategroy.Rows[i].Selected = true; //自动跳转到查找到的行 dgCategroy.FirstDisplayedScrollingRowIndex = i; break; } } } else { MessageBox.Show("新增失败!", "提示"); return; } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } else if (op == Operation.UPDATE) //修改按钮被点击 { if (cate == null) { MessageBox.Show("请选择要修改的数据!", "提示"); return; } cate.CategoryName = txtCategoryName.Text.Trim(); //获取文本框的值给对象的属性赋值 try { //判断执行是否成功(更新) if (categoryBll.Update(cate)) { MessageBox.Show("更新成功!", "提示"); BindDateGridView(); //重新填充ateGridView (刷新结果) dgCategroy.CurrentRow.Selected = false; //取消行的选中状态(第一行) dgCategroy.Rows[currentRowsIndex].Selected = true; //将当前被更新的行进行反蓝色显示 //自动跳转到查找到的行 dgCategroy.FirstDisplayedScrollingRowIndex = currentRowsIndex; } else { MessageBox.Show("更新失败!", "提示"); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } else if (op == Operation.DELETE) //删除按钮被点击 { if (cate == null) { MessageBox.Show("请选择要删除的数据!", "提示"); } //弹出是否确认删除的对话框 DialogResult result = MessageBox.Show("您是否真的要删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { try { if (categoryBll.Delete(cate)) { MessageBox.Show("删除成功", "提示"); BindDateGridView(); dgCategroy.CurrentRow.Selected = false; //取消行的选中状态(第一行) cate = null; //清空参数 //直接初始化 当前窗口 btnNewAdd.Enabled = btnModify.Enabled = btnDelete.Enabled = true; gbInfo.Visible = false; } else { MessageBox.Show("删除失败!", "提示"); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } } }
public IHttpActionResult Delete(int CategoryID) { _CategoryService.Delete(CategoryID, User.Identity.GetUserId()); return(Ok()); }
public void Delete(int id) { service.Delete(id); }