示例#1
0
        /// <summary>
        /// Gets all available product categories
        /// </summary>
        public bool GetAllCategories(CategoryDS categoryDS, int from, int count)
        {
            try
            {
                SqlDataReader reader = null;
                try
                {
                    reader = SqlHelper.ExecuteReader(this.ConnectionString,
                                                     CommandType.StoredProcedure,
                                                     "SelectAllCategories");

                    SqlHelperExtension.Fill(reader, categoryDS, "category", 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_ExceptionCantGetCategories"), e);
            }
        }
示例#2
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);
            }
        }
示例#3
0
        /// <summary>
        /// Gets the customer info
        /// </summary>
        /// <param name="customerDS">a dataset that will be used to store the customer info</param>
        /// <param name="email">customer email</param>
        public void GetCustomerByEmail(CustomerDS customerDS, string email)
        {
            try
            {
                SqlDataReader reader = null;
                try
                {
                    reader = SqlHelper.ExecuteReader(this.ConnectionString,
                                                     CommandType.StoredProcedure,
                                                     "SelectCustomerByEmail",
                                                     new SqlParameter[] { new SqlParameter("@EmailAddress", email) });

                    SqlHelperExtension.Fill(reader, customerDS, customerDS.Customers.TableName, 0, 1);
                }
                finally
                {
                    if (reader != null)
                    {
                        ((IDisposable)reader).Dispose();
                    }
                }
            }
            catch (Exception e)
            {
                throw new ApplicationException(String.Format(ResourceManager.GetString("RES_ExceptionCantGetCustomer"), email), e);
            }
        }
示例#4
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);
            }
        }