Ejemplo n.º 1
0
        /// <summary>
        /// Gets the product with the specified identifier
        /// </summary>
        public void GetProductById(ProductDS productDS, int productId)
        {
            try
            {
                SqlDataReader reader = null;
                try
                {
                    reader = SqlHelper.ExecuteReader(this.ConnectionString,
                                                     CommandType.StoredProcedure,
                                                     "SelectProductById",
                                                     new SqlParameter[] { new SqlParameter("@ProductID", productId) });


                    SqlHelperExtension.Fill(reader, productDS, "product", 0, 1);
                    reader.Close();
                }
                finally
                {
                    if (reader != null)
                    {
                        ((IDisposable)reader).Dispose();
                    }
                }
            }
            catch (Exception e)
            {
                throw new ApplicationException(String.Format(ResourceManager.GetString("RES_ExceptionCantGetProduct"), productId), e);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds a new item to a existing cart
 /// </summary>
 /// <remarks>If the item alredy exists in the cart, then only its quantity
 ///	is updated</remarks>
 public void AddToCart(CartDS.CartItemsDataTable cartItems, int productId, int quantity)
 {
     try
     {
         ProductBusinessObject productBO = new ProductBusinessObject();
         ProductDS             products  = new ProductDS();
         productBO.GetProductById(products, productId);
         if (cartItems.Rows.Count > 0)
         {
             DataRow[] selectedItems = cartItems.Select("productID=" + productId);
             if (selectedItems.Length > 0)
             {
                 ((CartDS.CartItem)selectedItems[0]).Quantity += quantity;
             }
             else
             {
                 cartItems.AddCartItem(quantity, productId, products.Products[0].ModelName, products.Products[0].UnitCost);
             }
         }
         else
         {
             cartItems.AddCartItem(quantity, productId, products.Products[0].ModelName, products.Products[0].UnitCost);
         }
     }
     catch (Exception e)
     {
         throw new ApplicationException(ResourceManager.GetString("RES_ExceptionCantAddCartItem"), e);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets all products in the catalog
        /// </summary>
        public bool GetAllProducts(ProductDS productDS, int from, int count)
        {
            try
            {
                SqlDataReader reader = null;
                try
                {
                    reader = SqlHelper.ExecuteReader(this.ConnectionString,
                                                     CommandType.StoredProcedure,
                                                     "SelectAllProducts");

                    SqlHelperExtension.Fill(reader, productDS, "product", from, count);
                    bool ret = reader.Read();
                    reader.Close();

                    return(ret);
                }
                finally
                {
                    if (reader != null)
                    {
                        ((IDisposable)reader).Dispose();
                    }
                }
            }
            catch (Exception e)
            {
                throw new ApplicationException(ResourceManager.GetString("RES_ExceptionCantGetCatalog"), e);
            }
        }
Ejemplo n.º 4
0
        public override DataSet Clone()
        {
            ProductDS cln = ((ProductDS)(base.Clone()));

            cln.InitVars();
            return(cln);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Gets the product with the specified identifier
 /// </summary>
 public void GetProductById(ProductDS productDS, int productId)
 {
     try
     {
         ProductDALC productDALC = new ProductDALC();
         productDALC.GetProductById(productDS, productId);
     }
     catch (Exception e)
     {
         throw new ApplicationException(ResourceManager.GetString("RES_ExceptionGetProduct"), e);
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Gets all products in the catalog
 /// </summary>
 public bool GetAllProducts(ProductDS productDS, int from, int count)
 {
     try
     {
         ProductDALC productDALC = new ProductDALC();
         return(productDALC.GetAllProducts(productDS, from, count));
     }
     catch (Exception e)
     {
         throw new ApplicationException(ResourceManager.GetString("RES_ExceptionGetCatalog"), e);
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates a new order with the specified params
        /// </summary>
        public int CreateOrderFromCart(int customerId, CartDS.CartItemsDataTable items)
        {
            OrderDALC   orderDALC   = new OrderDALC();
            ProductDALC productDALC = new ProductDALC();

            int orderId = orderDALC.CreateOrder(customerId, DateTime.Now, DateTime.Now.AddDays(2));

            foreach (CartDS.CartItem item in items)
            {
                ProductDS productDS = new ProductDS();
                productDALC.GetProductById(productDS, item.ProductId);

                orderDALC.CreateOrderItem(orderId, item.ProductId, productDS.Products[0].UnitCost, item.Quantity);
            }

            return(orderId);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Gets all products in the catalog
        /// </summary>
        public ProductDS GetCatalogProducts()
        {
            ProductDS productDS = new ProductDS();

            try
            {
                ProductBusinessObject productBO = new ProductBusinessObject();
                productBO.GetAllProducts(productDS, 0, 0);
            }
            catch (Exception e)
            {
                State[STATE_EXCEPTION] = e;
                State.NavigateValue    = "error";
                Navigate();
            }

            return(productDS);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Gets all products in the catalog
        /// </summary>
        public ProductDS GetCatalogProducts()
        {
            ProductDS productDS = new ProductDS();

            try
            {
                ProductBusinessObject productBO = new ProductBusinessObject();
                // fill the products dataset will all of the products in the database
                productBO.GetAllProducts(productDS, 0, 0);
            }
            catch (Exception e)
            {
                State[STATE_EXCEPTION] = e;
                State.NavigateValue    = "fail";
                Navigate();
            }

            return(productDS);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Gets all products in the catalog
        /// </summary>
        public bool GetAllProducts(ProductDS productDS, int from, int count)
        {
            try
            {
                SqlDataReader reader = null;
                bool          ret    = false;
                using
                (reader = SqlHelper.ExecuteReader(this.connectionString,
                                                  CommandType.StoredProcedure,
                                                  "SelectAllProducts"))
                {
                    SqlHelperExtension.Fill(reader, productDS, "product", from, count);

                    ret = reader.Read();
                    reader.Close();
                }

                return(ret);
            }
            catch (Exception e)
            {
                throw new ApplicationException(ResourceManager.GetString("RES_ExceptionCantGetCatalog"), e);
            }
        }