public List <ProductCategories> GetPCategories() { List <ProductCategories> listOfCategories = new List <ProductCategories>(); ProductCategories pctgry = null; try { db.OpenConn(); SqlCommand cmd = new SqlCommand("select * from ProductCategory", db.conn); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { pctgry = new ProductCategories(); pctgry.ProductCategoryID = long.Parse(dr["ProductCategoryID"].ToString()); pctgry.ProductCategoryName = dr["ProductCategoryName"].ToString(); listOfCategories.Add(pctgry); } db.CloseConn(); } catch (Exception ee) { db.CloseConn(); throw ee; } return(listOfCategories); }
public List <ProductCategories> GetAllPCategories() { string prdcatname = ""; List <ProductCategories> listOfCategories = new List <ProductCategories>(); ProductCategories pctgry = null; try { db.OpenConn(); string query = "select distinct pc.ProductCategoryID,pc.ProductCategoryName,(select count(productid) from products p where productcategoryid=pc.productcategoryid and p.ProductID not in (select od.productid from Orders o inner join OrderDetails od on o.OrderID=od.OrderID where Status='Success' or dateadd(MI,10,OrderDateTime)>GETDATE()))as Count from productcategory pc inner join products p on p.productcategoryid=pc.productcategoryid order by productcategoryid asc"; SqlCommand cmd = new SqlCommand(query, db.conn); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { pctgry = new ProductCategories(); pctgry.ProductCategoryID = long.Parse(dr["ProductCategoryID"].ToString()); //pctgry.ProductCategoryName = dr["ProductCategoryName"].ToString(); prdcatname = dr["ProductCategoryName"].ToString() + "(" + dr["Count"].ToString() + ")"; pctgry.ProductCategoryName = prdcatname; pctgry.Count = int.Parse(dr["Count"].ToString()); listOfCategories.Add(pctgry); } db.CloseConn(); } catch (Exception ee) { db.CloseConn(); throw ee; } return(listOfCategories); }
public List <ProductCategories> GetPcNameId() { List <ProductCategories> lstprodcat = new List <ProductCategories>(); ProductCategories objprodctgry = null; try { db.OpenConn(); string query = "select * from ProductCategory"; SqlCommand cmd = new SqlCommand(query, db.conn); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { objprodctgry = new ProductCategories(); objprodctgry.ProductCategoryID = long.Parse(dr["ProductCategoryID"].ToString()); objprodctgry.ProductCategoryName = dr["ProductCategoryName"].ToString(); objprodctgry.Description = dr["Description"].ToString(); //objprodctgry.Description = dr["Description"].ToString(); lstprodcat.Add(objprodctgry); } dr.Close(); db.CloseConn(); } catch (Exception ex) { db.CloseConn(); throw ex; } return(lstprodcat); }
void RenderJsonData() { List <ProductCategory> pcs = ProductCategories.GetCategoreisByProductID(productID); StringBuilder sb1 = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); foreach (ProductCategory pc in pcs) { sb1.AppendFormat("[{0}]:", pc.CategoryID); sb2.AppendFormat(catHtml, pc.CategoryID, pc.CategoryName); } hfCategories.Value = sb1.ToString(); hfCatHTML.Value = sb2.ToString(); sb1 = new StringBuilder(); sb2 = new StringBuilder(); List <ProductIndustry> pis = ProductIndustries.GetIndustriesByProductID(productID); foreach (ProductIndustry pi in pis) { sb1.AppendFormat("[{0}]:", pi.IndustryID); sb2.AppendFormat(indHtml, pi.IndustryID, pi.IndustryName); } hfIndustries.Value = sb1.ToString(); hfIndHTML.Value = sb2.ToString(); }
public ProductRES ProductDTtoRES() { ProductRES productRES = new ProductRES() { Id = Id, ProductStatus = ProductStatus, ProductName = ProductName, Categories = ProductCategories != null?ProductCategories.Select(x => x.CategoryToRES()).ToList() : null, CreateDate = CreateDate, CreateUser = CreateUser != null?CreateUser.AppUserDTtoRES() : null, Discount = Discount, DiscountAmount = DiscountAmount, DiscountFinishDate = DiscountFinishDate, DiscountStartDate = DiscountStartDate, MainImage = MainImage, ProductImageGalleries = ProductImageGalleries != null?ProductImageGalleries.Select(x => x.ProductImageGalleryDTtoRES()).ToList() : null, UpdateDate = UpdateDate, UpdateUser = UpdateUser != null?UpdateUser.AppUserDTtoRES() : null, ProductAmountTypes = ProductAmountTypes.Select(x => x.ProductAmountTypeDTtoRES()).ToList(), LongDescription = LongDescription, ShortDescription = ShortDescription, }; return(productRES); }
public List <ProductCategories> GetProductCategoryDetails(long pcid) { List <ProductCategories> lstpcobj = new List <ProductCategories>(); ProductCategories pcobj; try { db.OpenConn(); SqlCommand cmd = new SqlCommand("select P.ProductCategoryID, P.productcategoryname,P.description from productcategory P where ProductCategoryID=@ProductCategoryID", db.conn); cmd.Parameters.AddWithValue("@ProductCategoryID", pcid); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { pcobj = new ProductCategories(); pcobj.ProductCategoryName = dr["ProductCategoryName"].ToString(); pcobj.Description = dr["Description"].ToString(); pcobj.ProductCategoryID = long.Parse(dr["ProductCategoryID"].ToString()); lstpcobj.Add(pcobj); } dr.Close(); db.CloseConn(); } catch (Exception ex) { db.CloseConn(); throw ex; } return(lstpcobj); }
public async Task <IActionResult> Edit(int id, [Bind("ProductCategoriesId,ProductId,ProductName")] ProductCategories productCategories) { if (id != productCategories.ProductCategoriesId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(productCategories); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductCategoriesExists(productCategories.ProductCategoriesId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "Name", productCategories.ProductId); return(View(productCategories)); }
protected void UpdateCategoryDisplay() { if (this.CategoryPath.CurrentCategoryId == 0) { this.CurrentCategoryLabel.Text = "[All Categories]"; this.CurrentCategoryActionLabel.Text = "All Categories"; this.txtEditCategoryName.Text = string.Empty; this.txtEditCategoryDescription.Text = string.Empty; this.txtEditCategoryName.Enabled = this.txtEditCategoryDescription.Enabled = this.RenameCategoryButton.Enabled = false; this.MoveButton.Enabled = false; this.MoveAction.Enabled = false; this.CategoryDropDown.Enabled = false; this.RemoveCategoryButton.Enabled = false; } else { base.CurrentProductCategory = ProductCategories.GetProductCategory(this.CategoryPath.CurrentCategoryId); this.CurrentCategoryLabel.Text = this.CurrentCategoryActionLabel.Text = this.txtEditCategoryName.Text = this.CategoryPath.CurrentCategoryName; this.txtEditCategoryDescription.Text = base.CurrentProductCategory.CategoryDescription; this.txtEditCategoryName.Enabled = this.txtEditCategoryDescription.Enabled = true; this.RenameCategoryButton.Enabled = true; this.MoveButton.Enabled = true; this.MoveAction.Enabled = true; this.CategoryDropDown.Enabled = true; this.RemoveCategoryButton.Enabled = true; } }
public IActionResult Create([FromForm] CreateCategoryViewModel model) { try { var cate = new ProductCategories() { Active = true, Description = model.description, Id = Guid.NewGuid().ToString(), Name = model.name, ImageUrl = model.image_url, CategoriesOfProducts = null }; _context.ProductCategories.Add(cate); _context.SaveChanges(); return(NoContent()); } catch (Exception e) { return(Error(new { message = "Có lỗi xảy ra. Vui lòng thử lại.", data = e, })); } }
private async void OnRemoveCategoryExecute(int?id) { try { if (!id.HasValue) { return; } var result = await _dialogService.AskQuestionAsync("¿Estas seguro de querer eliminar esta categoria?", "Elimiar Categoria"); if (result == MessageDialogResult.Negative) { return; } var httpResponse = await ShowProgressAsync(async() => await _categoryRepository.DeleteCategoryAsync(id.Value)); if (httpResponse.IsSuccess) { var category = ProductCategories.Single(x => x.Id == httpResponse.Value); ProductCategories.Remove(category); } else { await _dialogService.ShowMessageAsync(httpResponse.Message, httpResponse.Title); } } catch (Exception ex) { _logService.Write(ex); await _dialogService.ShowMessageAsync(ex.Message); } }
private string DeleteCategory(HHPrincipal principal, HttpContext context, ref bool result) { string msg = string.Empty; if (principal.IsInRole("ProductCategoryModule-Delete")) { DataActionStatus s = ProductCategories.Delete(context.Request["categoryID"]); switch (s) { case DataActionStatus.Success: msg = "已成功删除所选的产品分类!"; result = true; break; case DataActionStatus.RelationshipExist: result = false; msg = "产品分类下存在关联数据[子分类/属性/商品],无法被删除!"; break; case DataActionStatus.UnknownFailure: result = false; msg = "删除产品分类信息时发生了未知的错误!"; break; } } else { throw new Exception("您没有执行此操作的权限!"); } return(msg); }
void BindData() { ProductProperty property = ProductProperties.GetProperty(id); ProductCategory category = null; if (property != null) { btnPost.Text = "修改"; this.txtPropertyDesc.Text = property.PropertyDesc; this.txtPropertyName.Text = property.PropertyName; this.txtDisplayOrder.Text = property.DisplayOrder.ToString(); this.scHidden.SelectedValue = property.SubCategoryHidden; category = ProductCategories.GetCategory(property.CategoryID); } if (category == null) { category = ProductCategories.GetCategory(categoryID); } if (category != null) { ltParCategory.Text = category.CategoryName; ltParCategoryDesc.Text = category.CategoryDesc; } else { parentName.Visible = false; parentDesc.Visible = false; } }
public static void GetModelInfoByDate(DateTime d, ProductCategories pc) { SqlConnection conn = new SqlConnection(); conn.ConnectionString = _ReadConnectionString; try { conn.Open(); SqlCommand command = new SqlCommand("sprocModelInfoByDate", conn); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@Date", d)); command.Parameters.AddWithValue($"@{ProductCategories.db_ID}", pc.ID); SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { ItemInfo inf = new ItemInfo(); inf.Fill(dr); ItemInfos.ItemInfoList.Add(inf); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); //throw; } finally { conn.Close(); } }
/// <summary> /// 加载数据 /// </summary> void BindCategory() { TreeNode root = new TreeNode("所有分类", "0", GlobalSettings.RelativeWebRoot + "images/default/cat.gif"); TreeNode tn = null; this.tvCategory.Nodes.Add(root); List <ProductCategory> categories = ProductCategories.GetChidCategories(0); foreach (ProductCategory category in categories) { tn = new TreeNode(category.CategoryName, category.CategoryID.ToString(), GlobalSettings.RelativeWebRoot + "images/default/cat.gif"); tn.ToolTip = category.CategoryDesc; //tn.CollapseAll(); LoadChild(tn); root.ChildNodes.Add(tn); //mbMsg.ShowMsg("请在产品分类树中选择您将要执行操作的分类"); } HttpCookie cache = HHCookie.GetCookie(nodeState + Profile.AccountInfo.UserName); int categoryID = 0; if (cache != null) { categoryID = Convert.ToInt32(cache.Value); } CheckNode(tvCategory.Nodes, categoryID.ToString()); BindDetail(categoryID); }
public List <ProductCategories> GetPCDetails(long prdcid) { List <ProductCategories> lstprodcatgry = new List <ProductCategories>(); ProductCategories objprodctgry = null; try { db.OpenConn(); string query = "select * from ProductCategory where ProductCategoryID=@ProductCategoryID"; SqlCommand cmd = new SqlCommand(query, db.conn); cmd.Parameters.AddWithValue("@ProductCategoryID", prdcid); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { objprodctgry = new ProductCategories(); objprodctgry.ProductCategoryID = long.Parse(dr["ProductCategoryID"].ToString()); objprodctgry.ProductCategoryName = dr["ProductCategoryName"].ToString(); objprodctgry.Description = dr["Description"].ToString(); lstprodcatgry.Add(objprodctgry); } dr.Close(); db.CloseConn(); } catch (Exception ex) { db.CloseConn(); throw ex; } return(lstprodcatgry); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Session["gemsize"] = null; Session["price"] = null; Session["descen"] = null; Session["ascen"] = null; //List<Products> lstobjp = objproducts.GetProductsData(); List <ProductCategories> lstpc = new List <ProductCategories>(); ProductCategories objpcid = new ProductCategories(); lstpc = objpcid.GetAllProductCategory(); PcGridview.DataSource = lstpc; PcGridview.DataBind(); //PCNameGridview.DataSource = lstobjp; //PCNameGridview.DataBind(); } else { Session["gemsize"] = null; Session["price"] = null; Session["descen"] = null; Session["ascen"] = null; //List<Products> lstobjp = objproducts.GetProductsData(); List <ProductCategories> lstpc = new List <ProductCategories>(); ProductCategories objpcid = new ProductCategories(); lstpc = objpcid.GetAllProductCategory(); PcGridview.DataSource = lstpc; PcGridview.DataBind(); } }
private void GetProductFromCategory(ProductCategories category, int productNumber) { if (category == ProductCategories.Top_deals) { var blackFridayControl = m_driverForRun.FindElement(By.XPath("//div[@id='v-pills-tab']//button[text()=' Black Friday ']")); blackFridayControl.Click(); Thread.Sleep(2000); categoryControl = m_driverForRun.FindElement(By.XPath("//div[@class='sub-menu opened']//div[@class='column ng-star-inserted']//li[1]/a")); categoryControl.Click(); Thread.Sleep(3000); } else { categoryControl = m_driverForRun.FindElement(By.XPath(category.GetDescription())); categoryControl.Click(); Thread.Sleep(3000); } //if (categoryControl != null) //{ //Thread.Sleep(2000); //categoryControl.Click(); //Thread.Sleep(3000); CaptureProductProperties(productNumber); //} }
public async Task <ActionResult <ProductCategories> > PostProductCategories(ProductCategories productCategories) { _context.ProductCategories.Add(productCategories); await _context.SaveChangesAsync(); return(CreatedAtAction("GetProductCategories", new { id = productCategories.Id }, productCategories)); }
private void ChangeSelectedProductCategory(SelectedProductCategory SelectedProductCategory) { ProductCategoryList = ProductCategories.GetAll().ToSvenTechCollection(); SelectedProduct.ProductCategory = SelectedProductCategory.ProductCategory; SelectedProduct.RefProductCategoryId = SelectedProductCategory.ProductCategory.ProductCategoryId; RaisePropertyChanged("SelectedProduct"); }
public async Task <IActionResult> PutProductCategories(int id, ProductCategories productCategories) { if (id != productCategories.Id) { return(BadRequest()); } _context.Entry(productCategories).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductCategoriesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public JsonResult GetProductsCategory() { ProductCategories productFilter = new ProductCategories(); ResultHandler <List <string> > result = new ResultHandler <List <string> >(productFilter.ProductCategory, ""); return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult CreateCate(ProductCategories model) { var session = Session["session"] as GlobSession; if (session != null) { model.CreateBy = User.Identity.Name.ToString(); if (model.Parent_ProductCategoryID == null) { model.Parent_ProductCategoryID = "0"; } var manager = ServiceFactory.GetService <ProductCategories>(session) as ProductCategoryManager; var obj = manager.Get(new ProductCategories { ProductCategoryID = model.ProductCategoryID }); if (obj == null) { manager.Add(model); return(RedirectToAction("SearchCate", "Product")); } else { return(View("UpdateCate", model)); } } else { return(RedirectToAction("Login", "Account", new { returnUrl = Url.Action("CreateCate") })); } }
/// <summary> /// Clears all the global /// </summary> public static void ClearValues() { AccountingGroups.Clear(); CostProfileGroups.Clear(); CountriesOfOrigin.Clear(); CustomerIdConversions.Clear(); ExternalIdTypes.Clear(); ItemCategories.Clear(); ItemGroups.Clear(); ItemIds.Clear(); ItemIdSuffixes.Clear(); ItemRecords.Clear(); Languages.Clear(); Licenses.Clear(); LocalItemIds.Clear(); MetaDescriptions.Clear(); PricingGroups.Clear(); ProductCategories.Clear(); ProductFormats.Clear(); ProductGoups.Clear(); ProductLines.Clear(); Properties.Clear(); PsStatuses.Clear(); RequestStatus.Clear(); SpecialCharacters.Clear(); TariffCodes.Clear(); Territories.Clear(); ToolTips.Clear(); UpcProductFormatExceptions.Clear(); Upcs.Clear(); UserNames.Clear(); UserRoles.Clear(); WebCategoryList.Clear(); }
private void SetupForCategory() { base.CurrentProductCategory = ProductCategories.GetProductCategory(int.Parse(base.Request.QueryString["c"].ToString())); List <SueetieProduct> sueetieProductsByCategory = Products.GetSueetieProductsByCategory(base.CurrentProductCategory.CategoryID, true); this.rptProducts.DataSource = sueetieProductsByCategory; this.rptProducts.DataBind(); }
public List <Product> Products(ProductCategories productCategory) { if (productCategory == ProductCategories.All) { return(products); } return(products.Where(x => x.Category == productCategory).ToList()); }
public void Collect(IEnumerable <int> productIds) { Attributes.Collect(productIds); AttributeCombinations.Collect(productIds); TierPrices.Collect(productIds); ProductCategories.Collect(productIds); AppliedDiscounts.Collect(productIds); }
public virtual void AddCategory(Category category) { var productCategory = new ProductCategory { Category = category, Product = this }; ProductCategories.Add(productCategory); category.ProductCategories.Add(productCategory); }
private bool CreatePropertyControl() { List <ProductProperty> selectedProperties = ProductProperties.GetPropertiesByProductID(ProductID); List <ProductProperty> properties = ProductProperties.GetAllPropertyByCategoryIDList(CategoryIDList); if (properties.Count > 0) { foreach (ProductProperty property in properties) { Literal ltBegin = new Literal(); ltBegin.Text = "<li>"; this.phProperty.Controls.Add(ltBegin); //label Label lblText = new Label(); lblText.Text = property.PropertyName; this.phProperty.Controls.Add(lblText); //textbox TextBox txtValue = new TextBox(); txtValue.ID = GenerateID(property.PropertyID); foreach (ProductProperty p in selectedProperties) { if (p.PropertyID == property.PropertyID) { txtValue.Text = p.PropertyValue; break; } } this.phProperty.Controls.Add(txtValue); List <ProductCategory> subCategories = ProductCategories.GetCategoriesByPropertyID(property.PropertyID); if (subCategories.Count > 0) { //ddl DropDownList ddlSubCategory = new DropDownList(); ddlSubCategory.Items.Add(new ListItem("请选择", "0")); foreach (ProductCategory category in subCategories) { ddlSubCategory.Items.Add(new ListItem(category.CategoryName, category.CategoryName.ToString())); } ddlSubCategory.Attributes.Add("onchange", "changeProperty(this)"); this.phProperty.Controls.Add(ddlSubCategory); } Literal ltEnd = new Literal(); ltEnd.Text = "</li>"; this.phProperty.Controls.Add(ltEnd); } return(true); } else { return(false); } }
private void AddChildCategory(TreeNode parent, ProductCategory category) { foreach (ProductCategory pc in ProductCategories.GetChidCategories(category.CategoryID)) { TreeNode tn = CreateNode(pc.CategoryName, pc.CategoryID.ToString(), pc.CategoryDesc); parent.ChildNodes.Add(tn); AddChildCategory(tn, pc); } }
public virtual void AddProduct(Product product) { var productCategory = new ProductCategory { Category = this, Product = product }; product.ProductCategories.Add(productCategory); ProductCategories.Add(productCategory); }