zimiro 0 Report post Posted August 8, 2013 alguem pode me ajudar, como criar um carrinho de compra usando mysql, sem usar profile como tem ai na internet usando sqlserver. Share this post Link to post Share on other sites
quintelab 91 Report post Posted August 8, 2013 Como assim ajudar? Um carrinho tem vários funcionalidades, ou pega um pronto ou vai tentando desenvolver e postando as dúvidas aqui.Abraços... Share this post Link to post Share on other sites
zimiro 0 Report post Posted August 12, 2013 o problema e assim, to salvando valores em cookeis, so que não to conseguindo colocar esses valores no grid com quantidades. Share this post Link to post Share on other sites
quintelab 91 Report post Posted August 20, 2013 Como pretende fazer isso? Na sua grid ja tem uma lista de registros de algum lugar? Esta tudo nos cookies?Abraços... Share this post Link to post Share on other sites
zimiro 0 Report post Posted August 20, 2013 quero fazer com cookies mais ta complicado por ser primeira loja. Share this post Link to post Share on other sites
KhaosDoctor 242 Report post Posted August 20, 2013 cookies são desnecessários, use Session Arrays. Share this post Link to post Share on other sites
zimiro 0 Report post Posted August 20, 2013 por to com problema assim fiz loja em asp.net com mysql sem profile direto ele joga os produtos para essa clase quando add carrinho using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using Microsoft.VisualBasic; using System.Data.MySqlClient; using System.Collections.Generic; namespace DevMedia.ECommerce { /// <summary> /// Class CartItem /// </summary> [Serializable] public class CartItem { //represent each of the items in your CartItem object. private int _productID; private string _productName; private string _productImageUrl; private int _quantity; private double _price; public CartItem() { } public CartItem(int ProductID, string ProductName, string ProductImageUrl, int Quantity, double Price) { _productID = ProductID; _productName = ProductName; _productImageUrl = ProductImageUrl; _quantity = Quantity; _price = Price; } public int ProductID { get { return _productID; } set { _productID = value; } } public string ProductName { get { return _productName; } set { _productName = value; } } public string ProductImageUrl { get { return _productImageUrl; } set { _productImageUrl = value; } } public int Quantity { get { return _quantity; } set { _quantity = value; } } public double Price { get { return _price; } set { _price = value; } } public double LineTotal { get { return _quantity*_price; } } } /// <summary> /// Class Cart /// </summary> [Serializable] public class Cart { private DateTime _dateCreated; private DateTime _lastUpdate; private List<CartItem> _items; public Cart() { if (_items == null) { _items = new List<CartItem>(); _dateCreated = DateTime.Now; } } public List<CartItem> Items { get { return _items; } set { _items = value; } } public void Insert(int ProductID, double Price, int Quantity, string ProductName, string ProductImageUrl) { int ItemIndex = ItemIndexOfID(ProductID); if (ItemIndex == -1) { CartItem NewItem = new CartItem(); NewItem.ProductID = ProductID; NewItem.Quantity = Quantity; NewItem.Price = Price; NewItem.ProductName = ProductName; NewItem.ProductImageUrl = ProductImageUrl; _items.Add(NewItem); } else { _items[ItemIndex].Quantity += 1; } _lastUpdate = DateTime.Now; } public void Update(int RowID, int ProductID, int Quantity, double Price) { CartItem Item = _items[RowID]; Item.ProductID = ProductID; Item.Quantity = Quantity; Item.Price = Price; _lastUpdate = DateTime.Now; } public void DeleteItem(int rowID) { _items.RemoveAt(rowID); _lastUpdate = DateTime.Now; } private int ItemIndexOfID(int ProductID) { int index = 0; foreach (CartItem item in _items) { if (item.ProductID == ProductID) { return index; } index += 1; } return -1; } public double Total { get { double t = 0; if (_items == null) { return 0; } foreach (CartItem Item in _items) { t += Item.LineTotal; } return t; } } } } so que não estou conseguindo usar ela no carrinho para trazer os produtos novamente Share this post Link to post Share on other sites
KhaosDoctor 242 Report post Posted August 21, 2013 Cara, não vou ler seu código completo, passe só o que está dando erro. Share this post Link to post Share on other sites
zimiro 0 Report post Posted August 21, 2013 erro q não estou conseguindo carregar a lista de produtos no carrinho para usar. Share this post Link to post Share on other sites
KhaosDoctor 242 Report post Posted August 21, 2013 Qual dessas funções carrega a lista? Share this post Link to post Share on other sites
zimiro 0 Report post Posted August 21, 2013 public void Insert(int ProductID, double Price, int Quantity, string ProductName, string ProductImageUrl) { int ItemIndex = ItemIndexOfID(ProductID); if (ItemIndex == -1) { CartItem NewItem = new CartItem(); NewItem.ProductID = ProductID; NewItem.Quantity = Quantity; NewItem.Price = Price; NewItem.ProductName = ProductName; NewItem.ProductImageUrl = ProductImageUrl; _items.Add(NewItem); } else { _items[ItemIndex].Quantity += 1; } _lastUpdate = DateTime.Now; } Share this post Link to post Share on other sites
KhaosDoctor 242 Report post Posted August 21, 2013 E aonde você busca essa variável "_items"? Share this post Link to post Share on other sites
KhaosDoctor 242 Report post Posted August 21, 2013 Sim? Share this post Link to post Share on other sites
zimiro 0 Report post Posted August 21, 2013 sem ele recebe tudo aqui public Cart() { if (_items == null) { _items = new List<CartItem>(); _dateCreated = DateTime.Now; } } public List<CartItem> Items { get { return _items; } set { _items = value; } } Share this post Link to post Share on other sites
KhaosDoctor 242 Report post Posted August 21, 2013 Sim, mas você viu se essa variável está recebendo todos os valores? Share this post Link to post Share on other sites
zimiro 0 Report post Posted August 21, 2013 sim public void Insert(int ProductID, double Price, int Quantity, string ProductName, string ProductImageUrl) { int ItemIndex = ItemIndexOfID(ProductID); if (ItemIndex == -1) { CartItem NewItem = new CartItem(); NewItem.ProductID = ProductID; NewItem.Quantity = Quantity; NewItem.Price = Price; NewItem.ProductName = ProductName; NewItem.ProductImageUrl = ProductImageUrl; _items.Add(NewItem); } else { _items[ItemIndex].Quantity += 1; } _lastUpdate = DateTime.Now; } Share this post Link to post Share on other sites
KhaosDoctor 242 Report post Posted August 22, 2013 Você está me mandando muitos códigos, mas a variável está populada? Já colocou breakpoints para verificar? Share this post Link to post Share on other sites
zimiro 0 Report post Posted August 22, 2013 entao eu to salvando aqui //salvando em session carrinho HttpContext.Current.Session["CarrinhoSessaoChave"] = HttpContext.Current.User.Identity.Name; HttpContext.Current.Session["CarrinhoSessaoChave"] = _items; so que no momento de carregar ele novamente que problema. Share this post Link to post Share on other sites
KhaosDoctor 242 Report post Posted August 22, 2013 Você não está entendendo cara, você tem absoluta certeza de que a variável "_item" NÃO está em branco? Share this post Link to post Share on other sites