Beispiel #1
0
        private bool Delete()
        {
            bool   boRetValue = false;
            string stIDs      = "";

            foreach (DataListItem item in lstItem.Items)
            {
                HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList");
                if (chkList != null)
                {
                    if (chkList.Checked == true)
                    {
                        stIDs     += chkList.Value + ",";
                        boRetValue = true;
                    }
                }
            }
            if (boRetValue)
            {
                ProductGroup clsProductGroup = new ProductGroup();
                clsProductGroup.Delete(stIDs.Substring(0, stIDs.Length - 1));
                clsProductGroup.CommitAndDispose();
            }

            return(boRetValue);
        }
        public static bool UnAssignAllProducts(ProductFilter filter, int groupId)
        {
            int totalCount   = ProductDataSource.FindProductsCount(filter.Name, filter.SearchDescriptions, filter.Sku, filter.CategoryId, filter.ManufacturerId, filter.VendorId, filter.Featured, 0, filter.FromPrice, filter.ToPrice, filter.DigitalGoodsOnly, filter.GiftCertificatesOnly, filter.KitsOnly, filter.SubscriptionsOnly);
            int currentIndex = 0;
            IDatabaseSessionManager database = AbleContext.Current.Database;

            database.BeginTransaction();
            while (currentIndex < totalCount)
            {
                IList <Product> currentBatch = ProductDataSource.FindProducts(filter.Name, filter.SearchDescriptions, filter.Sku, filter.CategoryId, filter.ManufacturerId, filter.VendorId, filter.Featured, 0, filter.FromPrice, filter.ToPrice, filter.DigitalGoodsOnly, filter.GiftCertificatesOnly, filter.KitsOnly, filter.SubscriptionsOnly, 100, currentIndex);
                foreach (Product p in currentBatch)
                {
                    ProductGroup pg = ProductGroupDataSource.Load(p.Id, groupId);
                    if (pg != null)
                    {
                        p.ProductGroups.Remove(pg);
                        p.Save();
                        pg.Delete();
                    }
                }
                currentIndex += 100;
            }

            database.CommitTransaction();
            return(true);
        }
        public static bool UnAssignProducts(int[] productIds, int groupId)
        {
            List <string>           ids      = new List <string>();
            IDatabaseSessionManager database = AbleContext.Current.Database;

            database.BeginTransaction();
            foreach (int pid in productIds)
            {
                ProductGroup pg = ProductGroupDataSource.Load(pid, groupId);
                if (pg != null)
                {
                    var product = pg.Product;
                    product.ProductGroups.Remove(pg);
                    product.Save();
                    pg.Delete();
                }
            }
            database.CommitTransaction();
            return(true);
        }
Beispiel #4
0
        protected void lstItem_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
        {
            HtmlInputCheckBox chkList = null;
            string            stParam = string.Empty;

            chkList = (HtmlInputCheckBox)e.Item.FindControl("chkList");
            stParam = "?task=" + Common.Encrypt("list", Session.SessionID) + "&groupid=" + Common.Encrypt(chkList.Value, Session.SessionID);

            switch (e.CommandName)
            {
            case "imgItemDelete":
                ProductGroup clsProductGroup = new ProductGroup();
                clsProductGroup.Delete(chkList.Value);
                clsProductGroup.CommitAndDispose();

                LoadList();
                break;

            case "imgItemEdit":
                stParam = "?task=" + Common.Encrypt("edit", Session.SessionID) + "&id=" + Common.Encrypt(chkList.Value, Session.SessionID);
                Response.Redirect("Default.aspx" + stParam);
                break;

            case "imgVariationsClick":
                Response.Redirect(Constants.ROOT_DIRECTORY + "/MasterFiles/_ProductGroup/_Variations/Default.aspx" + stParam);
                break;

            case "imgVariationsMatrixClick":
                Response.Redirect(Constants.ROOT_DIRECTORY + "/MasterFiles/_ProductGroup/_VariationsMatrix/Default.aspx" + stParam);
                break;

            case "imgUnitsMatrixClick":
                Response.Redirect(Constants.ROOT_DIRECTORY + "/MasterFiles/_ProductGroup/_UnitsMatrix/Default.aspx" + stParam);
                break;
            }
        }