Exemplo n.º 1
0
        public static void SaveProductMap(int varCategoryID, int[] itemList)
        {
            QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
            //delete out the existing
            QueryCommand cmdDel = new QueryCommand("DELETE FROM [Product_Category_Map] WHERE [Product_Category_Map].[CategoryID] = @CategoryID", Category.Schema.Provider.Name);

            cmdDel.AddParameter("@CategoryID", varCategoryID, DbType.Int32);
            coll.Add(cmdDel);
            DataService.ExecuteTransaction(coll);
            foreach (int item in itemList)
            {
                ProductCategoryMap varProductCategoryMap = new ProductCategoryMap();
                varProductCategoryMap.SetColumnValue("CategoryID", varCategoryID);
                varProductCategoryMap.SetColumnValue("ProductID", item);
                varProductCategoryMap.Save();
            }
        }
Exemplo n.º 2
0
        public static void SaveCategoryMap(int varProductID, System.Web.UI.WebControls.ListItemCollection itemList)
        {
            QueryCommandCollection coll = new SubSonic.QueryCommandCollection();
            //delete out the existing
            QueryCommand cmdDel = new QueryCommand("DELETE FROM [Product_Category_Map] WHERE [Product_Category_Map].[ProductID] = @ProductID", Product.Schema.Provider.Name);

            cmdDel.AddParameter("@ProductID", varProductID, DbType.Int32);
            coll.Add(cmdDel);
            DataService.ExecuteTransaction(coll);
            foreach (System.Web.UI.WebControls.ListItem l in itemList)
            {
                if (l.Selected)
                {
                    ProductCategoryMap varProductCategoryMap = new ProductCategoryMap();
                    varProductCategoryMap.SetColumnValue("ProductID", varProductID);
                    varProductCategoryMap.SetColumnValue("CategoryID", l.Value);
                    varProductCategoryMap.Save();
                }
            }
        }