public ActionResult CateList() { string cateName = WebUtil.GetFormValue <string>("cateName", string.Empty); int pageIndex = WebUtil.GetFormValue <int>("pageIndex", 0); int pageSize = WebUtil.GetFormValue <int>("pageSize", 0); ProductCategoryProvider provider = new ProductCategoryProvider(); ProductCategoryEntity entity = new ProductCategoryEntity(); if (!cateName.IsEmpty()) { entity.Begin <ProductCategoryEntity>() .Where <ProductCategoryEntity>("CateNum", ECondition.Like, "%" + cateName + "%") .Or <ProductCategoryEntity>("CateName", ECondition.Like, "%" + cateName + "%") .End <ProductCategoryEntity>() ; } PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; List <ProductCategoryEntity> list = provider.GetList(entity, ref pageInfo); list = list.IsNull() ? new List <ProductCategoryEntity>() : list; string json = ConvertJson.ListToJson <ProductCategoryEntity>(list, "data"); JsonObject jsonObject = new JsonObject(json); this.ReturnJson.AddProperty("list", jsonObject); this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount); return(Content(this.ReturnJson.ToString())); }
/// <summary> /// 新增产品类别 /// </summary> /// <returns></returns> public ActionResult Add() { string CateNum = WebUtil.GetFormValue <string>("CateNum"); string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); string CateName = WebUtil.GetFormValue <string>("CateName"); string Remark = WebUtil.GetFormValue <string>("Remark"); string CreateUser = WebUtil.GetFormValue <string>("CreateUser"); string ParentNum = WebUtil.GetFormValue <string>("ParentNum"); ProductCategoryEntity entity = new ProductCategoryEntity(); entity.CateName = CateName; entity.IsDelete = (int)EIsDelete.NotDelete; entity.CreateTime = DateTime.Now; entity.CreateUser = CreateUser; entity.Remark = Remark; entity.ParentNum = ParentNum; entity.CompanyID = CompanyID; ProductCategoryProvider provider = new ProductCategoryProvider(CompanyID); int line = provider.Add(entity); DataResult result = new DataResult(); if (line > 0) { result.Code = (int)EResponseCode.Success; result.Message = "产品类别新增成功"; } else { result.Code = (int)EResponseCode.Exception; result.Message = "产品类别新增失败"; } return(Content(JsonHelper.SerializeObject(result))); }
private ProductCategory AppendProductCategory(TreeNode parentPage, string[] subnodes) { if (parentPage == null || subnodes == null || subnodes.Length <= 0) { return(ProductCategoryProvider .GetProductCategories() .Culture(_culture) .WhereEquals(nameof(parentPage.DocumentID), parentPage.DocumentID) .FirstObject); } TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); TreeNode category = parentPage.Children.FirstOrDefault(c => c.NodeName == subnodes[0]); if (category == null) { category = TreeNode.New("KDA.ProductCategory", tree); category.DocumentName = subnodes[0]; category.DocumentCulture = _culture; SetPageTemplate(category, "_KDA_ProductCategory"); category.Insert(parentPage); } return(AppendProductCategory(category, subnodes.Skip(1).ToArray())); }
/// <summary> /// 查询分页 /// </summary> /// <returns></returns> public ActionResult GetPage() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); int PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1); int PageSize = WebUtil.GetFormValue <int>("PageSize", 10); string CateNum = WebUtil.GetFormValue <string>("CateNum"); string CateName = WebUtil.GetFormValue <string>("CateName"); string Remark = WebUtil.GetFormValue <string>("Remark"); ProductCategoryEntity entity = new ProductCategoryEntity(); entity.CateNum = CateNum; entity.CateName = CateName; entity.Remark = Remark; PageInfo pageInfo = new PageInfo(); pageInfo.PageIndex = PageIndex; pageInfo.PageSize = PageSize; ProductCategoryProvider provider = new ProductCategoryProvider(CompanyID); List <ProductCategoryEntity> list = provider.GetList(entity, ref pageInfo); DataListResult <ProductCategoryEntity> result = new DataListResult <ProductCategoryEntity>() { Code = (int)EResponseCode.Success, Message = "响应成功", Result = list, PageInfo = pageInfo }; return(Content(JsonHelper.SerializeObject(result))); }
/// <summary> /// Bind categories to dropdown /// </summary> public void BindCategories() { try { var categories = ProductCategoryProvider.GetProductCategories() .WhereEquals("NodeSiteID", CurrentSite.SiteID) .Columns("ProductCategoryID,ProductCategoryTitle") .WhereEquals("Status", 1) .ToList(); if (!DataHelper.DataSourceIsEmpty(categories)) { ddlProdCategory.DataSource = categories; ddlProdCategory.DataTextField = "ProductCategoryTitle"; ddlProdCategory.DataValueField = "ProductCategoryID"; ddlProdCategory.DataBind(); string selectText = ValidationHelper.GetString(ResHelper.GetString("Kadena.InvProductForm.CategoryWaterMark"), string.Empty); ddlProdCategory.Items.Insert(0, new ListItem(selectText, "0")); } } catch (Exception ex) { EventLogProvider.LogException("CMSWebParts_Kadena_Inventroy_Web_Products", "BindCategories", ex, CurrentSite.SiteID, ex.Message); } }
/// <summary> /// Bind Categories to Dropdown /// </summary> public void BindCategories() { try { var categories = ProductCategoryProvider.GetProductCategories() .WhereEquals("NodeSiteID", CurrentSite.SiteID) .Columns("ProductCategoryID,ProductCategoryTitle") .Select(x => new ProductCategory { ProductCategoryID = x.ProductCategoryID, ProductCategoryTitle = x.ProductCategoryTitle }) .ToList(); if (!DataHelper.DataSourceIsEmpty(categories)) { ddlCategory.DataSource = categories; ddlCategory.DataTextField = "ProductCategoryTitle"; ddlCategory.DataValueField = "ProductCategoryID"; ddlCategory.DataBind(); string selectText = ValidationHelper.GetString(ResHelper.GetString("Kadena.CampaignProduct.SelectCategoryText"), string.Empty); ddlCategory.Items.Insert(0, new ListItem(selectText, "0")); } } catch (Exception ex) { EventLogProvider.LogException("Bind Categories to Dropdown", "BindCategories()", ex, CurrentSite.SiteID, ex.Message); } }
private void BindProductCategoryList(ISheet sheet) { string[] productCategoryList = ProductCategoryProvider.GetProductCategories().OnCurrentSite().Select(x => x.ProductCategoryTitle).ToArray(); if (productCategoryList != null && productCategoryList.Count() > 0) { AddOneFromManyValidation(11, "ProductCategoryList", productCategoryList, sheet); } }
/// <summary> /// 查询产品类别列表 /// </summary> /// <returns></returns> public ActionResult GetList() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); ProductCategoryProvider provider = new ProductCategoryProvider(CompanyID); List <ProductCategoryEntity> list = provider.GetList(); DataListResult <ProductCategoryEntity> result = new DataListResult <ProductCategoryEntity>() { Code = (int)EResponseCode.Success, Message = "响应成功", Result = list }; return(Content(JsonHelper.SerializeObject(result))); }
/// <summary> /// 查询产品类别信息 /// </summary> /// <returns></returns> public ActionResult Single() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); string SnNum = WebUtil.GetFormValue <string>("SnNum"); ProductCategoryProvider provider = new ProductCategoryProvider(CompanyID); ProductCategoryEntity entity = provider.GetSingle(SnNum); DataResult <ProductCategoryEntity> result = new DataResult <ProductCategoryEntity>() { Code = (int)EResponseCode.Success, Message = "响应成功", Result = entity }; return(Content(JsonHelper.SerializeObject(result))); }
public ActionResult DelBat([ModelBinder(typeof(JsonBinder <List <string> >))] List <string> List) { if (!List.IsNullOrEmpty()) { ProductCategoryProvider provider = new ProductCategoryProvider(); int line = provider.DelBat(List); if (line > 0) { this.ReturnJson.AddProperty("d", "success"); } } return(Content(this.ReturnJson.ToString())); }
public ActionResult DelCate(string cateNum) { if (!cateNum.IsEmpty()) { ProductCategoryProvider provider = new ProductCategoryProvider(); int line = provider.Delete(cateNum); if (line > 0) { this.ReturnJson.AddProperty("d", "success"); } } return(Content(this.ReturnJson.ToString())); }
private ProductCategory GetProductCategory(string productCategoryName) { if (string.IsNullOrWhiteSpace(productCategoryName)) { return(null); } else { return(ProductCategoryProvider.GetProductCategories() .OnSite(_site) .Where(x => x.ProductCategoryTitle.Equals(productCategoryName) || x.DocumentName.Equals(productCategoryName)) .FirstOrDefault()); } }
public ActionResult Add() { string cateNum = WebUtil.GetQueryStringValue <string>("cateNum", string.Empty); ProductCategoryEntity entity = null; if (!cateNum.IsEmpty()) { ProductCategoryProvider provider = new ProductCategoryProvider(); entity = provider.GetSingle(cateNum); } entity = entity.IsNull() ? new ProductCategoryEntity() : entity; ViewBag.Category = entity; return(View()); }
/// <summary> /// 查询族谱路径 /// </summary> /// <returns></returns> public ActionResult GetParentList() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); string SnNum = WebUtil.GetFormValue <string>("SnNum"); ProductCategoryProvider provider = new ProductCategoryProvider(CompanyID); List <ProductCategoryEntity> list = provider.GetParentList(SnNum); DataResult <List <ProductCategoryEntity> > dataResult = new DataResult <List <ProductCategoryEntity> >(); dataResult.Code = (int)EResponseCode.Success; dataResult.Message = "响应成功"; dataResult.Result = list; return(Content(JsonHelper.SerializeObject(dataResult))); }
private static void GetProCatInfo(System.Data.DataSet dataset, List <ProductEntity> list) { var rows = dataset.Tables[0].Rows; if (rows.Count > 2) { ProductCategoryProvider ProductCategory = new ProductCategoryProvider(); for (var i = 2; i < rows.Count; i++) { ProductEntity entity = new ProductEntity(); ProductCategoryEntity PCEntity = new ProductCategoryEntity(); var row = rows[i]; entity.SnNum = row[1].ToString(); if (string.IsNullOrEmpty(entity.SnNum)) { continue; } entity.BarCode = row[2].ToString(); entity.ProductName = row[3].ToString(); entity.CateName = row[4].ToString(); PCEntity = ProductCategory.GetSingleCateName(entity.CateName); if (PCEntity.IsNotNull()) { entity.CateNum = PCEntity.CateNum; } else { entity.CateNum = ""; } entity.Num = ConvertHelper.ToType <int>(row[5].ToString()); entity.MinNum = ConvertHelper.ToType <int>(row[6].ToString()); entity.MaxNum = ConvertHelper.ToType <int>(row[7].ToString()); entity.UnitName = row[8].ToString(); entity.UnitNum = entity.UnitNum; entity.AvgPrice = ConvertHelper.ToType <double>(row[9].ToString()); entity.InPrice = ConvertHelper.ToType <double>(row[10].ToString()); entity.OutPrice = ConvertHelper.ToType <double>(row[11].ToString()); entity.NetWeight = ConvertHelper.ToType <double>(row[12].ToString()); entity.GrossWeight = ConvertHelper.ToType <double>(row[13].ToString()); entity.Remark = row[14].ToString(); entity.IsDelete = (int)EIsDelete.NotDelete; entity.CreateTime = DateTime.Now; list.Add(entity); } } }
/// <summary> /// 根据类别名称查询类别信息 /// </summary> /// <param name="cateName"></param> /// <returns></returns> public ProductCategory_CE GetSingleCateName(string cateName) { if (cateName.IsEmpty()) { return(null); } ProductCategoryProvider provider = new ProductCategoryProvider(); ProductCategoryEntity entity = provider.GetSingleCateName(cateName); if (entity.IsNotNull()) { ProductCategory_CE ce = ProductCategory_To.ToCE(entity); return(ce); } return(null); }
public static object GetCategoryName(EvaluationContext context, params object[] parameters) { try { int categoryID = ValidationHelper.GetInteger(parameters[0], 0); string categoryName = string.Empty; ProductCategory category = ProductCategoryProvider.GetProductCategories().WhereEquals("NodeSiteID", SiteContext.CurrentSite.SiteID).WhereEquals("ProductCategoryID", categoryID).Columns("ProductCategoryTitle").FirstObject; categoryName = category?.ProductCategoryTitle ?? string.Empty; return(categoryName); } catch (Exception ex) { EventLogProvider.LogInformation("Kadena Macro methods", "GetProgramName", ex.Message); return(string.Empty); } }
/// <summary> /// Binding product types /// </summary> private void BindProductTypes() { try { var productCategories = ProductCategoryProvider.GetProductCategories().Columns("ProductCategoryTitle,ProductCategoryID").WhereEquals("NodeSiteID", CurrentSite.SiteID).Select(x => new ProductCategory { ProductCategoryID = x.ProductCategoryID, ProductCategoryTitle = x.ProductCategoryTitle }).ToList().OrderBy(y => y.ProductCategoryTitle); ddlProductTypes.DataSource = productCategories; ddlProductTypes.DataTextField = "ProductCategoryTitle"; ddlProductTypes.DataValueField = "ProductCategoryID"; ddlProductTypes.DataBind(); } catch (Exception ex) { EventLogProvider.LogException("CMSWebParts_Kadena_Catalog_PrebuyProductsFilter", ex.Message, ex); } }
/// <summary> /// 查询所有的货品种类 /// </summary> /// <returns></returns> public List <ProductCategory_CE> GetList() { ProductCategoryProvider provider = new ProductCategoryProvider(); List <ProductCategoryEntity> listResult = provider.GetList(); if (!listResult.IsNullOrEmpty()) { List <ProductCategory_CE> list = new List <ProductCategory_CE>(); foreach (ProductCategoryEntity item in listResult) { ProductCategory_CE ce = ProductCategory_To.ToCE(item); list.Add(ce); } return(list); } return(null); }
/// <summary> /// 获得产品的类别 /// </summary> /// <param name="cateNum"></param> /// <returns></returns> public static string GetProductCategory(string cateNum) { ProductCategoryProvider provider = new ProductCategoryProvider(); List <ProductCategoryEntity> list = provider.GetList(); StringBuilder sb = new StringBuilder(); string departTemplate = "<option value='{0}' {1}>{2}</option>"; sb.AppendFormat(departTemplate, "", "", "请选择类别"); if (!list.IsNullOrEmpty()) { foreach (ProductCategoryEntity depart in list) { sb.AppendFormat(departTemplate, depart.CateNum, depart.CateNum == cateNum ? "selected='selected'" : string.Empty, depart.CateName); } } return(sb.ToString()); }
/// <summary> /// 新增带SKU的产品 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int Add(ProductEntity entity, List <ProductSkuEntity> listSku) { using (TransactionScope ts = new TransactionScope()) { entity.IncludeAll(); entity.InPrice = entity.AvgPrice; entity.OutPrice = entity.AvgPrice; entity.SnNum = ConvertHelper.NewGuid(); entity.BarCode = entity.BarCode.IsEmpty() ? new TNumProvider(CompanyID).GetSwiftNum(typeof(ProductEntity), 6) : entity.BarCode; //处理类别 if (!entity.CateNum.IsEmpty()) { ProductCategoryEntity category = new ProductCategoryProvider(this.CompanyID).GetSingle(entity.CateNum); entity.CateName = category != null ? category.CateName : ""; } if (!entity.UnitNum.IsEmpty()) { MeasureEntity meaure = new MeasureProvider(this.CompanyID).GetMeasure(entity.UnitNum); entity.UnitName = meaure != null ? meaure.MeasureName : ""; } int line = this.Product.Add(entity); if (!listSku.IsNullOrEmpty()) { foreach (ProductSkuEntity item in listSku) { item.SnNum = ConvertHelper.NewGuid(); item.ProductNum = entity.SnNum; item.BarCode = entity.BarCode + "-" + new TNumProvider(CompanyID).GetSwiftNum(entity.SnNum, 3); item.IsDelete = (int)EIsDelete.NotDelete; item.CreateTime = DateTime.Now; item.CompanyID = this.CompanyID; item.IncludeAll(); line += this.ProductSku.Add(item); } } ts.Complete(); return(line); } }
/// <summary> /// 删除产品类别 /// </summary> /// <returns></returns> public ActionResult Delete() { List <string> list = WebUtil.GetFormObject <List <string> >("List"); string CompanyID = WebUtil.GetFormValue <string>("CompanyID"); ProductCategoryProvider provider = new ProductCategoryProvider(CompanyID); int line = provider.Delete(list); DataResult result = new DataResult(); if (line > 0) { result.Code = (int)EResponseCode.Success; result.Message = string.Format("产品类别删除成功,受影响行数{0}行", line); } else { result.Code = (int)EResponseCode.Exception; result.Message = "产品类别删除失败"; } return(Content(JsonHelper.SerializeObject(result))); }
/// <summary> /// 编辑产品信息 /// </summary> /// <param name="entity"></param> /// <returns></returns> public int EditProduct(ProductEntity entity) { if (!entity.CateNum.IsEmpty()) { ProductCategoryEntity category = new ProductCategoryProvider(this.CompanyID).GetSingle(entity.CateNum); entity.CateName = category != null ? category.CateName : ""; } if (!entity.UnitNum.IsEmpty()) { MeasureEntity meaure = new MeasureProvider(this.CompanyID).GetMeasure(entity.UnitNum); entity.UnitName = meaure != null ? meaure.MeasureName : ""; } entity.Include(a => new { a.ProductName, a.BarCode, a.FactoryNum, a.InCode, a.UnitNum, a.UnitName, a.CateNum, a.CateName, a.StorageNum, a.DefaultLocal, a.CusNum, a.CusName, a.SupNum, a.SupName, a.Description, a.Display, a.Remark }); entity.Where(a => a.SnNum == entity.SnNum) .And(a => a.CompanyID == this.CompanyID); int line = this.Product.Update(entity); return(line); }
/// <summary> /// Binding product types /// </summary> private void BindProductTypes() { try { var productCategories = ProductCategoryProvider.GetProductCategories() .Columns("ProductCategoryTitle,ProductCategoryID") .WhereEquals("NodeSiteID", CurrentSite.SiteID) .Select(x => new ProductCategory { ProductCategoryID = x.ProductCategoryID, ProductCategoryTitle = x.ProductCategoryTitle }) .ToList() .OrderBy(y => y.ProductCategoryTitle); ddlProductTypes.DataSource = productCategories; ddlProductTypes.DataTextField = "ProductCategoryTitle"; ddlProductTypes.DataValueField = "ProductCategoryID"; ddlProductTypes.DataBind(); ddlProductTypes.Items.Insert(0, new ListItem(ResHelper.GetString("Kadena.Catalog.SelectProductTypeText"), "0")); } catch (Exception ex) { EventLogProvider.LogException("Binding producttypes based on program", ex.Message, ex); } }
public ActionResult Edit() { string cateNum = WebUtil.GetFormValue <string>("num", string.Empty); string cateName = WebUtil.GetFormValue <string>("name", string.Empty); string remark = WebUtil.GetFormValue <string>("remark", string.Empty); if (cateNum.IsEmpty()) { ProductCategoryEntity entity = new ProductCategoryEntity(); entity.CateNum = SequenceProvider.GetSequence(typeof(ProductCategoryEntity)); entity.CateName = cateName; entity.IsDelete = (int)EIsDelete.NotDelete; entity.CreateTime = DateTime.Now; entity.Remark = remark; entity.CreateUser = this.LoginUserCode; ProductCategoryProvider provider = new ProductCategoryProvider(); int line = provider.Add(entity); if (line > 0) { this.ReturnJson.AddProperty("d", "success"); } } else { ProductCategoryEntity entity = new ProductCategoryEntity(); entity.CateNum = cateNum; entity.CateName = cateName; entity.Remark = remark; ProductCategoryProvider provider = new ProductCategoryProvider(); int line = provider.Update(entity); if (line > 0) { this.ReturnJson.AddProperty("d", "success"); } } return(Content(this.ReturnJson.ToString())); }
public ProductCategoryController(ProductCategoryProvider productCategoryProvider, IMapper mapper) { this.mapper = mapper; this.productCategoryProvider = productCategoryProvider; }
public static List <ProductCategoryEntity> ListProductCategories() { return(ProductCategoryProvider.List(p => true)); }
public static bool NewProductCategory(ProductCategoryEntity category) { return(ProductCategoryProvider.Add(category)); }
public static bool DeleteProductCategory(ProductCategoryEntity category) { return(ProductCategoryProvider.Remove(category)); }
public static bool ModifyProductCategory(ProductCategoryEntity category) { return(ProductCategoryProvider.Modify(category)); }