예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     SimplicityCommLib.DataSets.Common.ProductsTableAdapters.ProductsTableAdapter prodTA = new SimplicityCommLib.DataSets.Common.ProductsTableAdapters.ProductsTableAdapter();
     //IEnumerator<SimplicityCommLib.DataSets.Common.Products.ProductsRow> ieProducts = .GetEnumerator();
     rptProds.DataSource = prodTA.GetAllProducts();
     rptProds.DataBind();
     if (Request[WebConstants.Request.PRODUCT_ID] != null)
     {
         int productId = int.Parse(Request[WebConstants.Request.PRODUCT_ID]);
         ProductsTableAdapters.ProductVideoTableAdapter videoTA = new ProductsTableAdapters.ProductVideoTableAdapter();
         rptVideos.DataSource = videoTA.GetVideosByProduct(productId);
         rptVideos.DataBind();
         lblContent.Visible = false;
         SimplicityCommLib.DataSets.Common.Products.ProductsRow product = DatabaseUtility.Instance.GetProduct(productId);
         if(product != null)
         {
             lblProdName.Text = product.Name;
             lblProdName.Visible = true;
         }
     }
     else
     {
         lblContent.Visible = true;
         lblProdName.Visible = false;
     }
 }
 public SimplicityCommLib.DataSets.Common.Products.ProductsRow GetProduct(int productId)
 {
     SimplicityCommLib.DataSets.Common.ProductsTableAdapters.ProductsTableAdapter prodTA = new SimplicityCommLib.DataSets.Common.ProductsTableAdapters.ProductsTableAdapter();
     IEnumerator<SimplicityCommLib.DataSets.Common.Products.ProductsRow> ieProducts = prodTA.GetProductById(productId).GetEnumerator();
     if (ieProducts.MoveNext())
     {
         return ieProducts.Current;
     }
     return null;
 }
예제 #3
0
        public static Product LoadCompleteProduct(int productId)
        {
            SimplicityCommLib.DataSets.Common.ProductsTableAdapters.ProductsTableAdapter prodTA = new SimplicityCommLib.DataSets.Common.ProductsTableAdapters.ProductsTableAdapter();
            SimplicityCommLib.DataSets.Common.Products.ProductsRow productDS = DatabaseUtility.Instance.GetProduct(productId);
            if (productDS != null)
            {
                Product product = new Product();
                product.ProductDS = productDS;
                ProductsTableAdapters.ProductDetailTableAdapter detailTA = new ProductsTableAdapters.ProductDetailTableAdapter();
                IEnumerator<Products.ProductDetailEntityRow> details = detailTA.GetDetailsByProduct(productId).GetEnumerator();
                double totalPrice = 0;
                while (details.MoveNext())
                {
                    if (details.Current.mandatory)
                    {
                        product.mandatoryDetails.Add(details.Current);
                        totalPrice += details.Current.price;
                    }
                    else
                    {
                        product.optionalDetails.Add(details.Current);
                    }
                }

                ProductsTableAdapters.ProductVersionTableAdapter versionTA = new ProductsTableAdapters.ProductVersionTableAdapter();
                IEnumerator<Products.ProductVersionEntityRow> versions = versionTA.GetVersionByProduct(productId).GetEnumerator();
                while (versions.MoveNext())
                {
                    product.versions.Add(versions.Current);
                }
                return product;
            }
            else
            {
                return null;
            }
        }