public static void PluginMove(HttpContext context)
        {
            if (NBrightBuyUtils.CheckRights())
            {
                var ajaxInfo        = NBrightBuyUtils.GetAjaxFields(context);
                var movepluginsid   = ajaxInfo.GetXmlPropertyInt("genxml/hidden/movepluginsid");
                var movetopluginsid = ajaxInfo.GetXmlPropertyInt("genxml/hidden/movetopluginsid");
                if (movepluginsid > 0 && movetopluginsid > 0)
                {
                    var objCtrl = new NBrightBuyController();
                    var infoTo  = objCtrl.GetData(movetopluginsid);
                    var info    = objCtrl.GetData(movepluginsid);

                    if (infoTo.GetXmlPropertyDouble("genxml/hidden/index") < info.GetXmlPropertyDouble("genxml/hidden/index"))
                    {
                        info.SetXmlProperty("genxml/hidden/index", (infoTo.GetXmlPropertyDouble("genxml/hidden/index") - 0.5).ToString("00.0"), TypeCode.Double);
                    }
                    else
                    {
                        info.SetXmlProperty("genxml/hidden/index", (infoTo.GetXmlPropertyDouble("genxml/hidden/index") + 0.5).ToString("00.0"), TypeCode.Double);
                    }
                    objCtrl.Update(info);

                    // remove save GetData cache so we read changed data
                    DataCache.ClearCache();

                    PluginUtils.ResequenceRecords();

                    // remove save GetData cache
                    DataCache.ClearCache();
                }
            }
        }
Beispiel #2
0
        public IEncodedString QtyPromoDescription(int productId, string qtypromoref = "")
        {
            var qtydescritpion = "";
            var objCtrl        = new NBrightBuyController();
            var prodData       = new ProductData(productId, Utils.GetCurrentCulture());

            if (qtypromoref != "")
            {
                var qtypromo = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -2, "QTYPROMO", qtypromoref);
                if (bulkBuyOn(prodData, qtypromo))
                {
                    var qtyInfo = objCtrl.GetData(qtypromo.ItemID, "QTYPROMOLANG", Utils.GetCurrentCulture());
                    qtydescritpion = qtyInfo.GetXmlProperty("genxml/lang/genxml/textbox/description");
                }
            }
            else
            {
                var qtypromolist = objCtrl.GetList(PortalSettings.Current.PortalId, -2, "QTYPROMO");
                foreach (var q in qtypromolist)
                {
                    if (bulkBuyOn(prodData, q))
                    {
                        var qtyInfo = objCtrl.GetData(q.ItemID, "QTYPROMOLANG", Utils.GetCurrentCulture());
                        qtydescritpion = qtyInfo.GetXmlProperty("genxml/lang/genxml/textbox/description");
                        break;
                    }
                }
            }

            return(new RawString(qtydescritpion));
        }
Beispiel #3
0
        public static string RemoveGroupProductPromo(int portalId, int promoid)
        {
            var objCtrl = new NBrightBuyController();
            var p       = objCtrl.GetData(promoid);

            var typeselect  = p.GetXmlProperty("genxml/radiobuttonlist/typeselect");
            var catgroupid  = p.GetXmlProperty("genxml/dropdownlist/catgroupid");
            var propgroupid = p.GetXmlProperty("genxml/dropdownlist/propgroupid");

            CategoryData gCat;
            var          groupid = catgroupid;

            if (typeselect != "cat")
            {
                groupid = propgroupid;
            }

            gCat = CategoryUtils.GetCategoryData(groupid, Utils.GetCurrentCulture());
            if (gCat.Exists)
            {
                var prdList = gCat.GetAllArticles();

                foreach (var prd in prdList)
                {
                    // END Promo
                    RemoveProductPromoData(portalId, prd.ParentItemId, p.ItemID);
                    ProductUtils.RemoveProductDataCache(prd.PortalId, prd.ParentItemId);
                }
            }
            return("OK");
        }
Beispiel #4
0
        private static void EndProductSalePrice(int portalId, int productId, int promoid)
        {
            var objCtrl = new NBrightBuyController();
            var prdData = objCtrl.GetData(productId);

            var nodList = prdData.XMLDoc.SelectNodes("genxml/models/genxml");

            if (nodList != null)
            {
                var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid");
                if (currentpromoid == promoid)
                {
                    var portalsettings = NBrightDNN.DnnUtils.GetPortalSettings(portalId);
                    var lang           = portalsettings.DefaultLanguage;

                    var lp = 1;
                    foreach (XmlNode nod in nodList)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", 0);
                        lp += 1;
                    }
                    objCtrl.Update(prdData);
                    RemoveProductPromoData(portalId, productId, promoid);
                    var productData = ProductUtils.GetProductData(productId, lang);
                    productData.Save(); // recalc any new prices.
                }
            }
        }
Beispiel #5
0
        public String CategoryAdminDetail(HttpContext context, int catid, string editLangCurrent)
        {
            try
            {
                if (NBrightBuyUtils.CheckManagerRights())
                {
                    EditLangCurrent = editLangCurrent;
                    var ajaxInfo       = NBrightBuyUtils.GetAjaxInfo(context);
                    var strOut         = "";
                    var selecteditemid = ajaxInfo.GetXmlPropertyInt("genxml/hidden/selectedcatid");
                    if (catid > 0)
                    {
                        selecteditemid = catid;
                    }
                    if (Utils.IsNumeric(selecteditemid))
                    {
                        var themeFolder   = ajaxInfo.GetXmlProperty("genxml/hidden/themefolder");
                        var razortemplate = ajaxInfo.GetXmlProperty("genxml/hidden/razortemplate");
                        var portalId      = PortalSettings.Current.PortalId;

                        var passSettings = ajaxInfo.ToDictionary();
                        foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement
                        {
                            if (passSettings.ContainsKey(s.Key))
                            {
                                passSettings[s.Key] = s.Value;
                            }
                            else
                            {
                                passSettings.Add(s.Key, s.Value);
                            }
                        }

                        if (selecteditemid <= 0)
                        {
                            return("");
                        }

                        if (themeFolder == "")
                        {
                            themeFolder = StoreSettings.Current.ThemeFolder;
                        }

                        var objCtrl = new NBrightBuyController();
                        var info    = objCtrl.GetData(Convert.ToInt32(selecteditemid), EntityTypeCode + "LANG", EditLangCurrent, true);

                        strOut = NBrightBuyUtils.RazorTemplRender(razortemplate, 0, "", info, TemplateRelPath, themeFolder, Utils.GetCurrentCulture(), passSettings);
                    }
                    return(strOut);
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Beispiel #6
0
        public static string RemoveMultiBuyProductPromo(int portalId, int promoid)
        {
            var objCtrl = new NBrightBuyController();
            var p       = objCtrl.GetData(promoid);

            var propgroupid      = p.GetXmlPropertyInt("genxml/dropdownlist/propbuy");
            var propapplygroupid = p.GetXmlPropertyInt("genxml/dropdownlist/propapply");

            var portalsettings = NBrightDNN.DnnUtils.GetPortalSettings(p.PortalId);
            var lang           = portalsettings.DefaultLanguage;


            var gCat = CategoryUtils.GetCategoryData(propgroupid, lang);

            if (gCat.Exists)
            {
                var prdList = gCat.GetAllArticles();

                foreach (var prd in prdList)
                {
                    // END Promo
                    RemoveProductPromoData(portalId, prd.ParentItemId, promoid);
                    ProductUtils.RemoveProductDataCache(prd.PortalId, prd.ParentItemId);
                    var productData = ProductUtils.GetProductData(prd.ParentItemId, lang);
                    productData.Save(); // recalc any new prices.
                }
            }

            if (propapplygroupid != propgroupid && propapplygroupid > 0)
            {
                gCat = CategoryUtils.GetCategoryData(propapplygroupid, lang);
                if (gCat.Exists)
                {
                    var prdList2 = gCat.GetAllArticles();

                    foreach (var prd in prdList2)
                    {
                        // END Promo
                        RemoveProductPromoData(p.PortalId, prd.ParentItemId, p.ItemID);
                        ProductUtils.RemoveProductDataCache(p.PortalId, prd.ParentItemId);
                        var productData = ProductUtils.GetProductData(prd.ParentItemId, lang);
                        productData.Save(); // recalc any new prices.
                    }
                }
            }

            return("OK");
        }
Beispiel #7
0
        public static string RemoveGroupProductPromo(int portalId, int promoid)
        {
            var objCtrl = new NBrightBuyController();
            var p       = objCtrl.GetData(promoid);

            var typeselect  = p.GetXmlProperty("genxml/radiobuttonlist/typeselect");
            var catgroupid  = p.GetXmlProperty("genxml/dropdownlist/catgroupid");
            var propgroupid = p.GetXmlProperty("genxml/dropdownlist/propgroupid");

            var portalsettings = NBrightDNN.DnnUtils.GetPortalSettings(p.PortalId);
            var lang           = portalsettings.DefaultLanguage;

            var prdList = new List <NBrightInfo>();

            if (typeselect == "all")
            {
                prdList = objCtrl.GetList(p.PortalId, -1, "PRD");
            }
            else
            {
                CategoryData gCat;
                var          groupid = catgroupid;
                if (typeselect != "cat")
                {
                    groupid = propgroupid;
                }
                gCat = CategoryUtils.GetCategoryData(groupid, lang);
                if (gCat != null)
                {
                    prdList = gCat.GetAllArticles();
                }
            }
            foreach (var prd in prdList)
            {
                var productid = prd.ParentItemId;
                if (typeselect == "all")
                {
                    productid = prd.ItemID;
                }

                // END Promo
                RemoveProductPromoData(portalId, productid, p.ItemID);
                ProductUtils.RemoveProductDataCache(prd.PortalId, productid);
                var productData = ProductUtils.GetProductData(productid, lang);
                productData.Save(); // recalc any new prices.
            }
            return("OK");
        }
Beispiel #8
0
        public override NBrightInfo AfterProductSave(NBrightInfo nbrightInfo)
        {
            var promoid = nbrightInfo.GetXmlPropertyInt("genxml/hidden/promoid");

            if (promoid > 0)
            {
                var prdData   = ProductUtils.GetProductData(nbrightInfo.ItemID, nbrightInfo.Lang);
                var objCtrl   = new NBrightBuyController();
                var promoData = objCtrl.GetData(promoid);

                var catgroupid       = promoData.GetXmlPropertyInt("genxml/dropdownlist/catgroupid");
                var propgroupid      = promoData.GetXmlPropertyInt("genxml/dropdownlist/propgroupid");
                var propbuygroupid   = promoData.GetXmlPropertyInt("genxml/dropdownlist/propbuy");
                var propapplygroupid = promoData.GetXmlPropertyInt("genxml/dropdownlist/propapply");

                var removepromo = true;
                foreach (var c in prdData.GetCategories())
                {
                    if (c.categoryid == catgroupid)
                    {
                        removepromo = false;
                    }
                    if (c.categoryid == propgroupid)
                    {
                        removepromo = false;
                    }
                    if (c.categoryid == propbuygroupid)
                    {
                        removepromo = false;
                    }
                    if (c.categoryid == propapplygroupid)
                    {
                        removepromo = false;
                    }
                }

                if (removepromo)
                {
                    PromoUtils.RemoveProductPromoData(nbrightInfo.PortalId, nbrightInfo.ItemID, promoid);
                    ProductUtils.RemoveProductDataCache(nbrightInfo.PortalId, nbrightInfo.ItemID);
                }
            }

            return(nbrightInfo);
        }
        public static void PluginSave(HttpContext context)
        {
            if (NBrightBuyUtils.CheckRights())
            {
                var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
                var itemid   = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");
                if (Utils.IsNumeric(itemid))
                {
                    var objCtrl      = new NBrightBuyController();
                    var info         = objCtrl.GetData(Convert.ToInt32(itemid));
                    var pluginRecord = new PluginRecord(info);
                    var modelXml     = Utils.UnCode(ajaxInfo.GetXmlProperty("genxml/hidden/xmlupdatemodeldata"));

                    ajaxInfo.RemoveXmlNode("genxml/hidden/xmlupdatemodeldata");
                    pluginRecord.Info().XMLData = ajaxInfo.XMLData;

                    // check for unique ctrl ref
                    var ctrlref  = pluginRecord.Info().GetXmlProperty("genxml/textbox/ctrl");
                    var ctrltest = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PLUGIN", ctrlref);
                    if (ctrltest != null)
                    {
                        if (ctrltest.ItemID != pluginRecord.Info().ItemID)
                        {
                            pluginRecord.Info().SetXmlProperty("genxml/textbox/ctrl", pluginRecord.Info().GetXmlProperty("genxml/textbox/ctrl") + Utils.GetUniqueKey());
                        }
                    }

                    // make sure index is in correct format, (FLOAT) for SQL
                    pluginRecord.Info().SetXmlProperty("genxml/hidden/index", (pluginRecord.Info().GetXmlPropertyInt("genxml/hidden/index").ToString()), TypeCode.Double);
                    pluginRecord.Info().RemoveXmlNode("genxml/hidden/itemid");
                    pluginRecord.Info().RemoveXmlNode("genxml/hidden/editlanguage");
                    pluginRecord.Info().RemoveXmlNode("genxml/hidden/uilang1");
                    pluginRecord.Info().GUIDKey = pluginRecord.Info().GetXmlProperty("genxml/textbox/ctrl");

                    pluginRecord.UpdateModels(modelXml, Utils.GetCurrentCulture());
                    objCtrl.Update(pluginRecord.Info());

                    // remove save GetData cache
                    DataCache.ClearCache();

                    //load entity typecode to DB idx settings.
                    NBrightBuyUtils.RegisterEnityTypeToDataBase();
                }
            }
        }
Beispiel #10
0
        public String CategoryGroupFilters(HttpContext context, string editLangCurrent)
        {
            try
            {
                if (NBrightBuyUtils.CheckManagerRights())
                {
                    EditLangCurrent = editLangCurrent;
                    var ajaxInfo = NBrightBuyUtils.GetAjaxInfo(context);
                    var strOut   = "";
                    var catid    = ajaxInfo.GetXmlPropertyInt("genxml/hidden/selectedcatid");
                    if (catid > 0)
                    {
                        var themeFolder   = "config";
                        var razortemplate = "Admin_CategoryFilterGroups.cshtml";

                        var passSettings = ajaxInfo.ToDictionary();
                        foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement
                        {
                            if (passSettings.ContainsKey(s.Key))
                            {
                                passSettings[s.Key] = s.Value;
                            }
                            else
                            {
                                passSettings.Add(s.Key, s.Value);
                            }
                        }

                        var objCtrl = new NBrightBuyController();
                        var info    = objCtrl.GetData(catid, EntityTypeCode + "LANG", EditLangCurrent, true);

                        strOut = NBrightBuyUtils.RazorTemplRender(razortemplate, 0, "", info, TemplateRelPath, themeFolder, Utils.GetCurrentCulture(), passSettings);
                    }
                    return(strOut);
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
        private String GetData(HttpContext context, bool clearCache = false)
        {
            var objCtrl = new NBrightBuyController();
            var strOut  = "";
            //get uploaded params
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);

            var guidkey  = ajaxInfo.GetXmlProperty("genxml/hidden/guidkey");
            var typeCode = ajaxInfo.GetXmlProperty("genxml/hidden/typecode");
            var moduleid = ajaxInfo.GetXmlProperty("genxml/hidden/moduleid");
            var editlang = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");

            if (editlang == "")
            {
                editlang = _lang;
            }

            if (!Utils.IsNumeric(moduleid))
            {
                moduleid = "-2";                             // use moduleid -2 for razor
            }
            if (clearCache)
            {
                NBrightBuyUtils.RemoveModCache(Convert.ToInt32(moduleid));
            }

            var templateControl = "/DesktopModules/NBright/NBrightBuyOpenUrlRewriter";

            // get data record with language
            var obj = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, Convert.ToInt32(moduleid), typeCode, guidkey);

            if (obj == null)
            {
                var itemId = AddNew(moduleid, typeCode);
                obj = objCtrl.Get(itemId);
            }
            var objData = objCtrl.GetData(obj.ItemID, typeCode + "LANG", editlang);

            //strOut = NBrightBuyUtils.RazorTemplRender(typeCode.ToLower() + "fields.cshtml", Convert.ToInt32(moduleid), _lang + guidkey + editlang, objData, templateControl, "config", editlang, StoreSettings.Current.Settings());

            return(strOut);
        }
Beispiel #12
0
        public static void RemoveProductPromoData(int portalid, int productId, int promoid)
        {
            var cultureList = DnnUtils.GetCultureCodeList(portalid);
            var objCtrl     = new NBrightBuyController();
            var prdData     = objCtrl.GetData(productId);

            var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid");

            if (currentpromoid == promoid)
            {
                prdData.RemoveXmlNode("genxml/hidden/promotype");
                prdData.RemoveXmlNode("genxml/hidden/promoname");
                prdData.RemoveXmlNode("genxml/hidden/promoid");
                prdData.RemoveXmlNode("genxml/hidden/promocalcdate");
                prdData.RemoveXmlNode("genxml/hidden/datefrom");
                prdData.RemoveXmlNode("genxml/hidden/dateuntil");

                // remove any sale price amounts that may have been added by group promotion.
                var l = prdData.XMLDoc.SelectNodes("genxml/models/genxml");
                if (l != null)
                {
                    var lp = 1;
                    foreach (XmlNode nod in l)
                    {
                        prdData.SetXmlProperty("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", "0");
                        lp += 1;
                    }
                }

                objCtrl.Update(prdData);
                foreach (var lang in cultureList)
                {
                    var prdDataLang = objCtrl.GetDataLang(productId, lang);
                    if (prdDataLang != null)
                    {
                        prdDataLang.RemoveXmlNode("genxml/hidden/promodesc");
                        objCtrl.Update(prdDataLang);
                    }
                }
            }
        }
Beispiel #13
0
        public static string RemoveMultiBuyProductPromo(int portalId, int promoid)
        {
            var objCtrl = new NBrightBuyController();
            var p       = objCtrl.GetData(promoid);

            var propgroupid      = p.GetXmlPropertyInt("genxml/dropdownlist/propbuy");
            var propapplygroupid = p.GetXmlPropertyInt("genxml/dropdownlist/propapply");

            var gCat = CategoryUtils.GetCategoryData(propgroupid, Utils.GetCurrentCulture());

            if (gCat.Exists)
            {
                var prdList = gCat.GetAllArticles();

                foreach (var prd in prdList)
                {
                    // END Promo
                    RemoveProductPromoData(portalId, prd.ParentItemId, promoid);
                    ProductUtils.RemoveProductDataCache(prd.PortalId, prd.ParentItemId);
                }
            }

            if (propapplygroupid != propgroupid && propapplygroupid > 0)
            {
                gCat = CategoryUtils.GetCategoryData(propapplygroupid, Utils.GetCurrentCulture());
                if (gCat.Exists)
                {
                    var prdList2 = gCat.GetAllArticles();

                    foreach (var prd in prdList2)
                    {
                        // END Promo
                        RemoveProductPromoData(p.PortalId, prd.ParentItemId, p.ItemID);
                        ProductUtils.RemoveProductDataCache(p.PortalId, prd.ParentItemId);
                    }
                }
            }

            return("OK");
        }
 public static void PluginAddInterface(HttpContext context)
 {
     try
     {
         if (NBrightBuyUtils.CheckRights())
         {
             var ajaxInfo       = NBrightBuyUtils.GetAjaxInfo(context);
             var selecteditemid = ajaxInfo.GetXmlProperty("genxml/hidden/selecteditemid");
             if (Utils.IsNumeric(selecteditemid))
             {
                 var objCtrl      = new NBrightBuyController();
                 var info         = objCtrl.GetData(Convert.ToInt32(selecteditemid));
                 var pluginRecord = new PluginRecord(info);
                 pluginRecord.AddInterface();
             }
         }
     }
     catch (Exception ex)
     {
         // ignore
     }
 }
Beispiel #15
0
        private static void EndProductSalePrice(int portalId, int productId, int promoid)
        {
            var objCtrl = new NBrightBuyController();
            var prdData = objCtrl.GetData(productId);

            var nodList = prdData.XMLDoc.SelectNodes("genxml/models/genxml");

            if (nodList != null)
            {
                var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid");
                if (currentpromoid == promoid)
                {
                    var lp = 1;
                    foreach (XmlNode nod in nodList)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", 0);
                        lp += 1;
                    }
                    objCtrl.Update(prdData);
                    RemoveProductPromoData(portalId, productId, promoid);
                }
            }
        }
Beispiel #16
0
        private static void FlagProductMultiBuy(int portalid, int productId, string promoname, int promoid, String promoType, DateTime dteF, DateTime dteU)
        {
            var cultureList = DnnUtils.GetCultureCodeList(portalid);
            var objCtrl     = new NBrightBuyController();
            var prdData     = objCtrl.GetData(productId);

            var nodList = prdData.XMLDoc.SelectNodes("genxml/models/genxml");

            if (nodList != null)
            {
                var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid");
                if (currentpromoid == 0 || currentpromoid == promoid)
                {
                    prdData.SetXmlProperty("genxml/hidden/promotype", promoType);
                    prdData.SetXmlProperty("genxml/hidden/promoname", promoname);
                    prdData.SetXmlProperty("genxml/hidden/promoid", promoid.ToString());
                    prdData.SetXmlProperty("genxml/hidden/promocalcdate", DateTime.Now.ToString("O"));
                    prdData.SetXmlProperty("genxml/hidden/datefrom", dteF.ToString("O"));
                    prdData.SetXmlProperty("genxml/hidden/dateuntil", dteU.ToString("O"));

                    objCtrl.Update(prdData);
                    if (promoType == "PROMOMULTIBUY")
                    {
                        foreach (var lang in cultureList)
                        {
                            var p           = objCtrl.GetDataLang(promoid, lang);
                            var prdDataLang = objCtrl.GetDataLang(productId, lang);
                            if (prdDataLang != null)
                            {
                                prdDataLang.SetXmlProperty("genxml/hidden/promodesc", p.GetXmlProperty("genxml/textbox/description"));
                                objCtrl.Update(prdDataLang);
                            }
                        }
                    }
                }
            }
        }
        public static String PluginAdminDetail(HttpContext context)
        {
            try
            {
                if (NBrightBuyUtils.CheckRights())
                {
                    var ajaxInfo = NBrightBuyUtils.GetAjaxInfo(context);

                    var strOut         = "";
                    var selecteditemid = ajaxInfo.GetXmlProperty("genxml/hidden/selecteditemid");
                    if (Utils.IsNumeric(selecteditemid))
                    {
                        var themeFolder = ajaxInfo.GetXmlProperty("genxml/hidden/themefolder");
                        if (themeFolder == "")
                        {
                            themeFolder = "config";
                        }
                        var razortemplate = ajaxInfo.GetXmlProperty("genxml/hidden/razortemplate");

                        var passSettings = NBrightBuyUtils.GetPassSettings(ajaxInfo);

                        var objCtrl      = new NBrightBuyController();
                        var info         = objCtrl.GetData(Convert.ToInt32(selecteditemid));
                        var pluginRecord = new PluginRecord(info);

                        strOut = NBrightBuyUtils.RazorTemplRender(razortemplate, 0, "", pluginRecord, TemplateRelPath, themeFolder, Utils.GetCurrentCulture(), passSettings);
                    }
                    return(strOut);
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Beispiel #18
0
        private static void CalcProductSalePrice(int portalid, int productId, string amounttype, double amount, string promoname, int promoid, bool overwrite, DateTime dteF, DateTime dteU)
        {
            var cultureList = DnnUtils.GetCultureCodeList(portalid);
            var objCtrl     = new NBrightBuyController();
            var prdData     = objCtrl.GetData(productId);

            var nodList = prdData.XMLDoc.SelectNodes("genxml/models/genxml");

            if (nodList != null)
            {
                var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid");
                if (currentpromoid == 0 || currentpromoid == promoid || overwrite)
                {
                    prdData.SetXmlProperty("genxml/hidden/promotype", "PROMOGROUP");
                    prdData.SetXmlPropertyDouble("genxml/hidden/promoname", promoname);
                    prdData.SetXmlProperty("genxml/hidden/promoid", promoid.ToString());
                    prdData.SetXmlProperty("genxml/hidden/promocalcdate", DateTime.Now.ToString("O"));
                    prdData.SetXmlProperty("genxml/hidden/datefrom", dteF.ToString("O"));
                    prdData.SetXmlProperty("genxml/hidden/dateuntil", dteU.ToString("O"));

                    var lp = 1;
                    foreach (XmlNode nod in nodList)
                    {
                        var nbi = new NBrightInfo();
                        nbi.XMLData = nod.OuterXml;
                        var    unitcost = nbi.GetXmlPropertyDouble("genxml/textbox/txtunitcost");
                        Double newamt   = 0;
                        if (amounttype == "1")
                        {
                            newamt = unitcost - amount;
                        }
                        else
                        {
                            newamt = unitcost - ((unitcost / 100) * amount);
                        }

                        if (newamt < 0)
                        {
                            newamt = 0;
                        }

                        var currentprice = prdData.GetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice");

                        if (!overwrite)
                        {
                            if (currentprice == 0)
                            {
                                overwrite = true;
                            }
                            if (currentpromoid == promoid)
                            {
                                overwrite = true;
                            }
                        }
                        if (overwrite)
                        {
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", newamt);
                        }
                        lp += 1;
                    }
                    objCtrl.Update(prdData);

                    foreach (var lang in cultureList)
                    {
                        var p           = objCtrl.GetDataLang(promoid, lang);
                        var prdDataLang = objCtrl.GetDataLang(productId, lang);
                        if (prdDataLang != null)
                        {
                            prdDataLang.SetXmlProperty("genxml/hidden/promodesc", p.GetXmlProperty("genxml/textbox/description"));
                            objCtrl.Update(prdDataLang);
                        }
                    }
                }
            }
        }
Beispiel #19
0
        public static void RemoveProductPromoData(int portalid, int productId, int promoid)
        {
            var cultureList = DnnUtils.GetCultureCodeList(portalid);
            var objCtrl     = new NBrightBuyController();
            var prdData     = objCtrl.GetData(productId);

            // (legacy) remove fields for old promo
            var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid");

            if (currentpromoid != 0) //
            {
                prdData.RemoveXmlNode("genxml/hidden/promotype");
                prdData.RemoveXmlNode("genxml/hidden/promoname");
                prdData.RemoveXmlNode("genxml/hidden/promoid");
                prdData.RemoveXmlNode("genxml/hidden/promocalcdate");
                prdData.RemoveXmlNode("genxml/hidden/datefrom");
                prdData.RemoveXmlNode("genxml/hidden/dateuntil");
            }

            // remove any sale price amounts that may have been added by group promotion.
            var l = prdData.XMLDoc.SelectNodes("genxml/models/genxml");

            if (l != null)
            {
                var promoexist = false;
                var lp         = 1;
                foreach (XmlNode nod in l)
                {
                    var promodealersaleid = prdData.GetXmlPropertyInt("genxml/promo/dealersaleid" + lp);
                    var promosalepriceid  = prdData.GetXmlPropertyInt("genxml/promo/salepriceid" + lp);
                    var promodealercostid = prdData.GetXmlPropertyInt("genxml/promo/dealercostid" + lp);

                    if (promosalepriceid == promoid)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", "0");
                        prdData.RemoveXmlNode("genxml/promo/salepriceid" + lp);
                        promosalepriceid = 0;
                    }
                    if (promodealercostid == promoid)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealercost", "0");
                        prdData.RemoveXmlNode("genxml/promo/dealercostid" + lp);
                        promodealercostid = 0;
                    }
                    if (promodealersaleid == promoid)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealersale", "0");
                        prdData.RemoveXmlNode("genxml/promo/dealersaleid" + lp);
                        promodealersaleid = 0;
                    }

                    if (promodealersaleid > 0 || promosalepriceid > 0 || promodealercostid > 0)
                    {
                        promoexist = true;
                    }

                    lp += 1;
                }

                if (!promoexist)
                {
                    prdData.RemoveXmlNode("genxml/hidden/promoflag");
                    prdData.RemoveXmlNode("genxml/promo");
                }

                // promo description only at product level, thi sis not correct for multiple price promoiton.
                // but this is a rare use case issue.
                foreach (var lang in cultureList)
                {
                    var prdDataLang = objCtrl.GetDataLang(productId, lang);
                    if (prdDataLang != null)
                    {
                        prdDataLang.RemoveXmlNode("genxml/hidden/promodesc");
                        objCtrl.Update(prdDataLang);
                    }
                }
            }

            objCtrl.Update(prdData);
        }
Beispiel #20
0
        public static List <UrlRule> GetRules(int portalId)
        {
            object padlock = new object();

            lock (padlock)
            {
                List <UrlRule> rules    = new List <UrlRule>();
                List <UrlRule> catrules = new List <UrlRule>();

                #if DEBUG
                decimal speed;
                string  mess;
                var     stopwatch = new System.Diagnostics.Stopwatch();
                stopwatch.Start();
                #endif

                var purgeResult    = UrlRulesCaching.PurgeExpiredItems(portalId);
                var portalCacheKey = UrlRulesCaching.GeneratePortalCacheKey(portalId, null);
                var portalRules    = UrlRulesCaching.GetCache(portalId, portalCacheKey, purgeResult.ValidCacheItems);
                if (portalRules != null && portalRules.Count > 0)
                {
                    #if DEBUG
                    stopwatch.Stop();
                    speed = stopwatch.Elapsed.Milliseconds;
                    mess  = $"PortalId: {portalId}. Time elapsed: {stopwatch.Elapsed.Milliseconds}ms. All Cached. PurgedItems: {purgeResult.PurgedItemCount}. Speed: {speed}";
                    Logger.Error(mess);
                    #endif
                    return(portalRules);
                }

                Dictionary <string, Locale> dicLocales = LocaleController.Instance.GetLocales(portalId);

                var objCtrl = new NBrightBuyController();

                var storesettings = new StoreSettings(portalId);

                ModuleController mc  = new ModuleController();
                var modules          = mc.GetModulesByDefinition(portalId, "NBS_ProductDisplay").OfType <ModuleInfo>();
                var modulesOldModule = mc.GetModulesByDefinition(portalId, "NBS_ProductView").OfType <ModuleInfo>();
                modules = modules.Concat(modulesOldModule);

                // ------- Category URL ---------------

                #region "Category Url"

                // Not using the module loop!!
                // becuase tabs that are defined in the url are dealt with by open url rewriter, so we only need use the default tab which is defined by the store settings.

                foreach (KeyValuePair <string, Locale> key in dicLocales)
                {
                    try
                    {
                        string cultureCode     = key.Value.Code;
                        string ruleCultureCode = (dicLocales.Count > 1 ? cultureCode : null);

                        var grpCatCtrl = new GrpCatController(cultureCode, portalId);

                        // get all products in portal, with lang data
                        var catitems = objCtrl.GetList(portalId, -1, "CATEGORY");

                        foreach (var catData in catitems)
                        {
                            var catDataLang = objCtrl.GetDataLang(catData.ItemID, cultureCode);

                            if (catDataLang != null && !catData.GetXmlPropertyBool("genxml/checkbox/chkishidden"))
                            {
                                var            catCacheKey   = portalCacheKey + "_" + catDataLang.ItemID + "_" + cultureCode;
                                List <UrlRule> categoryRules = UrlRulesCaching.GetCache(portalId, catCacheKey, purgeResult.ValidCacheItems);
                                if (categoryRules != null && categoryRules.Count > 0)
                                {
                                    rules.AddRange(categoryRules);
                                }
                                else
                                {
                                    catrules = new List <UrlRule>();

                                    var caturlname   = catDataLang.GUIDKey;
                                    var SEOName      = catDataLang.GetXmlProperty("genxml/textbox/txtseoname");
                                    var categoryName = catDataLang.GetXmlProperty("genxml/textbox/txtcategoryname");

                                    var newcatUrl = grpCatCtrl.GetBreadCrumb(catData.ItemID, 0, "/", false);

                                    var url = newcatUrl;
                                    if (!string.IsNullOrEmpty(url))
                                    {
                                        // ------- Category URL ---------------

                                        var rule = new UrlRule
                                        {
                                            CultureCode = ruleCultureCode,
                                            TabId       = storesettings.ProductListTabId,
                                            Parameters  = "catref=" + caturlname,
                                            Url         = url
                                        };
                                        var reducedRules =
                                            rules.Where(r => r.CultureCode == rule.CultureCode && r.TabId == rule.TabId)
                                            .ToList();
                                        bool ruleExist = reducedRules.Any(r => r.Parameters == rule.Parameters);
                                        if (!ruleExist)
                                        {
                                            if (reducedRules.Any(r => r.Url == rule.Url)) // if duplicate url
                                            {
                                                rule.Url = catData.ItemID + "-" + url;
                                            }
                                            rules.Add(rule);
                                            catrules.Add(rule);
                                        }

                                        var proditems = objCtrl.GetList(catData.PortalId, -1, "CATXREF", " and NB1.XRefItemId = " + catData.ItemID.ToString(""));
                                        var l2        = objCtrl.GetList(catData.PortalId, -1, "CATCASCADE", " and NB1.XRefItemId = " + catData.ItemID.ToString(""));
                                        proditems.AddRange(l2);

                                        var pageurl  = "";
                                        var pageurl1 = rule.Url;
                                        // do paging for category (on all product modules.)
                                        foreach (var module in modules)
                                        {
                                            // ------- Paging URL ---------------
                                            var modsetting        = NBrightBuyUtils.GetSettings(portalId, module.ModuleID);
                                            var pagesize          = modsetting.GetXmlPropertyInt("genxml/textbox/pagesize");
                                            var staticlist        = modsetting.GetXmlPropertyBool("genxml/checkbox/staticlist");
                                            var defaultcatid      = modsetting.GetXmlPropertyBool("genxml/dropdownlist/defaultpropertyid");
                                            var defaultpropertyid = modsetting.GetXmlPropertyBool("genxml/dropdownlist/defaultcatid");
                                            if (pagesize > 0)
                                            {
                                                if (module.TabID != storesettings.ProductListTabId || staticlist)
                                                {
                                                    // on the non-default product list tab, add the moduleid, so we dont; get duplicates.
                                                    // NOTE: this only supports defaut paging url for 1 module on the defaut product list page. Other modules will have moduleid added to the url.

                                                    //pageurl = module.ModuleID + "-" + pageurl1;

                                                    //IGNORE NON DEFAULT MODULES.
                                                }
                                                else
                                                {
                                                    pageurl = pageurl1;


                                                    var pagetotal = Convert.ToInt32((proditems.Count / pagesize) + 1);
                                                    for (int i = 1; i <= pagetotal; i++)
                                                    {
                                                        rule = new UrlRule
                                                        {
                                                            CultureCode = ruleCultureCode,
                                                            TabId       = module.TabID,
                                                            Parameters  = "catref=" + caturlname + "&page=" + i + "&pagemid=" + module.ModuleID,
                                                            Url         = pageurl + "-" + i
                                                        };
                                                        ruleExist = reducedRules.Any(r => r.Parameters == rule.Parameters);
                                                        if (!ruleExist)
                                                        {
                                                            if (reducedRules.Any(r => r.Url == rule.Url)) // if duplicate url
                                                            {
                                                                rule.Url = module.ModuleID + "-" + rule.Url;
                                                            }
                                                            rules.Add(rule);
                                                            catrules.Add(rule);
                                                        }
                                                    }
                                                }
                                            }
                                        }

                                        // ------- Product URL ---------------
                                        foreach (var xrefData in proditems)
                                        {
                                            //var product = new ProductData(xrefData.ParentItemId, cultureCode, false);
                                            var prdData = objCtrl.GetData(xrefData.ParentItemId, cultureCode);

                                            var pref = prdData.GetXmlProperty("genxml/textbox/txtproductref");

                                            string produrl = prdData.GetXmlProperty("genxml/lang/genxml/textbox/txtseoname");
                                            ;
                                            if (string.IsNullOrEmpty(produrl))
                                            {
                                                produrl = prdData.GetXmlProperty("genxml/lang/genxml/textbox/txtproductname");
                                            }
                                            if (string.IsNullOrEmpty(produrl))
                                            {
                                                produrl = pref;
                                            }
                                            if (string.IsNullOrEmpty(produrl))
                                            {
                                                produrl = prdData.ItemID.ToString("");
                                            }
                                            //if (catref != "") produrl = catref + "-" + produrl;
                                            //if (catref != "") produrl = catref + "-" + produrl;
                                            produrl = newcatUrl + "/" + Utils.UrlFriendly(produrl);
                                            var prodrule = new UrlRule
                                            {
                                                CultureCode = ruleCultureCode,
                                                TabId       = storesettings.ProductDetailTabId,
                                                Parameters  = "catref=" + catDataLang.GUIDKey + "&ref=" + prdData.GUIDKey,
                                                Url         = produrl
                                            };
                                            reducedRules =
                                                rules.Where(
                                                    r => r.CultureCode == prodrule.CultureCode && r.TabId == prodrule.TabId)
                                                .ToList();
                                            ruleExist = reducedRules.Any(r => r.Parameters == prodrule.Parameters);
                                            if (!ruleExist)
                                            {
                                                if (reducedRules.Any(r => r.Url == prodrule.Url)) // if duplicate url
                                                {
                                                    prodrule.Url = prdData.ItemID + "-" + produrl;
                                                }
                                                rules.Add(prodrule);
                                                catrules.Add(prodrule);
                                            }
                                        }
                                    }
                                    UrlRulesCaching.SetCache(portalId, catCacheKey, new TimeSpan(1, 0, 0, 0), catrules);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Failed to generate url for module NBS", ex);
                    }
                }

                #endregion


                UrlRulesCaching.SetCache(portalId, portalCacheKey, new TimeSpan(1, 0, 0, 0), rules);


                #if DEBUG
                stopwatch.Stop();
                mess = $"PortalId: {portalId}. Time elapsed: {stopwatch.Elapsed.Milliseconds}ms. Module Count: {modules.Count()}. PurgedItems: {purgeResult.PurgedItemCount}";
                Logger.Error(mess);
                Console.WriteLine(mess);
                #endif


                return(rules);
            }
        }
Beispiel #21
0
        public override NBrightInfo AfterProductSave(NBrightInfo nbrightInfo)
        {
            var promoid = nbrightInfo.GetXmlPropertyInt("genxml/hidden/promoid"); // legacy promo flag

            if (nbrightInfo.GetXmlPropertyBool("genxml/hidden/promoflag") || promoid > 0)
            {
                var prdData = ProductUtils.GetProductData(nbrightInfo.ItemID, nbrightInfo.Lang);
                // loop on models to get all promoid at model level.
                var modelpromoids = new List <int>();
                if (promoid > 0)
                {
                    modelpromoids.Add(promoid);
                }
                var lp = 1;
                foreach (var m in prdData.Models)
                {
                    var modelPromoId = prdData.Info.GetXmlPropertyInt("genxml/promo/salepriceid" + lp);
                    if (modelPromoId > 0 && !modelpromoids.Contains(modelPromoId))
                    {
                        modelpromoids.Add(modelPromoId);
                    }
                    modelPromoId = prdData.Info.GetXmlPropertyInt("genxml/promo/dealercostid" + lp);
                    if (modelPromoId > 0 && !modelpromoids.Contains(modelPromoId))
                    {
                        modelpromoids.Add(modelPromoId);
                    }
                    modelPromoId = prdData.Info.GetXmlPropertyInt("genxml/promo/dealersaleid" + lp);
                    if (modelPromoId > 0 && !modelpromoids.Contains(modelPromoId))
                    {
                        modelpromoids.Add(modelPromoId);
                    }
                    lp += 1;
                }

                // multiple promotions, remove from each model.
                foreach (var mpid in modelpromoids)
                {
                    var objCtrl   = new NBrightBuyController();
                    var promoData = objCtrl.GetData(mpid);

                    var catgroupid       = promoData.GetXmlPropertyInt("genxml/dropdownlist/catgroupid");
                    var propgroupid      = promoData.GetXmlPropertyInt("genxml/dropdownlist/propgroupid");
                    var propbuygroupid   = promoData.GetXmlPropertyInt("genxml/dropdownlist/propbuy");
                    var propapplygroupid = promoData.GetXmlPropertyInt("genxml/dropdownlist/propapply");

                    var removepromo = true;
                    foreach (var c in prdData.GetCategories())
                    {
                        if (c.categoryid == catgroupid)
                        {
                            removepromo = false;
                        }
                        if (c.categoryid == propgroupid)
                        {
                            removepromo = false;
                        }
                        if (c.categoryid == propbuygroupid)
                        {
                            removepromo = false;
                        }
                        if (c.categoryid == propapplygroupid)
                        {
                            removepromo = false;
                        }
                    }

                    if (removepromo)
                    {
                        PromoUtils.RemoveProductPromoData(nbrightInfo.PortalId, nbrightInfo.ItemID, mpid);
                        ProductUtils.RemoveProductDataCache(nbrightInfo.PortalId, nbrightInfo.ItemID);
                    }
                }
            }

            return(nbrightInfo);
        }
Beispiel #22
0
        public override NBrightInfo CalculatePromotion(int portalId, NBrightInfo cartInfo)
        {
            // loop through cart items
            var rtncartInfo = (NBrightInfo)cartInfo.Clone();

            try
            {
                var cartData = new CartData(cartInfo.PortalId);
                var cartList = cartData.GetCartItemList();

                foreach (var cartItemInfo in cartList)
                {
                    cartInfo.SetXmlPropertyDouble("genxml/items/genxml[./itemcode = '" + cartItemInfo.GetXmlProperty("genxml/itemcode") + "']/promodiscount", 0); // remove any existing discount
                    if (cartItemInfo.GetXmlProperty("genxml/productxml/genxml/hidden/promotype") == "PROMOMULTIBUY")
                    {
                        var promoid   = cartItemInfo.GetXmlPropertyInt("genxml/productxml/genxml/hidden/promoid");
                        var objCtrl   = new NBrightBuyController();
                        var promoData = objCtrl.GetData(promoid);
                        if (promoData != null)
                        {
                            //NOTE: WE nedd to process disabld promotions so they can be removed from cart

                            var buyqty           = promoData.GetXmlPropertyInt("genxml/textbox/buyqty");
                            var validfrom        = promoData.GetXmlProperty("genxml/textbox/validfrom");
                            var validuntil       = promoData.GetXmlProperty("genxml/textbox/validuntil");
                            var propbuygroupid   = promoData.GetXmlProperty("genxml/dropdownlist/propbuy");
                            var propapplygroupid = promoData.GetXmlProperty("genxml/dropdownlist/propapply");
                            var amounttype       = promoData.GetXmlProperty("genxml/radiobuttonlist/amounttype");
                            var amount           = promoData.GetXmlPropertyDouble("genxml/textbox/amount");


                            // Applied discount to this single cart item
                            if (!promoData.GetXmlPropertyBool("genxml/checkbox/disabled") && cartItemInfo.GetXmlPropertyInt("genxml/qty") >= buyqty && Utils.IsDate(validfrom) && Utils.IsDate(validuntil)) // check we have correct qty to activate promo
                            {
                                var dteF = Convert.ToDateTime(validfrom).Date;
                                var dteU = Convert.ToDateTime(validuntil).Date;
                                if (DateTime.Now.Date >= dteF && DateTime.Now.Date <= dteU)
                                {
                                    // calc discount amount

                                    var    cartqty     = cartItemInfo.GetXmlPropertyDouble("genxml/qty");
                                    var    qtycount    = cartqty;
                                    var    unitcost    = cartItemInfo.GetXmlPropertyDouble("genxml/basecost");
                                    double discountamt = 0;
                                    while (qtycount > buyqty)
                                    {
                                        if (amounttype == "1")
                                        {
                                            discountamt += (unitcost - amount);
                                        }
                                        else
                                        {
                                            discountamt += ((unitcost / 100) * amount);
                                        }
                                        if (discountamt < 0)
                                        {
                                            discountamt = 0;
                                        }

                                        qtycount = (qtycount - (buyqty + 1)); // +1 so we allow for discount 1 in basket.
                                    }

                                    cartInfo.SetXmlPropertyDouble("genxml/items/genxml[./itemcode = '" + cartItemInfo.GetXmlProperty("genxml/itemcode") + "']/promodiscount", discountamt);
                                }
                            }
                        }
                    }
                }

                return(cartInfo);
            }
            catch (Exception ex)
            {
                var x = ex.ToString();
                return(rtncartInfo);
            }
        }
Beispiel #23
0
        private static void CalcProductSalePrice(int portalid, int productId, string amounttype, double amount, int promoid, int whichprice, bool overwrite)
        {
            var cultureList = DnnUtils.GetCultureCodeList(portalid);
            var objCtrl     = new NBrightBuyController();
            var prdData     = objCtrl.GetData(productId);

            var nodList = prdData.XMLDoc.SelectNodes("genxml/models/genxml");

            if (nodList != null)
            {
                prdData.SetXmlProperty("genxml/hidden/promoflag", "True"); // set flag, so we can identify products with promo for product save event removal.
                if (prdData.GetXmlProperty("genxml/promo") == "")
                {
                    prdData.SetXmlProperty("genxml/promo", "");
                }
                var lp = 1;
                foreach (XmlNode nod in nodList)
                {
                    var currentpromoid = GetCurrentPromoId(prdData, whichprice, lp);
                    var nbi            = new NBrightInfo();
                    nbi.XMLData = nod.OuterXml;
                    var    disablesale      = nbi.GetXmlPropertyBool("genxml/checkbox/chkdisablesale");
                    var    disabledealer    = nbi.GetXmlPropertyBool("genxml/checkbox/chkdisabledealer");
                    var    unitcost         = nbi.GetXmlPropertyDouble("genxml/textbox/txtunitcost");
                    var    dealercost       = nbi.GetXmlPropertyDouble("genxml/textbox/txtdealercost");
                    Double newamt           = 0;
                    Double newdealersaleamt = 0;
                    Double newdealeramt     = 0;
                    if (amounttype == "1")
                    {
                        newamt           = unitcost - amount;
                        newdealersaleamt = dealercost - amount;
                    }
                    else
                    {
                        newamt           = unitcost - ((unitcost / 100) * amount);
                        newdealersaleamt = dealercost - ((dealercost / 100) * amount);
                    }
                    newdealeramt = newamt;
                    if (newamt < 0)
                    {
                        newamt = 0;
                    }
                    if (newdealersaleamt < 0)
                    {
                        newdealersaleamt = 0;
                    }

                    var currentprice = GetCurrentPromoPrice(prdData, whichprice, lp);
                    if (!overwrite)
                    {
                        if (currentprice == 0)
                        {
                            overwrite = true;
                        }
                        if (currentpromoid == promoid)
                        {
                            overwrite = true;
                        }
                    }
                    if (overwrite)
                    {
                        switch (whichprice)
                        {
                        case 1:
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", newamt);
                            prdData.SetXmlProperty("genxml/promo/salepriceid" + lp, promoid.ToString());
                            break;

                        case 2:
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealercost", newdealeramt);
                            prdData.SetXmlProperty("genxml/promo/dealercostid" + lp, promoid.ToString());
                            break;

                        case 3:
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealersale", newdealersaleamt);
                            prdData.SetXmlProperty("genxml/promo/dealersaleid" + lp, promoid.ToString());
                            break;

                        case 4:
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealersale", newdealersaleamt);
                            prdData.SetXmlProperty("genxml/promo/dealersaleid" + lp, promoid.ToString());
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", newamt);
                            prdData.SetXmlProperty("genxml/promo/salepriceid" + lp, promoid.ToString());
                            break;

                        default:
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", newamt);
                            prdData.SetXmlProperty("genxml/promo/salepriceid" + lp, promoid.ToString());
                            break;
                        }
                    }
                    if (disablesale)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", 0);
                        prdData.RemoveXmlNode("genxml/promo/salepriceid" + lp);
                    }
                    if (disabledealer)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealercost", 0);
                        prdData.RemoveXmlNode("genxml/promo/dealercostid" + lp);
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealersale", 0);
                        prdData.RemoveXmlNode("genxml/promo/dealersaleid" + lp);
                    }

                    lp += 1;
                }
                objCtrl.Update(prdData);

                foreach (var lang in cultureList)
                {
                    var promodesc = "";
                    var p         = objCtrl.GetDataLang(promoid, lang);
                    if (p != null)
                    {
                        promodesc = p.GetXmlProperty("genxml/textbox/description");
                    }
                    var prdDataLang = objCtrl.GetDataLang(productId, lang);
                    if (prdDataLang != null)
                    {
                        prdDataLang.SetXmlProperty("genxml/hidden/promodesc", promodesc);
                        objCtrl.Update(prdDataLang);
                    }
                }
            }
        }