/// <summary> /// 保存商品类别信息 /// </summary> /// <param name="loggingSessionInfo"></param> /// <param name="itemCategoryInfo"></param> /// <returns></returns> public bool SetItemCategoryTableInfo(LoggingSessionInfo loggingSessionInfo, ItemCategoryInfo itemCategoryInfo) { try { bool bReturn = false; if (itemCategoryInfo != null) { itemCategoryInfo.Status = "1"; if (itemCategoryInfo.Create_User_Id == null || itemCategoryInfo.Create_User_Id.Equals("")) { itemCategoryInfo.Create_User_Id = loggingSessionInfo.CurrentUser.User_Id; itemCategoryInfo.Create_Time = GetCurrentDateTime(); } if (itemCategoryInfo.Modify_User_Id == null || itemCategoryInfo.Modify_User_Id.Equals("")) { itemCategoryInfo.Modify_User_Id = loggingSessionInfo.CurrentUser.User_Id; itemCategoryInfo.Modify_Time = GetCurrentDateTime(); } CPOS.BS.DataAccess.ItemCategoryService server = new DataAccess.ItemCategoryService(loggingSessionInfo); bReturn = server.SetItemCategoryInfoInsert(itemCategoryInfo); } return(bReturn); } catch (Exception ex) { throw (ex); } }
/// <summary> /// 保存商品类别(新建或者修改) /// </summary> /// <param name="loggingSessionInfo"></param> /// <param name="itemCategoryInfo"></param> /// <returns></returns> public string SetItemCategoryInfo(LoggingSessionInfo loggingSessionInfo, ItemCategoryInfo itemCategoryInfo) { string strResult = string.Empty; //事物信息 //cSqlMapper.Instance().BeginTransaction(); try { //处理是新建还是修改 if (itemCategoryInfo.Item_Category_Id == null || itemCategoryInfo.Item_Category_Id.Equals("")) { //如果是新建,并且没有传值给DisplayIndex,就取他所在子类里最大的displayindex+1 if (itemCategoryInfo.DisplayIndex == null || itemCategoryInfo.DisplayIndex == 0) { int displayindex = 0; //获取他的父类下的子分类的 IList <ItemCategoryInfo> list = GetItemCategoryListByParentId(itemCategoryInfo.Parent_Id).OrderByDescending(p => p.DisplayIndex).ToList(); if (list != null && list.Count() != 0) { int oldDisplayIndex = list[0].DisplayIndex == null?0: (int)list[0].DisplayIndex; displayindex = oldDisplayIndex + 1; } itemCategoryInfo.DisplayIndex = displayindex; } itemCategoryInfo.Item_Category_Id = NewGuid(); //2.提交用户信息 if (!SetItemCategoryTableInfo(loggingSessionInfo, itemCategoryInfo)) { strResult = "提交用户表失败"; return(strResult); } } else { CPOS.BS.DataAccess.ItemCategoryService server = new DataAccess.ItemCategoryService(loggingSessionInfo); strResult = server.SetItemCategoryInfoUpdate(itemCategoryInfo).ToString(); } var objectImagesBLL = new ObjectImagesBLL(loggingSessionInfo); var tmpImageList = objectImagesBLL.QueryByEntity(new ObjectImagesEntity() { ObjectId = itemCategoryInfo.Item_Category_Id }, null); if (tmpImageList != null && tmpImageList.Length > 0) { foreach (var tmpImageItem in tmpImageList) { objectImagesBLL.Delete(tmpImageItem); } } if (itemCategoryInfo.ImageUrl != null && itemCategoryInfo.ImageUrl.Length > 0) { objectImagesBLL.Create(new ObjectImagesEntity() { ImageId = NewGuid(), ObjectId = itemCategoryInfo.Item_Category_Id, ImageURL = itemCategoryInfo.ImageUrl }); } strResult = "保存成功!"; return(strResult); } catch (Exception ex) { throw (ex); } //return ""; }