Esempio n. 1
0
        public void InsertToKart(LineSale lineSale)
        {
            bool            existProduct = false;
            List <LineSale> listLS       = new List <LineSale>();

            if (Session["ListLineSale"] != null)
            {
                listLS = (List <LineSale>)Session["ListLineSale"];
            }
            if (listLS.Count > 0)
            {
                foreach (LineSale oneLS in listLS)
                {
                    if (lineSale.LineSaleProductId == oneLS.LineSaleProductId)
                    {
                        oneLS.LineSaleProductQuantity += lineSale.LineSaleProductQuantity;
                        Session["ListLineSale"]        = listLS;
                        existProduct = true;
                        break;
                    }
                }
            }
            if (!existProduct)
            {
                listLS.Add(lineSale);
                Session["ListLineSale"] = listLS;
            }
        }
Esempio n. 2
0
        public List <LineSale> GetDepartaments(bool isTypeShoes)
        {
            List <LineSale> lines  = new List <LineSale>();
            string          strSQL = "SELECT * FROM LineSale WHERE DepartamentIsDeleted = 0 AND DepartamentIsTypeShoes = '" + isTypeShoes + "'"; //ToDO
            DataSet         data   = ExecuteWithResultSQL(strSQL);

            if (data.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow Row in data.Tables[0].Rows)
                {
                    LineSale oneLS = new LineSale();
                    oneLS.LineSaleId           = Convert.ToInt32(Row.ItemArray[0].ToString());
                    oneLS.LineSaleProductPrice = Convert.ToDecimal(Row.ItemArray[1].ToString());
                    lines.Add(oneLS);
                }
            }
            return(lines);
        }
        public List <LineSale> GetListLineSalesBySaleId(int saleId)
        {
            List <LineSale> lineSales = new List <LineSale>();
            string          strSQL    = "SELECT P.[ProductId], P.ProductCode, P.ProductName, P.ProductDescription, LS.[LineSaleId],LS.[LineSaleProductQuantity],LS.[LineSaleProductPrice] FROM LineSale LS INNER JOIN Product P ON LS.ProductId = P.ProductId WHERE LS.SaleId = '" + saleId + "'";
            DataSet         data      = ExecuteWithResultSQL(strSQL);

            if (data.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow Row in data.Tables[0].Rows)
                {
                    LineSale oneLS = new LineSale();
                    oneLS.ProductId               = Convert.ToInt32(Row.ItemArray[0].ToString());
                    oneLS.ProductCode             = Row.ItemArray[1].ToString();
                    oneLS.ProductName             = Row.ItemArray[2].ToString();
                    oneLS.ProductDescription      = Row.ItemArray[3].ToString();
                    oneLS.LineSaleId              = Convert.ToInt32(Row.ItemArray[4].ToString());
                    oneLS.LineSaleProductQuantity = Convert.ToInt32(Row.ItemArray[5].ToString());
                    oneLS.ProductPrice            = Convert.ToDecimal(Row.ItemArray[6].ToString());
                    lineSales.Add(oneLS);
                }
            }
            return(lineSales);
        }
Esempio n. 4
0
        protected void btnBuy_Click(object sender, EventArgs e)
        {
            Button btnBuy = (Button)sender;

            string[]     commandArgs = btnBuy.CommandArgument.ToString().Split(new char[] { ',' });
            RepeaterItem item        = (sender as Button).NamingContainer as RepeaterItem;

            (item.FindControl("lblMessageProduct") as Label).Text = "";
            if ((item.FindControl("ddlProductSizeGeneric") as DropDownList).SelectedIndex > 0)
            {
                if (Convert.ToInt32((item.FindControl("txtProductQuantity") as TextBox).Text) > 0 && (item.FindControl("txtProductQuantity") as TextBox).Text != "")
                {
                    bool isTypeShoes = false;
                    if ((item.FindControl("ddlProductSizeGeneric") as DropDownList).SelectedItem.Text.Length > 1)
                    {
                        isTypeShoes = (item.FindControl("ddlProductSizeGeneric") as DropDownList).SelectedItem.Text.Substring(0, 2) == "EU";
                    }
                    int size      = (item.FindControl("ddlProductSizeGeneric") as DropDownList).SelectedIndex;
                    int productId = Convert.ToInt32(commandArgs[0]);
                    if (this.ThereIsStock(productId, size, isTypeShoes))
                    {
                        decimal  productPrice    = Convert.ToInt32(commandArgs[1]);
                        int      productQuantity = Convert.ToInt32((item.FindControl("txtProductQuantity") as TextBox).Text);
                        LineSale oneLS           = new LineSale
                        {
                            LineSaleId = -1,
                            LineSaleProductQuantity = productQuantity,
                            LineSaleProductPrice    = productPrice,
                            ListLineSale            = new List <LineSale>(),
                            LineSaleProductId       = productId
                        };

                        if (isTypeShoes)
                        {
                            oneLS.ProductStockSizeShoes       = new int[17];
                            oneLS.ProductStockSizeShoes[size] = productQuantity;
                        }
                        else
                        {
                            oneLS.ProductStockSize       = new int[8];
                            oneLS.ProductStockSize[size] = productQuantity;
                        }

                        shoppingOnline.InsertToKart(oneLS);
                        (this.Master.FindControl("lblCartNumber") as Label).Text = this.shoppingOnline.GetListLineSale().Count.ToString();
                    }
                    else
                    {
                        (item.FindControl("lblMessageProduct") as Label).Text = "Lo sentimos, no hay stock.";
                    }
                }
                else
                {
                    (item.FindControl("lblMessageProduct") as Label).Text = "Por favor, ingrese una cantidad mayor a cero.";
                }
            }
            else
            {
                (item.FindControl("lblMessageProduct") as Label).Text = "Por favor, seleccione un talle.";
            }
        }