Beispiel #1
0
        public List <ProductDetails> FindByTag(long tagId, int startIndex, int count)
        {
            List <ProductDetails> products = new List <ProductDetails>();

            List <Product> productList = TagDao.Find(tagId).Products.ToList <Product>();

            int c = 0;

            for (int i = startIndex; i < productList.Count; i++)
            {
                if (c == count)
                {
                    break;
                }
                long     productId     = productList.ElementAt(i).productId;
                string   name          = productList.ElementAt(i).name;
                long     categoryId    = productList.ElementAt(i).categoryId;
                string   categoryName  = CategoryDao.Find(productList.ElementAt(i).categoryId).name;
                DateTime registerDate  = productList.ElementAt(i).registerDate;
                double   prize         = productList.ElementAt(i).prize;
                int      numberOfUnits = productList.ElementAt(i).numberOfUnits;
                products.Add(new ProductDetails(name, categoryId, categoryName, registerDate, prize, productId, numberOfUnits, false));
                c++;
            }
            return(products);
        }
Beispiel #2
0
        public ProductDetails FindProduct(long id)
        {
            Product product;

            product = ProductDao.Find(id);
            long   categoryId   = product.categoryId;
            string categoryName = CategoryDao.Find(product.categoryId).name;

            ProductDetails productDetails;

            if (product is Movie)
            {
                Movie mov = product as Movie;
                productDetails = new MovieDetails(product.name, categoryId, categoryName, product.registerDate, product.prize, product.productId, product.numberOfUnits, false, mov.title, mov.director, mov.summary, mov.topic, mov.duration);
            }
            else if (product is Book)
            {
                Book book = product as Book;
                productDetails = new BookDetails(product.name, categoryId, categoryName, product.registerDate, product.prize, product.productId, product.numberOfUnits, false, book.title, book.author, book.summary, book.topic, book.pages);
            }
            else if (product is CD)
            {
                CD cd = product as CD;
                productDetails = new CDDetails(product.name, categoryId, categoryName, product.registerDate, product.prize, product.productId, product.numberOfUnits, false, cd.title, cd.artist, cd.topic, cd.songs);
            }
            else
            {
                productDetails = new ProductDetails(product.name, categoryId, categoryName, product.registerDate, product.prize, product.productId, product.numberOfUnits, false);
            }
            return(productDetails);
        }
Beispiel #3
0
        public List <ProductDetails> FindByKeywords(string keywords, int startIndex, int count)
        {
            List <ProductDetails> products = new List <ProductDetails>();
            string productName             = keywords;

            try
            {
                List <Product> productList = ProductDao.FindByKeywords(keywords, -1, startIndex, count);

                for (int i = 0; i < productList.Count; i++)
                {
                    long     productId     = productList.ElementAt(i).productId;
                    string   name          = productList.ElementAt(i).name;
                    long     categoryId    = productList.ElementAt(i).categoryId;
                    string   categoryName  = CategoryDao.Find(productList.ElementAt(i).categoryId).name;
                    DateTime registerDate  = productList.ElementAt(i).registerDate;
                    double   prize         = productList.ElementAt(i).prize;
                    int      numberOfUnits = productList.ElementAt(i).numberOfUnits;
                    products.Add(new ProductDetails(name, categoryId, categoryName, registerDate, prize, productId, numberOfUnits, false));
                }
            }catch (InstanceNotFoundException e)
            {
            }
            return(products);
        }
Beispiel #4
0
 public override void ConvertSpecific(NoteParam param, Data.Entity.Note entity)
 {
     entity.Account  = AccountDao.Find(param.AccountId);
     entity.Category = CategoryDao.Find(param.CategoryId);
     entity.Status   = StatusDao.Find(param.StatusId);
     entity.Type     = TypeDao.Find(param.TypeId);
 }
    // Populate the controls
    private void PopulateControls()
    {
        // Retrieve product details and category details from database
        ECommerce.CdShop.Entity.Product productDetails = CatalogAccess.GetProductDetails(currentProductId);
        Category categoryDetails = categoryDao.Find(currentCategoryId);

        // Set up labels and images
        productNameLabel.Text = productDetails.Name;
        image1.ImageUrl       = Link.ToProductImage(productDetails.Thumbnail);
        image2.ImageUrl       = Link.ToProductImage(productDetails.Image);
        // Link to department
        catLink.Text        = categoryDetails.Name;
        catLink.NavigateUrl = "AdminCategories.aspx?DepartmentID=" + currentDepartmentId;
        // Clear form
        categoriesLabel.Text = "";
        categoriesListAssign.Items.Clear();
        categoriesListMove.Items.Clear();
        categoriesListRemove.Items.Clear();
        // Fill categoriesLabel and categoriesListRemove with data
        string    categoryId, categoryName;
        DataTable productCategories = CatalogAccess.GetCategoriesWithProduct(currentProductId);

        for (int i = 0; i < productCategories.Rows.Count; i++)
        {
            // obtain category id and name
            categoryId   = productCategories.Rows[i]["Id"].ToString();
            categoryName = productCategories.Rows[i]["Name"].ToString();
            // add a link to the category admin page
            categoriesLabel.Text +=
                (categoriesLabel.Text == "" ? "" : ", ") +
                "<a href='AdminProducts.aspx?DepartmentID=" +
                CatalogAccess.GetCategoryDetails(currentCategoryId).DepartmentId +
                "&CategoryID=" + categoryId + "'>" +
                categoryName + "</a>";
            // populate the categoriesListRemove combo box
            categoriesListRemove.Items.Add(new ListItem(categoryName, categoryId));
        }
        // Delete from catalog or remove from category?
        if (productCategories.Rows.Count > 1)
        {
            deleteButton.Visible = false;
            removeButton.Enabled = true;
        }
        else
        {
            deleteButton.Visible = true;
            removeButton.Enabled = false;
        }
        // Fill categoriesListMove and categoriesListAssign with data
        productCategories = CatalogAccess.GetCategoriesWithoutProduct(currentProductId);
        for (int i = 0; i < productCategories.Rows.Count; i++)
        {
            // obtain category id and name
            categoryId   = productCategories.Rows[i]["Id"].ToString();
            categoryName = productCategories.Rows[i]["Name"].ToString();
            // populate the list boxes
            categoriesListAssign.Items.Add(new ListItem(categoryName, categoryId));
            categoriesListMove.Items.Add(new ListItem(categoryName, categoryId));
        }
    }
Beispiel #6
0
        public List <ProductDetails> GetOrderLineProductsByOrderId(long orderId)
        {
            Order order = OrderDao.Find(orderId);
            List <ProductDetails> productsDetails = new List <ProductDetails>();

            for (int i = 0; i < order.OrderLines.Count; i++)
            {
                Product        p              = ProductDao.Find(order.OrderLines.ElementAt(i).productId);
                string         categoryName   = CategoryDao.Find(p.categoryId).name;
                ProductDetails productDetails = new ProductDetails(p.name, p.categoryId, categoryName, p.registerDate, order.OrderLines.ElementAt(i).unitPrize, p.productId, order.OrderLines.ElementAt(i).numberOfUnits, order.OrderLines.ElementAt(i).forGift);
                productsDetails.Add(productDetails);
            }

            return(productsDetails);
        }
Beispiel #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // Load the grid only the first time the page is loaded
     if (!Page.IsPostBack)
     {
         // Get CategoryID and DepartmentID from the query string
         string categoryId   = Request.QueryString["CategoryID"];
         string departmentId = Request.QueryString["DepartmentID"];
         // Obtain the category name
         CategoryDao dao = new CategoryDao();
         ECommerce.CdShop.Entity.Category cd = dao.Find(categoryId);
         string categoryName = cd.Name;
         // Link to department
         catLink.Text        = categoryName;
         catLink.NavigateUrl = "AdminCategories.aspx?DepartmentID=" + departmentId;
         // Load the products grid
         BindGrid();
     }
 }
Beispiel #8
0
        public void create(Category objCategory)
        {
            Category objCategoryAux = new Category();
            bool     verification   = true;

            string code = objCategory.IdCategory;

            if (code == null || code.Trim().Equals(""))
            {
                objCategory.State = 10;
                return;
            }
            else
            {
                code         = objCategory.IdCategory.Trim();
                verification = code.Length > 0 && code.Length <= 5;
                if (!verification)
                {
                    objCategory.State = 1;
                    return;
                }
            }

            string name = objCategory.Name;

            if (name == null || name.Equals(""))
            {
                objCategory.State = 20;
                return;
            }
            else
            {
                name         = objCategory.Name.Trim();
                verification = name.Length > 0 && name.Length <= 30;
                if (!verification)
                {
                    objCategory.State = 2;
                    return;
                }
            }

            string description = objCategory.Description;

            if (description == null || description.Trim().Equals(""))
            {
                objCategory.State = 30;
                return;
            }
            else
            {
                description  = objCategory.Description.Trim();
                verification = description.Length > 0 && description.Length <= 50;
                if (!verification)
                {
                    objCategory.State = 3;
                    return;
                }
            }


            objCategoryAux.IdCategory = objCategory.IdCategory;
            verification = !objCategoryDao.Find(objCategoryAux);
            if (!verification)
            {
                objCategory.State = 8;
                return;
            }

            //verificar o nome
            objCategoryAux.Name = objCategory.Name;
            verification        = !objCategoryDao.FindCat(objCategoryAux);
            if (!verification)
            {
                objCategory.State = 16;
                return;
            }

            objCategory.State = 99;
            objCategoryDao.Create(objCategory);
            return;
        }