public ActionResult NewGoodsType() { string strErrText; //生成上级货物类别下拉列表项 DDSystem dd = new DDSystem(); List <GoodsType> listGoodsType = dd.LoadGoodsTypes(LoginAccountId, LoginStaffName, out strErrText); if (listGoodsType == null) { throw new Exception(strErrText); } List <SelectListItem> selectListGoodsType = new List <SelectListItem>(); selectListGoodsType.Add(new SelectListItem { Text = string.Empty, Value = "0" }); selectListGoodsType.AddRange(from o in listGoodsType orderby o.FullName select new SelectListItem { Text = o.FullName, Value = o.Id.ToString() }); ViewData["GoodsTypes"] = new SelectList(selectListGoodsType, "Value", "Text"); //创建空的Model GoodsTypeViewModel model = new GoodsTypeViewModel(); return(View(model)); }
public ActionResult ModifyGoodsType(string id) { string strErrText; //生成Model数据 DDSystem dd = new DDSystem(); GoodsType data = dd.LoadGoodsType(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText); if (data == null) { throw new Exception(strErrText); } GoodsTypeViewModel model = new GoodsTypeViewModel(); model.Id = data.Id; model.Name = data.Name; model.ParentId = data.ParentId; model.Remark = data.Remark; List <GoodsType> listGoodsType = dd.LoadGoodsTypes(LoginAccountId, LoginStaffName, out strErrText); if (listGoodsType == null) { throw new Exception(strErrText); } List <SelectListItem> selectlistGoodsType = new List <SelectListItem>(); selectlistGoodsType.Add(new SelectListItem { Text = string.Empty, Value = "0" }); selectlistGoodsType.AddRange(from t in listGoodsType where !t.FullPath.StartsWith(data.FullPath) orderby t.FullName select new SelectListItem { Text = t.FullName, Value = t.Id.ToString() }); ViewData["GoodsTypes"] = new SelectList(selectlistGoodsType, "Value", "Text", model.ParentId); return(View(model)); }
public JsonResult LoadGoodsTypes() { string strErrText = string.Empty; DDSystem dd = new DDSystem(); List <GoodsType> listGoodsType = dd.LoadGoodsTypes(LoginAccountId, LoginStaffName, out strErrText); if (listGoodsType == null) { throw new Exception(strErrText); } var ret = from t in listGoodsType select new { t.Id, t.FullName }; return(Json(ret, JsonRequestBehavior.AllowGet)); }
public JsonResult LoadGoodsTypesGrid(long?nodeid, int?n_level) { //读取全部数据 string strErrText; DDSystem dd = new DDSystem(); List <GoodsType> listGoodsType = dd.LoadGoodsTypes(LoginAccountId, LoginStaffName, out strErrText); if (listGoodsType == null) { throw new Exception(strErrText); } //根据父子关系生成类别树 List <GoodsType> data = new List <GoodsType>(); RecursiveMakeGoodsTypeTree(listGoodsType, 0, ref data); //返回数据 var ret = new { page = 1, total = 1, records = data.Count, rows = (from t in data select new { cell = new[] { t.Name, t.Id.ToString(), t.Remark, (t.FullPath.Where(c => c == '\\').Count() - 1).ToString(), t.ParentId.ToString(), data.Where(GoodsType => (GoodsType.FullPath.StartsWith(t.FullPath) && GoodsType.Id != t.Id)).Count() == 0 ? "true" : "false", "true" } }).ToArray() }; return(Json(ret, JsonRequestBehavior.AllowGet)); }