public void ProcessRequest(HttpContext context) { try { LoginUser loginUser = new LoginUser(context, "Area"); if (!loginUser.Pass)//权限验证 { return; } AreaBLL bll = new AreaBLL(context, loginUser); if (context.Request["action"] == "treeLoad") {//加载树 bll.LoadTree(); } else if (context.Request["action"] == "load") {//加载信息 bll.Load(context.Request["areaId"]); } else if (context.Request["action"] == "add") {//增加 TBArea area = new TBArea(); area.areaCode = context.Request.Form["areaCode"]; area.areaName = context.Request.Form["areaName"]; area.isUse = context.Request.Form["isUse"]; area.parentId = context.Request.Form["parentId"]; area.areaLayer = int.Parse(context.Request.Form["areaLayer"]); area.areaIndex = int.Parse(context.Request.Form["areaIndex"]); bll.Add(area); } else if (context.Request["action"] == "edit") {//修改 TBArea area = new TBArea(); area.areaId = context.Request["areaId"]; area.areaCode = context.Request.Form["areaCode"]; area.areaName = context.Request.Form["areaName"]; area.parentId = context.Request.Form["parentId"]; area.isUse = context.Request.Form["isUse"]; area.areaIndex = int.Parse(context.Request.Form["areaIndex"]); bll.Edit(area); } else if (context.Request["action"] == "delete") {//删除 string areaId = context.Request["areaId"]; bll.Delete(areaId); } } catch (Exception e) { Message.error(context, e.Message); } }
private void btnDeleteArea_Click(object sender, EventArgs e) { Button btn = (Button)sender; Area area = (Area)btn.Tag; DialogResult dr = MessageBox.Show("Are you sure to delete area '" + area.Name + "'?", "Confirm", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { AreaBLL areaBLL = new AreaBLL(); areaBLL.Delete(area); this.LoadData(); } }
public void TestDeleteArea(Area area) { bool isDelete = true; areaBLL.Delete(area); List <Area> areas = areaBLL.ListArea(); for (int i = 0; i < areas.Count; i++) { if (areas[i].ID == area.ID) { isDelete = false; } } Assert.AreEqual(isDelete, true); }
public ActionResult DeleteConfirmed(int id) { AreaBLL.Delete(id); return(RedirectToAction("Index")); }