Exemplo n.º 1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int fabricCode = int.Parse(this.hdnSelectedID.Value.Trim());

            if (Page.IsValid)
            {
                try
                {
                    List <PriceBO> lstPrices = (from o in (new PriceBO()).SearchObjects()
                                                where o.Pattern == int.Parse(this.hdnPattern.Value.Trim()) &&
                                                o.FabricCode == fabricCode
                                                select o).ToList();
                    if (lstPrices.Count > 0)
                    {
                        using (TransactionScope ts = new TransactionScope())
                        {
                            PriceBO objPrice = new PriceBO(this.ObjContext);
                            objPrice.ID = lstPrices[0].ID;
                            objPrice.GetObject();

                            foreach (PriceLevelCostBO itemPLC in objPrice.PriceLevelCostsWhereThisIsPrice)
                            {
                                PriceLevelCostBO objPLC = new PriceLevelCostBO(this.ObjContext);
                                objPLC.ID = itemPLC.ID;
                                objPLC.GetObject();

                                foreach (DistributorPriceLevelCostBO itemDPLC in objPLC.DistributorPriceLevelCostsWhereThisIsPriceLevelCost)
                                {
                                    DistributorPriceLevelCostBO objDPLC = new DistributorPriceLevelCostBO(this.ObjContext);
                                    objDPLC.ID = itemDPLC.ID;
                                    objDPLC.GetObject();

                                    objDPLC.Delete();
                                }
                                objPLC.Delete();
                            }
                            objPrice.Delete();

                            this.ObjContext.SaveChanges();
                            ts.Complete();
                        }
                    }

                    // Populate active pattern fabrics
                    this.PopulatePatternFabrics();
                }
                catch (Exception ex)
                {
                    // Log the error
                    IndicoLogging.log.Error("btnDelete_Click : Error occured while Adding the Item", ex);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Process the page data.
        /// </summary>
        private void ProcessForm(int queryId, bool isDelete)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    PatternBO objPattern = new PatternBO(this.ObjContext);
                    if (queryId > 0)
                    {
                        objPattern.ID = queryId;
                        objPattern.GetObject();
                    }
                    if (isDelete)
                    {
                        List <PriceBO> lstPrces = objPattern.PricesWhereThisIsPattern;
                        foreach (PriceBO price in lstPrces)
                        {
                            PriceBO objPrice = new PriceBO(this.ObjContext);
                            objPrice.ID = price.ID;
                            objPrice.GetObject();

                            foreach (PriceLevelCostBO priceLevelCost in objPrice.PriceLevelCostsWhereThisIsPrice)
                            {
                                PriceLevelCostBO objPriceLevelCost = new PriceLevelCostBO(this.ObjContext);
                                objPriceLevelCost.ID = priceLevelCost.ID;
                                objPriceLevelCost.GetObject();

                                objPriceLevelCost.Delete();
                            }

                            objPrice.Delete();
                        }
                    }
                    this.ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                // Log the error
                //IndicoLogging.log("Error occured while Adding the Item", ex);
            }
        }