public JsonResult EditSupplierType(FormCollection form) { var apiResult = new APIResult(); try { var opt = form["opt"]; SupplierType model = new SupplierType(); model.Name = form["name"]; if (opt == "0") { model.Pid = Convert.ToInt64(form["id"]); } else { model.Id = Convert.ToInt64(form["id"]); } SupplierTypeBll.AddOrUpdate(model, UserContext.CurrentUser.Name, UserContext.CurrentUser.HotelId); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
/// <summary> /// 构建tree树 /// </summary> /// <returns></returns> public string GetTreeView() { List <SupplierType> supTypeList = SupplierTypeBll.GetList(UserContext.CurrentUser.HotelId); TreeNode rootNode = new TreeNode() { id = 0, text = "全部分类", state = "open", children = findTreeChildren(supTypeList, 0) }; var result = JsonConvert.SerializeObject(rootNode); return($"[{result}]"); }
public ActionResult DeleteSupplierType(long id) { var apiResult = new APIResult(); try { SupplierTypeBll.Delete(id); } catch (Exception ex) { apiResult.Ret = -1; apiResult.Msg = ex.Message; if (!(ex is OperationExceptionFacade)) { LogFactory.GetLogger().Log(LogLevel.Error, ex); } } return(Json(apiResult)); }
public ActionResult Edit(long id = 0) { List <SupplierType> supTypeList = SupplierTypeBll.GetList(UserContext.CurrentUser.HotelId); List <SelectListItem> items = new List <SelectListItem>(); foreach (var item in supTypeList) { items.Add(new SelectListItem { Text = item.Name, Value = item.Id.ToString() }); } ViewData["hotelTypeList"] = items; if (id == 0) { return(View(new Hotel.Model.Inventory.Supplier() { HotelId = UserContext.CurrentUser.HotelId })); } var info = SupplierBll.GetById(id); return(View(info)); }