Ejemplo n.º 1
0
 public override void EventAfterUpdate(System.Web.UI.WebControls.Repeater rpData, NBrightDNN.NBrightInfo objInfo)
 {
     // set page size so we pick it up in the product view.
     var navigationdata = new NavigationData(PortalId, objInfo.GetXmlProperty("genxml/textbox/modulekey"));
     navigationdata.PageSize = objInfo.GetXmlProperty("genxml/textbox/pagesize");
     navigationdata.Save();
 }
Ejemplo n.º 2
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg = e.CommandArgument.ToString();
            var param = new string[3];
            var navigationData = new NavigationData(PortalId, "OrderAdmin");

            switch (e.CommandName.ToLower())
            {
                case "entrydetail":
                    param[0] = "eid=" + cArg;
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
                case "reorder":
                    if (Utils.IsNumeric(cArg))
                    {
                        var orderData = new OrderData(PortalId, Convert.ToInt32(cArg));
                        orderData.CopyToCart(DebugMode);
                    }
                    Response.Redirect(Globals.NavigateURL(StoreSettings.Current.CartTabId, "", param), true);
                    break;
                case "return":
                    param[0] = "";
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
                case "search":
                    var strXml = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                    navigationData.Build(strXml, _templSearch);
                    navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpSearch);
                    navigationData.XmlData = GenXmlFunctions.GetGenXml(rpSearch);
                    navigationData.Save();
                    if (StoreSettings.Current.DebugModeFileOut)
                    {
                        strXml = "<root><sql><![CDATA[" + navigationData.Criteria + "]]></sql>" + strXml + "</root>";
                        var xmlDoc = new System.Xml.XmlDocument();
                        xmlDoc.LoadXml(strXml);
                        xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_search.xml");
                    }
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
                case "resetsearch":
                    // clear cookie info
                    navigationData.Delete();
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
                case "downloadinvoice":
                    DownloadInvoice(Convert.ToInt32(cArg));
                    break;
                case "orderby":
                    navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpData);
                    navigationData.Save();
                    break;
            }
        }
Ejemplo n.º 3
0
        public GroupCategoryData GetCurrentCategoryData(int portalId, System.Web.HttpRequest request, int entryId = 0, Dictionary <string, string> settings = null, String targetModuleKey = "")
        {
            var defcatid = 0;

            var categoryid = NBrightBuyUtils.GetCategoryIdFromUrl(portalId, request);

            // always use the catid in url if we have no target module (use GetGrpCategory to include properties being listed)
            if ((categoryid > 0) && targetModuleKey == "")
            {
                return(GetGrpCategory(categoryid));
            }

            if (targetModuleKey != "")
            {
                var navigationdata = new NavigationData(portalId, targetModuleKey);
                if (Utils.IsNumeric(navigationdata.CategoryId) && navigationdata.FilterMode)
                {
                    defcatid = Convert.ToInt32(navigationdata.CategoryId);
                }
                // always use the catid in url if we have no navigation categoryid for the target module.
                if ((categoryid > 0) && defcatid == 0)
                {
                    return(GetGrpCategory(categoryid));
                }
            }

            // if we have no catid in url, make sure we have any possible entryid
            if (entryId == 0)
            {
                entryId = NBrightBuyUtils.GetEntryIdFromUrl(portalId, request);
            }

            // use the first/default category the product has
            if (entryId > 0)
            {
                return(GetDefaultCategory(entryId));
            }

            // get any default set in the settings
            if (defcatid == 0)
            {
                if (settings != null && settings["defaultcatid"] != null)
                {
                    var setcatid = settings["defaultcatid"];
                    if (Utils.IsNumeric(setcatid))
                    {
                        defcatid = Convert.ToInt32(setcatid);
                    }
                }
            }

            return(GetGrpCategory(defcatid));
        }
Ejemplo n.º 4
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var param = new string[2];
            var targlist = _targetModuleKey.Split(',');
                switch (e.CommandName.ToLower())
                {
                    case "search":
                        foreach (var targ in targlist)
                        {
                            var strXml = GenXmlFunctions.GetGenXml(rpData, "", "");
                            var navigationData = new NavigationData(PortalId, targ);
                            navigationData.Build(strXml, _templD);
                            navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpData);
                            navigationData.XmlData = GenXmlFunctions.GetGenXml(rpData);
                            navigationData.Mode = GenXmlFunctions.GetField(rpData, "navigationmode").ToLower();
                            navigationData.Save();

                            if (StoreSettings.Current.DebugModeFileOut)
                            {
                                strXml = "<root><sql><![CDATA[" + navigationData.Criteria + "]]></sql>" + strXml + "</root>";
                                var xmlDoc = new System.Xml.XmlDocument();
                                xmlDoc.LoadXml(strXml);
                                xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_search.xml");
                            }

                        }

                        Response.Redirect(Globals.NavigateURL(_redirecttabid, "", param), true);
                        break;
                    case "resetsearch":
                        // clear cookie info
                        foreach (var targ in targlist)
                        {
                            var navigationData = new NavigationData(PortalId, targ);
                            navigationData.Delete();
                        }
                        Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                        break;
                    case "orderby":
                        foreach (var targ in targlist)
                        {
                            var navigationData = new NavigationData(PortalId, targ);
                            navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpData);
                            navigationData.Save();
                        }
                        break;
                }
        }
Ejemplo n.º 5
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg = e.CommandArgument.ToString();
            var param = new string[3];

            var navigationData = new NavigationData(PortalId, "CategoryAdmin");
            switch (e.CommandName.ToLower())
            {
                case "entrydetail":
                    SaveAll();
                    param[1] = "eid=" + cArg;
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "return":
                    param[1] = "";
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "search":
                    var strXml = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                    navigationData.XmlData = strXml;
                    if (StoreSettings.Current.DebugModeFileOut)
                    {
                        strXml = "<root><sql><![CDATA[" + navigationData.Criteria + "]]></sql>" + strXml + "</root>";
                        var xmlDoc = new System.Xml.XmlDocument();
                        xmlDoc.LoadXml(strXml);
                        xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_search.xml");
                    }
                    navigationData.Save();
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "resetsearch":
                    // clear cookie info
                    navigationData.Delete();
                    param[2] = "catid=0";
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "addnew":
                    var strXml2 = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                    navigationData.XmlData = strXml2;
                    navigationData.Save();
                    var categoryData = CategoryUtils.GetCategoryData(-1, EditLanguage);
                    if (!String.IsNullOrEmpty(Edittype) && Edittype.ToLower() == "group")
                    {
                        categoryData.GroupType = GenXmlFunctions.GetGenXmlValue(navigationData.XmlData, "genxml/dropdownlist/groupsel");
                        if (categoryData.GroupType == "") categoryData.GroupType = "cat";
                        var grpCtrl = new GrpCatController(Utils.GetCurrentCulture());
                        var grp = grpCtrl.GetGrpCategoryByRef(categoryData.GroupType);
                        if (grp != null) categoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", grp.categoryid.ToString(""));
                        categoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkishidden", "False"); // don't hide property groups by default
                    }
                    categoryData.ParentItemId = _openid;
                    categoryData.Save();
                    NBrightBuyUtils.RemoveModCachePortalWide(PortalId);

                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "delete":
                    if (Utils.IsNumeric(cArg))
                    {
                        ModCtrl.Delete(Convert.ToInt32(cArg));
                    }
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "saveall":
                    SaveAll();
                    NBrightBuyUtils.RemoveModCachePortalWide(PortalId); //clear any cache
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "move":
                    SaveAll();
                    if (Utils.IsNumeric(cArg))
                    {
                        MoveRecord(Convert.ToInt32(cArg));
                    }
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "open":
                    param[1] = "catid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "close":
                    var catData = CategoryUtils.GetCategoryData(_openid, EditLanguage);
                    if (catData.DataRecord == null)
                        param[1] = "catid=0";
                    else
                        param[1] = "catid=" + catData.DataRecord.ParentItemId.ToString("");
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "save":
                    UpdateRecord();
                    param[1] = "eid=" + cArg;
                   param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "saveexit":
                    UpdateRecord();
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;

            }
        }
Ejemplo n.º 6
0
        private void PageLoad()
        {
            #region "Data Repeater"
            if (UserId > 0) // only logged in users can see data on this module.
            {

                if (_displayentrypage)
                {
                    DisplayDataEntryRepeater(_entryid);
                }
                else
                {
                    var navigationData = new NavigationData(PortalId, "ClientsAdmin");

                    //setup paging
                    var pagesize = StoreSettings.Current.GetInt("pagesize");
                    var pagenumber = 1;
                    var strpagenumber = Utils.RequestParam(Context, "page");
                    if (Utils.IsNumeric(strpagenumber)) pagenumber = Convert.ToInt32(strpagenumber);
                    var recordcount = 0;

                    // get search data
                    var sInfo = new NBrightInfo();
                    sInfo.XMLData = navigationData.XmlData;

                    // display search
                    base.DoDetail(rpSearch, sInfo);

                    if (Utils.IsNumeric(navigationData.RecordCount))
                    {
                        recordcount = Convert.ToInt32(navigationData.RecordCount);
                    }
                    else
                    {
                        recordcount = ModCtrl.GetDnnUsersCount(PortalId, "%" + sInfo.GetXmlProperty("genxml/textbox/txtsearch") + "%");
                        navigationData.RecordCount = recordcount.ToString("");
                    }

                    //display list, with search filter
                    var userlist = ModCtrl.GetDnnUsers(PortalId, "%" + sInfo.GetXmlProperty("genxml/textbox/txtsearch") + "%", 0,pagenumber,pagesize,recordcount);
                    rpData.DataSource = userlist;
                    rpData.DataBind();

                    if (pagesize > 0)
                    {
                        CtrlPaging.PageSize = pagesize;
                        CtrlPaging.CurrentPage = pagenumber;
                        CtrlPaging.TotalRecords = recordcount;
                        CtrlPaging.BindPageLinks();
                    }

                }
            }

            #endregion

            // display header (Do header after the data return so the productcount works)
            base.DoDetail(rpDataH);

            // display footer
            base.DoDetail(rpDataF);
        }
Ejemplo n.º 7
0
        protected override void OnInit(EventArgs e)
        {
            _eid = Utils.RequestQueryStringParam(Context, "eid");
            _print = Utils.RequestParam(Context, "print");
            _printtemplate = Utils.RequestParam(Context, "template");

            EnablePaging = true;

            base.OnInit(e);

            // if guidkey entered instead of eid, find it using the guid and assign to _eid
            _guidkey = Utils.RequestQueryStringParam(Context, "guidkey");
            if (_guidkey == "") _guidkey = Utils.RequestQueryStringParam(Context, "ref");
            if (_eid== "" && _guidkey != "")
            {
                var guidData = ModCtrl.GetByGuidKey(PortalId, -1, "PRD", _guidkey);
                if (guidData != null)
                    _eid = guidData.ItemID.ToString("D");
                else
                    _eid = "0";
            }

            // if we want to print we need to open the browser with a startup script, this points to a Printview.aspx. (Must go after the ModSettings has been init.)
            if (_print != "") Page.ClientScript.RegisterStartupScript(this.GetType(), "printproduct", "window.open('" + StoreSettings.NBrightBuyPath() + "/PrintView.aspx?itemid=" + _eid + "&printcode=" + _print + "&template=" + _printtemplate + "&theme=" + ModSettings.Get("themefolder") + "','_blank');", true);

            if (ModuleKey == "")  // if we don't have module setting jump out
            {
                rpDataH.ItemTemplate = new GenXmlTemplate("NO MODULE SETTINGS");
                return;
            }

            _navigationdata = new NavigationData(PortalId, ModuleKey);

            // Pass in a template specifying the token to create a friendly url for paging.
            // (NOTE: we need this in NBS becuase the edit product from list return url will copy the page number and hence paging will not work after editing if we don;t do this)
            CtrlPaging.HrefLinkTemplate = "[<tag type='valueof' databind='PreText' />][<tag type='if' databind='Text' testvalue='' display='{OFF}' />][<tag type='hrefpagelink' moduleid='" + ModuleId.ToString("") + "' />][<tag type='endif' />][<tag type='valueof' databind='PostText' />]";
            CtrlPaging.UseListDisplay = true;
            try
            {
                _catid = Utils.RequestQueryStringParam(Context, "catid");
                _catname = Utils.RequestQueryStringParam(Context, "catref");

                #region "set templates based on entry id (eid) from url"

                _ename = Utils.RequestQueryStringParam(Context, "entry");
                _modkey = Utils.RequestQueryStringParam(Context, "modkey");
                _pagemid = Utils.RequestQueryStringParam(Context, "pagemid");
                _pagenum = Utils.RequestQueryStringParam(Context, "page");
                _pagesize = Utils.RequestQueryStringParam(Context, "pagesize");
                _orderbyindex = Utils.RequestQueryStringParam(Context, "orderby");

                // see if we need to display the entry page.
                if ((_modkey == ModuleKey | _modkey == "") && (_eid != "" | _ename != "")) _displayentrypage = true;

                // if we have entry detail display, but no catd, get the default one.
                if (_displayentrypage && _catid == "" && Utils.IsNumeric(_eid))
                {
                    var prdData = ProductUtils.GetProductData(Convert.ToInt32(_eid), Utils.GetCurrentCulture());
                    var defcat = prdData.GetDefaultCategory();
                    if (defcat != null) _catid = defcat.categoryid.ToString("");
                }

                if (ModSettings.Get("listonly").ToLower() == "true") _displayentrypage = false;

                // get template codes
                if (_displayentrypage)
                {
                    _templH = ModSettings.Get("txtdisplayentryheader");
                    _templD = ModSettings.Get("txtdisplayentrybody");
                    _templF = ModSettings.Get("txtdisplayentryfooter");
                }
                else
                {
                    _templH = ModSettings.Get("txtdisplayheader");
                    _templD = ModSettings.Get("txtdisplaybody");
                    _templF = ModSettings.Get("txtdisplayfooter");
                }

                #endregion

                // Get Display Header
                var rpDataHTempl = ModCtrl.GetTemplateData(ModSettings, _templH, Utils.GetCurrentCulture(), DebugMode);

                //-------------------------------------------------------------------------
                //Get default sort order and filter from the displayheader template.  Use template data, becuase repeater is not fully initialized yet.
                _strOrder = _navigationdata.OrderBy;
                if (String.IsNullOrEmpty(_strOrder)) _strOrder = GenXmlFunctions.GetSqlOrderBy(rpDataHTempl); // get default
                if (_orderbyindex != "") // if we have orderby set in url, find the meta tags
                {
                    _strOrder = GenXmlFunctions.GetSqlOrderBy(rpDataHTempl,_orderbyindex);
                    // save the selected orderby to the cookie, so we can page with it.
                    _navigationdata.OrderBy = _strOrder;
                }
                //-------------------------------------------------------------------------

                var cachekey = "GenXmlTemplate*rpDataH" + _templH + "*" + ModuleId.ToString();
                _templateHeader = (GenXmlTemplate)Utils.GetCache(cachekey);
                if (_templateHeader == null || StoreSettings.Current.DebugMode)
                {
                    _templateHeader = NBrightBuyUtils.GetGenXmlTemplate(rpDataHTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                }
                rpDataH.ItemTemplate = _templateHeader;

                // insert page header text
                NBrightBuyUtils.IncludePageHeaders(ModCtrl, ModuleId, Page, _templateHeader, ModSettings.Settings(), null, DebugMode);

                // Get Display Body
                var rpDataTempl = ModCtrl.GetTemplateData(ModSettings, _templD, Utils.GetCurrentCulture(), DebugMode);
                //if body template doesn't contain a default moduleid add it.
                if (!rpDataTempl.ToLower().Contains("nbs:modeldefault")) rpDataTempl = "[<tag type='nbs:modeldefault' />]" + rpDataTempl;
                // always add a productid hidden field to the data template (for add to cart)
                rpDataTempl = "[<tag type='hidden' id='productid' value='databind:itemid' />]" + rpDataTempl;

                cachekey = "GenXmlTemplate*rpData" + _templD + "*" + ModuleId.ToString();
                var gXml = (GenXmlTemplate)Utils.GetCache(cachekey);
                if (gXml == null || StoreSettings.Current.DebugMode)
                {
                    gXml = NBrightBuyUtils.GetGenXmlTemplate(rpDataTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                }
                rpData.ItemTemplate = gXml;

                // Get Display Footer
                var rpDataFTempl = ModCtrl.GetTemplateData(ModSettings, _templF, Utils.GetCurrentCulture(), DebugMode);

                cachekey = "GenXmlTemplate*rpDataF" + _templF + "*" + ModuleId.ToString();
                gXml = (GenXmlTemplate)Utils.GetCache(cachekey);
                if (gXml == null || StoreSettings.Current.DebugMode)
                {
                    gXml = NBrightBuyUtils.GetGenXmlTemplate(rpDataFTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                }
                rpDataF.ItemTemplate = gXml;

            }
            catch (Exception exc)
            {
                // remove any cookie which might store SQL in error.
                _navigationdata.Delete();
                DisplayProductError(exc.ToString());
            }
        }
Ejemplo n.º 8
0
 private void ProductCountDataBind(object sender, EventArgs e)
 {
     var l = (Literal)sender;
     try
     {
         var navdata = new NavigationData(PortalSettings.Current.PortalId, l.Text);
         l.Text = navdata.RecordCount;
         l.Visible = visibleStatus.DefaultIfEmpty(true).First();
     }
     catch (Exception ex)
     {
         l.Text = ex.ToString();
     }
 }
Ejemplo n.º 9
0
        public override TestOfData TestOfDataBinding(object sender, EventArgs e)
        {
            var rtnData = new TestOfData();
            rtnData.DataValue = null;
            rtnData.TestValue = null;
            var lc = (Literal)sender;
            var container = (IDataItemContainer)lc.NamingContainer;
            try
            {
                NBrightInfo info;

                ProductData prodData;
                CatProdXref xrefData;

                var xmlDoc = new XmlDocument();
                CartData currentcart;

                xmlDoc.LoadXml("<root>" + lc.Text + "</root>");
                var xmlNod = xmlDoc.SelectSingleNode("root/tag");

                if (container.DataItem != null && xmlNod != null && (xmlNod.Attributes != null && xmlNod.Attributes["function"] != null))
                {
                    rtnData.DataValue = "FALSE";

                    XmlNode nod;
                    var testValue = "";
                    if ((xmlNod.Attributes["testvalue"] != null)) testValue = xmlNod.Attributes["testvalue"].Value;

                    // check for setting key
                    var settingkey = "";
                    if ((xmlNod.Attributes["key"] != null)) settingkey = xmlNod.Attributes["key"].Value;

                    var role = "";
                    if ((xmlNod.Attributes["role"] != null)) role = xmlNod.Attributes["role"].Value;

                    var index = "";
                    if ((xmlNod.Attributes["index"] != null)) index = xmlNod.Attributes["index"].Value;

                    var modulekey = "";
                    if ((xmlNod.Attributes["modulekey"] != null)) modulekey = xmlNod.Attributes["modulekey"].Value;

                    var targetmodulekey = "";
                    if ((xmlNod.Attributes["targetmodulekey"] != null)) targetmodulekey = xmlNod.Attributes["targetmodulekey"].Value;

                    // do special tests for named fucntions
                    switch (xmlNod.Attributes["function"].Value.ToLower())
                    {
                        case "searchactive":
                            var navdata2 = new NavigationData(PortalSettings.Current.PortalId, targetmodulekey);
                            if (navdata2.Criteria == "") rtnData.DataValue = "FALSE";
                            else rtnData.DataValue = "TRUE";
                            break;
                        case "productcount":
                            var navdata = new NavigationData(PortalSettings.Current.PortalId, modulekey);
                            rtnData.DataValue = navdata.RecordCount;
                            break;
                        case "price":
                            rtnData.DataValue = GetFromPrice((NBrightInfo) container.DataItem);
                            break;
                        case "dealerprice":
                            rtnData.DataValue = GetDealerPrice((NBrightInfo) container.DataItem);
                            break;
                        case "saleprice":
                            rtnData.DataValue = GetSalePrice((NBrightInfo) container.DataItem);
                            break;
                        case "imgexists":
                            rtnData.DataValue = testValue;
                            nod = GenXmlFunctions.GetGenXmLnode(DataBinder.Eval(container.DataItem, _databindColumn).ToString(), "genxml/imgs/genxml[" + rtnData.DataValue + "]");
                            if (nod == null) rtnData.DataValue = "FALSE";
                            break;
                        case "modelexists":
                            rtnData.DataValue = testValue;
                            nod = GenXmlFunctions.GetGenXmLnode(DataBinder.Eval(container.DataItem, _databindColumn).ToString(), "genxml/models/genxml[" + rtnData.DataValue + "]");
                            if (nod == null) rtnData.DataValue = "FALSE";
                            break;
                        case "optionexists":
                            rtnData.DataValue = testValue;
                            nod = GenXmlFunctions.GetGenXmLnode(DataBinder.Eval(container.DataItem, _databindColumn).ToString(), "genxml/options/genxml[" + rtnData.DataValue + "]");
                            if (nod == null) rtnData.DataValue = "FALSE";
                            break;
                        case "isinstock":
                            if (IsInStock((NBrightInfo) container.DataItem))
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "ismodelinstock":
                            if (IsModelInStock((NBrightInfo) container.DataItem))
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "inwishlist":
                            var productid = DataBinder.Eval(container.DataItem, "ItemId").ToString();
                            if (Utils.IsNumeric(productid))
                            {
                                var listname = "ItemList";
                                if ((xmlNod.Attributes["listname"] != null)) listname = xmlNod.Attributes["listname"].Value;

                                var wl = new ItemListData(listname);
                                if (wl.IsInList(productid))
                                {
                                    rtnData.DataValue = "TRUE";
                                    rtnData.TestValue = "TRUE";
                                }
                            }
                            break;
                        case "isonsale":
                            var saleprice = GetSalePriceDouble((NBrightInfo) container.DataItem);
                            if (saleprice > 0)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "hasrelateditems":
                            info = (NBrightInfo) container.DataItem;
                            prodData = ProductUtils.GetProductData(info.ItemID, info.Lang);
                            if (prodData.GetRelatedProducts().Count > 0)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "hasdocuments":
                            info = (NBrightInfo) container.DataItem;
                            prodData = ProductUtils.GetProductData(info.ItemID, info.Lang);
                            if (prodData.Docs.Count > 0)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "haspurchasedocuments":
                            info = (NBrightInfo) container.DataItem;
                            prodData = ProductUtils.GetProductData(info.ItemID, info.Lang);
                            if (prodData.Docs.Select(i => i.GetXmlProperty("genxml/checkbox/chkpurchase") == "True").Any())
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "hasproperty":
                            info = (NBrightInfo) container.DataItem;
                            xrefData = new CatProdXref();
                            if (xrefData.IsProductInCategory(info.ItemID,testValue))
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "isincategory":
                            info = (NBrightInfo) container.DataItem;
                            xrefData = new CatProdXref();
                            if (xrefData.IsProductInCategory(info.ItemID,testValue))
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "isdocpurchasable":
                            nod = GenXmlFunctions.GetGenXmLnode(DataBinder.Eval(container.DataItem, _databindColumn).ToString(), "genxml/docs/genxml[" + index + "]/hidden/docid");
                            if (nod != null)
                            {
                                info = (NBrightInfo) container.DataItem;
                                prodData = ProductUtils.GetProductData(info.ItemID, info.Lang);
                                if (prodData.Docs.Select(i => i.GetXmlProperty("genxml/checkbox/chkpurchase") == "True" && i.GetXmlProperty("genxml/hidden/docid") == nod.InnerText).Any())
                                {
                                    rtnData.DataValue = "TRUE";
                                    rtnData.TestValue = "TRUE";
                                }
                            }
                            break;
                        case "isdocpurchased":
                            nod = GenXmlFunctions.GetGenXmLnode(DataBinder.Eval(container.DataItem, _databindColumn).ToString(), "genxml/docs/genxml[" + index + "]/hidden/docid");
                            if (nod != null && Utils.IsNumeric(nod.InnerText))
                            {
                                var uInfo = UserController.GetCurrentUserInfo();
                                //[TODO: work out method of finding if user purchased document.]
                                //if (NBrightBuyV2Utils.DocHasBeenPurchasedByDocId(uInfo.UserID, Convert.ToInt32(nod.InnerText)))
                                //{
                                //    rtnData.DataValue = "TRUE";
                                //    rtnData.TestValue = "TRUE";
                                //}
                            }
                            break;
                        case "hasmodelsoroptions":
                            nod = GenXmlFunctions.GetGenXmLnode(DataBinder.Eval(container.DataItem, _databindColumn).ToString(), "genxml/models/genxml[2]/hidden/modelid");
                            if (nod != null && nod.InnerText != "")
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            if (rtnData.DataValue == "FALSE")
                            {
                                nod = GenXmlFunctions.GetGenXmLnode(DataBinder.Eval(container.DataItem, _databindColumn).ToString(), "genxml/options/genxml[1]/hidden/optionid");
                                if (nod != null && nod.InnerText != "")
                                {
                                    rtnData.DataValue = "TRUE";
                                    rtnData.TestValue = "TRUE";
                                }
                            }
                            break;
                        case "isproductincart":
                            var cartData = new CartData(PortalSettings.Current.PortalId);
                            info = (NBrightInfo) container.DataItem;
                            if (cartData.GetCartItemList().Select(i => i.GetXmlProperty("genxml/productid") == info.ItemID.ToString("")).Any())
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "settings":
                            if (_settings != null && _settings.ContainsKey(settingkey) && _settings[settingkey] == testValue)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "debugmode":
                            if (StoreSettings.Current.DebugMode)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "isinrole":
                            if (CmsProviderManager.Default.IsInRole(role))
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "issuperuser":
                            if (UserController.GetCurrentUserInfo().IsSuperUser)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "isuser":
                            if (UserController.GetCurrentUserInfo().UserID >= 0)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "isclientordermode":
                            currentcart = new CartData(PortalSettings.Current.PortalId);
                            if (currentcart.IsClientOrderMode())
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "carteditmode":
                            currentcart = new CartData(PortalSettings.Current.PortalId);
                            var editmode = currentcart.GetInfo().GetXmlProperty("genxml/carteditmode");
                            if (editmode == testValue)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "iscartempty":
                            currentcart = new CartData(PortalSettings.Current.PortalId);
                            var l = currentcart.GetCartItemList();
                            if (!l.Any())
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "hasshippingproviders":
                            var pluginData = new PluginData(PortalSettings.Current.PortalId);
                            var provList = pluginData.GetShippingProviders();
                            if (provList.Count > 1)
                            {
                                rtnData.DataValue = "TRUE";
                                rtnData.TestValue = "TRUE";
                            }
                            break;
                        case "profile":
                            var userInfo = UserController.GetCurrentUserInfo();
                            if (userInfo.UserID >= 0) rtnData.DataValue = userInfo.Profile.GetPropertyValue(settingkey);
                            break;
                        case "static":
                            break;
                        default:
                            rtnData.DataValue = null;
                            break;
                    }
                }
            }
            catch (Exception)
            {
                lc.Text = "";
            }
            return rtnData;
        }
Ejemplo n.º 10
0
        protected override void OnInit(EventArgs e)
        {
            _eid = Utils.RequestQueryStringParam(Context, "eid");
            _print = Utils.RequestParam(Context, "print");
            _printtemplate = Utils.RequestParam(Context, "template");

            EnablePaging = true;

            base.OnInit(e);

            // if guidkey entered instead of eid, find it using the guid and assign to _eid
            _guidkey = Utils.RequestQueryStringParam(Context, "guidkey");
            if (_guidkey == "") _guidkey = Utils.RequestQueryStringParam(Context, "ref");
            if (_eid== "" && _guidkey != "")
            {
                var guidData = ModCtrl.GetByGuidKey(PortalId, -1, EntityTypeCode, _guidkey);
                if (guidData != null)
                    _eid = guidData.ItemID.ToString("D");
                else
                    _eid = "0";
            }

            // if we want to print we need to open the browser with a startup script, this points to a Printview.aspx. (Must go after the ModSettings has been init.)
            if (_print != "") Page.ClientScript.RegisterStartupScript(this.GetType(), "printproduct", "window.open('" + StoreSettings.NBrightBuyPath() + "/PrintView.aspx?itemid=" + _eid + "&printcode=" + _print + "&template=" + _printtemplate + "&theme=" + ModSettings.Get("themefolder") + "','_blank');", true);

            if (ModuleKey == "")  // if we don't have module setting jump out
            {
                var lit = new Literal();
                lit.Text = "NO MODULE SETTINGS";
                phData.Controls.Add(lit);
                return;
            }

            _navigationdata = new NavigationData(PortalId, ModuleKey);

            // Pass in a template specifying the token to create a friendly url for paging.
            // (NOTE: we need this in NBS becuase the edit product from list return url will copy the page number and hence paging will not work after editing if we don;t do this)
            CtrlPaging.HrefLinkTemplate = "[<tag type='valueof' databind='PreText' />][<tag type='if' databind='Text' testvalue='' display='{OFF}' />][<tag type='hrefpagelink' moduleid='" + ModuleId.ToString("") + "' />][<tag type='endif' />][<tag type='valueof' databind='PostText' />]";
            CtrlPaging.UseListDisplay = true;
            try
            {
                _catid = Utils.RequestQueryStringParam(Context, "catid");
                _catname = Utils.RequestQueryStringParam(Context, "catref");

                #region "set templates based on entry id (eid) from url"

                _ename = Utils.RequestQueryStringParam(Context, "entry");
                _modkey = Utils.RequestQueryStringParam(Context, "modkey");
                _pagemid = Utils.RequestQueryStringParam(Context, "pagemid");
                _pagenum = Utils.RequestQueryStringParam(Context, "page");
                _pagesize = Utils.RequestQueryStringParam(Context, "pagesize");
                _orderbyindex = Utils.RequestQueryStringParam(Context, "orderby");

                // see if we need to display the entry page.
                if ((_modkey == ModuleKey | _modkey == "") && (_eid != "" | _ename != "")) _displayentrypage = true;

                // if we have entry detail display, but no catd, get the default one.
                if (_displayentrypage && _catid == "" && Utils.IsNumeric(_eid))
                {
                    var prdData = ProductUtils.GetProductData(Convert.ToInt32(_eid),Utils.GetCurrentCulture(), true, EntityTypeCode);
                    var defcat = prdData.GetDefaultCategory();
                    if (defcat != null) _catid = defcat.categoryid.ToString("");
                }

                if (ModSettings.Get("listonly").ToLower() == "true") _displayentrypage = false;

                // get template codes
                if (_displayentrypage)
                {
                    _templD = ModSettings.Get("razordetailtemplate");
                    if (_templD == "") _templD = ModSettings.Get("txtdisplayentrybody"); // legacy name
                }
                else
                {
                    _templD = ModSettings.Get("razorlisttemplate");
                    if (_templD == "") _templD = ModSettings.Get("txtdisplaybody"); // legacy name
                }

                #endregion

            }
            catch (Exception exc)
            {
                // remove any cookie which might store SQL in error.
                _navigationdata.Delete();
                DisplayProductError(exc.ToString());
            }
        }
Ejemplo n.º 11
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg = e.CommandArgument.ToString();
            var param = new string[3];

            var navigationData = new NavigationData(PortalId, "CategoryAdmin");
            switch (e.CommandName.ToLower())
            {
                case "entrydetail":
                    SaveAll();
                    param[1] = "eid=" + cArg;
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "return":
                    param[1] = "";
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "search":
                    var strXml = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                    navigationData.XmlData = strXml;
                    if (StoreSettings.Current.DebugModeFileOut)
                    {
                        strXml = "<root><sql><![CDATA[" + navigationData.Criteria + "]]></sql>" + strXml + "</root>";
                        var xmlDoc = new System.Xml.XmlDocument();
                        xmlDoc.LoadXml(strXml);
                        xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_search.xml");
                    }
                    navigationData.Save();
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "resetsearch":
                    // clear cookie info
                    navigationData.Delete();
                    param[2] = "catid=0";
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "addnew":
                    var strXml2 = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                    navigationData.XmlData = strXml2;
                    navigationData.Save();
                    var categoryData = CategoryUtils.GetCategoryData(-1, EditLanguage);
                    if (!String.IsNullOrEmpty(Edittype) && Edittype.ToLower() == "group")
                    {
                        categoryData.GroupType = GenXmlFunctions.GetGenXmlValue(navigationData.XmlData, "genxml/dropdownlist/groupsel");
                        if (categoryData.GroupType == "") categoryData.GroupType = "cat";
                        var grpCtrl = new GrpCatController(Utils.GetCurrentCulture());
                        var grp = grpCtrl.GetGrpCategoryByRef(categoryData.GroupType);
                        if (grp != null) categoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", grp.categoryid.ToString(""));
                        categoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkishidden", "False"); // don't hide property groups by default
                    }
                    categoryData.ParentItemId = _openid;
                    categoryData.Save();
                    NBrightBuyUtils.RemoveModCachePortalWide(PortalId);

                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "delete":
                    if (Utils.IsNumeric(cArg))
                    {
                        var catid = Convert.ToInt32(cArg);
                        if (catid > 0)
                        {
                            var delCatData = CategoryUtils.GetCategoryData(catid, EditLanguage);
                            if (delCatData.Exists && delCatData.GetDirectChildren().Count == 0) // only delete end leaf
                            {
                                var productidlist = new ArrayList();
                                foreach (var dc in delCatData.GetDirectArticles())
                                {
                                    productidlist.Add(dc.ParentItemId);
                                }

                                var parentCatList = new List<CategoryData>();
                                var loopCat = CategoryUtils.GetCategoryData(catid, EditLanguage);
                                while (loopCat.Exists && loopCat.ParentItemId > 0)
                                {
                                    loopCat = CategoryUtils.GetCategoryData(loopCat.ParentItemId, EditLanguage);
                                    parentCatList.Add(loopCat);
                                }

                                foreach (var pCat in parentCatList)
                                {
                                    foreach (var prodxref in pCat.GetCascadeArticles())
                                    {
                                        if (productidlist.Contains(prodxref.ParentItemId))
                                        {
                                            // delete CATCASCADE record
                                           ModCtrl.Delete(prodxref.ItemID);
                                        }
                                    }

                                }

                                foreach (var dc in delCatData.GetDirectArticles())
                                {
                                    // delete CATXREF record
                                    ModCtrl.Delete(dc.ParentItemId);
                                }
                                // delete CATEGORY record (constrants remove LANG records.)
                                ModCtrl.Delete(catid);
                            }
                            else
                            {
                                NBrightBuyUtils.SetNotfiyMessage(ModuleId, "onlyleafcat", NotifyCode.fail);
                            }
                        }
                    }
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "saveall":
                    SaveAll();
                    NBrightBuyUtils.RemoveModCachePortalWide(PortalId); //clear any cache
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "move":
                    SaveAll();
                    if (Utils.IsNumeric(cArg))
                    {
                        MoveRecord(Convert.ToInt32(cArg));
                    }
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "open":
                    param[1] = "catid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "close":
                    var catData = CategoryUtils.GetCategoryData(_openid, EditLanguage);
                    if (catData.DataRecord == null)
                        param[1] = "catid=0";
                    else
                        param[1] = "catid=" + catData.DataRecord.ParentItemId.ToString("");
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "save":
                    UpdateRecord();
                    param[1] = "eid=" + cArg;
                   param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "saveexit":
                    UpdateRecord();
                    param[2] = "catid=" + _openid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;

            }
        }
Ejemplo n.º 12
0
        public GroupCategoryData GetCurrentCategoryData(int portalId, System.Web.HttpRequest request, int entryId = 0, Dictionary<string, string> settings = null, String targetModuleKey = "")
        {
            var defcatid = 0;

            var categoryid = NBrightBuyUtils.GetCategoryIdFromUrl(portalId, request);

            // always use the catid in url if we have no target module (use GetGrpCategory to include properties being listed)
            if ((categoryid > 0) && targetModuleKey == "") return GetGrpCategory(categoryid);

            if (targetModuleKey != "")
            {
                var navigationdata = new NavigationData(portalId, targetModuleKey);
                if (Utils.IsNumeric(navigationdata.CategoryId) && navigationdata.FilterMode) defcatid = Convert.ToInt32(navigationdata.CategoryId);
                // always use the catid in url if we have no navigation categoryid for the target module.
                if ((categoryid > 0) && defcatid == 0) return GetGrpCategory(categoryid);
            }

            // if we have no catid in url, make sure we have any possible entryid
            if (entryId == 0) entryId = NBrightBuyUtils.GetEntryIdFromUrl(portalId, request);

            // use the first/default category the product has
            if (entryId > 0) return GetDefaultCategory(entryId);

            // get any default set in the settings
            if (defcatid == 0)
            {
                if (settings != null && settings["defaultcatid"] != null)
                {
                    var setcatid = settings["defaultcatid"];
                    if (Utils.IsNumeric(setcatid)) defcatid = Convert.ToInt32(setcatid);
                }
            }

            return GetGrpCategory(defcatid);
        }
Ejemplo n.º 13
0
        private string ResetSearch(HttpContext context)
        {
            // take all input and created a SQL select with data and save for processing on search list.
                var ajaxInfo = GetAjaxInfo(context, true);
                var navData = new NavigationData(ajaxInfo.PortalId, ajaxInfo.GetXmlProperty("genxml/hidden/modulekey"));
                navData.Delete();

                return "RESET";
        }
Ejemplo n.º 14
0
        private string DoSearch(HttpContext context)
        {
            // take all input and created a SQL select with data and save for processing on search list.
                var ajaxInfo = GetAjaxInfo(context, true);
                var tagList = new List<string>();
                var nodList = ajaxInfo.XMLDoc.SelectNodes("genxml/hidden/*");
                foreach (XmlNode nod in nodList)
                {
                    tagList.Add(nod.InnerText);
                }
                var navData = new NavigationData(ajaxInfo.PortalId, ajaxInfo.GetXmlProperty("genxml/hidden/modulekey"));
                navData.Build(ajaxInfo.XMLData,tagList);
                navData.Mode = ajaxInfo.GetXmlProperty("genxml/hidden/navigationmode").ToLower();
                navData.CategoryId = ajaxInfo.GetXmlPropertyInt("genxml/hidden/categoryid");
                if (ajaxInfo.GetXmlProperty("genxml/hidden/pagenumber") != "") navData.PageNumber = ajaxInfo.GetXmlProperty("genxml/hidden/pagenumber");
                if (ajaxInfo.GetXmlProperty("genxml/hidden/pagesize") != "") navData.PageSize = ajaxInfo.GetXmlProperty("genxml/hidden/pagesize");
                if (ajaxInfo.GetXmlProperty("genxml/hidden/pagename") != "") navData.PageName = ajaxInfo.GetXmlProperty("genxml/hidden/pagename");
                if (ajaxInfo.GetXmlProperty("genxml/hidden/pagemoduleid") != "") navData.PageModuleId  = ajaxInfo.GetXmlProperty("genxml/hidden/pagemoduleid");
                navData.SearchFormData = ajaxInfo.XMLData;
                navData.Save();

                return "OK";
        }
Ejemplo n.º 15
0
        private string DoOrderBy(HttpContext context)
        {
            // take all input and created a SQL select with data and save for processing on search list.
                var ajaxInfo = GetAjaxInfo(context, true);
                var navData = new NavigationData(ajaxInfo.PortalId, ajaxInfo.GetXmlProperty("genxml/hidden/modulekey"));
                navData.OrderByIdx = ajaxInfo.GetXmlProperty("genxml/hidden/orderbyidx");
                navData.OrderBy = " order by " + ajaxInfo.GetXmlProperty("genxml/hidden/orderby" + navData.OrderByIdx);
                navData.Save();

                return "OK";
        }
 private void RazorPageLoad()
 {
     var obj = new NBrightInfo(true);
     // no cache key, we don't want to cache this form.
     var searchcookie = new NavigationData(PortalId, ModSettings.Get("targetmodulekey"));
     var paramcatid = Utils.RequestQueryStringParam(Context, "catid");
     if (!Utils.IsNumeric(paramcatid)) paramcatid = "0";
     if (searchcookie.CategoryId == Convert.ToInt32(paramcatid)) // filter mode DOES NOT persist catid (stop confusion when user selects a category)
     {
         if (searchcookie.SearchFormData != "") obj.XMLData = searchcookie.SearchFormData;
     }
     else
     {
         searchcookie.ResetSearch();
     }
     var strOut = NBrightBuyUtils.RazorTemplRender(RazorTemplate,-1,"", obj,ControlPath, ThemeFolder, Utils.GetCurrentCulture(), ModSettings.Settings());
     var lit = new Literal();
     lit.Text = strOut;
     phData.Controls.Add(lit);
 }
Ejemplo n.º 17
0
        public GroupCategoryData GetCurrentCategoryData(int portalId, System.Web.HttpRequest request, int entryId = 0, Dictionary<string, string> settings = null, String targetModuleKey = "")
        {
            var defcatid = 0;
            var qrycatid = Utils.RequestQueryStringParam(request, "catid");
            if (qrycatid == "")
            {
                var qrycatref = Utils.RequestQueryStringParam(request, "catref");
                if (qrycatref != "")
                {
                    var catrefData = GetCategoryByRef(portalId, qrycatref);
                    if (catrefData != null) qrycatid = catrefData.categoryid.ToString("");
                }
            }

            // always use the catid in url if we have no target module
            if (Utils.IsNumeric(qrycatid) && targetModuleKey == "") return GetCategory(Convert.ToInt32(qrycatid));

            if (targetModuleKey != "")
            {
                var navigationdata = new NavigationData(portalId, targetModuleKey);
                if (Utils.IsNumeric(navigationdata.CategoryId) && navigationdata.FilterMode) defcatid = Convert.ToInt32(navigationdata.CategoryId);
                // always use the catid in url if we have no navigation categoryid for the target module.
                if (Utils.IsNumeric(qrycatid) && defcatid == 0) return GetCategory(Convert.ToInt32(qrycatid));
            }

            // if we have no catid in url, make sure we have any possible entryid
            if (entryId == 0)
            {
                var qryitemid = Utils.RequestQueryStringParam(request, "eid");
                if (Utils.IsNumeric(qryitemid))
                {
                    entryId = Convert.ToInt32(qryitemid);
                }
                else
                {
                    var qryguidkey = Utils.RequestQueryStringParam(request, "guidkey");
                    if (qryguidkey == "") qryguidkey = Utils.RequestQueryStringParam(request, "ref");
                    if (qryguidkey != "")
                    {
                        var objCtrl = new NBrightBuyController();
                        var guidData = objCtrl.GetByGuidKey(portalId, -1, "PRD", qryguidkey);
                        if (guidData != null) entryId = guidData.ItemID;
                    }
                }
            }

            // use the first/default category the proiduct has
            if (Utils.IsNumeric(entryId) && entryId > 0) return GetDefaultCategory(entryId);

            // get any default set in the settings
            if (defcatid == 0)
            {
                if (settings != null && settings["defaultcatid"] != null)
                {
                    var setcatid = settings["defaultcatid"];
                    if (Utils.IsNumeric(setcatid)) defcatid = Convert.ToInt32(setcatid);
                }
            }

            return GetCategory(defcatid);
        }
Ejemplo n.º 18
0
        private void DoExport()
        {
            var navigationData = new NavigationData(PortalId, "AdminOrders");
            var strFilter = navigationData.Criteria;
            var l2 = new List<NBrightInfo>();

            const string strOrder = "   order by [XMLData].value('(genxml/createddate)[1]','nvarchar(20)') DESC, ModifiedDate DESC  ";
            var l1 = ModCtrl.GetList(PortalId, -1, "ORDER", strFilter, strOrder, 1000);
            foreach (var i in l1)
            {
                var nodList = i.XMLDoc.SelectNodes("genxml/items/*");
                foreach (XmlNode nod in nodList)
                {
                    var itemline = (NBrightInfo)i.Clone();
                    itemline.RemoveXmlNode("genxml/items");
                    itemline.AddXmlNode("<item>" + nod.OuterXml + "</item>", "item", "genxml");
                    l2.Add(itemline);
                }
            }

            var rp = new Repeater();
            var rpSearchTempl = ModCtrl.GetTemplateData(ModSettings, "ordersexport.html", Utils.GetCurrentCulture(), DebugMode);
            rp.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpSearchTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
            rp.DataSource = l2;
            var strOut = GenXmlFunctions.RenderRepeater(rp);
            Utils.ForceStringDownload(Response,"ordersexport.csv",strOut);
        }
Ejemplo n.º 19
0
        private Dictionary<int, string> GetPropertyList(XmlNode xmlNod)
        {
            var displaylevels = 20;
            var parentref = "";
            var prefix = "..";
            var showhidden = "False";
            var showarchived = "False";
            var showempty = "True";
            var showHidden = false;
            var showArchived = false;
            var catreflist = "";
            var parentid = 0;
            var displaycount = "False";
            var displayCount = false;
            var showEmpty = true;
            var groupref = "";
            var filtermode = "";
            List<int> validCatList = null;
            var modulekey = "";
            var redirecttabid = "";
            var tabid = "";
            var lang = Utils.GetCurrentCulture();

            if (xmlNod.Attributes != null)
            {
                if (xmlNod.Attributes["displaylevels"] != null)
                {
                    if (Utils.IsNumeric(xmlNod.Attributes["displaylevels"].Value)) displaylevels = Convert.ToInt32(xmlNod.Attributes["displaylevels"].Value);
                }

                if (xmlNod.Attributes["parentref"] != null) parentref = xmlNod.Attributes["parentref"].Value;
                if (xmlNod.Attributes["showhidden"] != null) showhidden = xmlNod.Attributes["showhidden"].Value;
                if (xmlNod.Attributes["showarchived"] != null) showarchived = xmlNod.Attributes["showarchived"].Value;
                if (xmlNod.Attributes["showempty"] != null) showempty = xmlNod.Attributes["showempty"].Value;
                if (xmlNod.Attributes["displaycount"] != null) displaycount = xmlNod.Attributes["displaycount"].Value;
                if (xmlNod.Attributes["prefix"] != null) prefix = xmlNod.Attributes["prefix"].Value;
                if (xmlNod.Attributes["groupref"] != null) groupref = xmlNod.Attributes["groupref"].Value;
                if (xmlNod.Attributes["filtermode"] != null) filtermode = xmlNod.Attributes["filtermode"].Value;
                if (xmlNod.Attributes["modulekey"] != null) modulekey = xmlNod.Attributes["modulekey"].Value;
                if (xmlNod.Attributes["lang"] != null) lang = xmlNod.Attributes["lang"].Value;

                if (showhidden.ToLower() == "true") showHidden = true;
                if (showarchived.ToLower() == "true") showArchived = true;
                if (showempty.ToLower() == "false") showEmpty = false;
                if (displaycount.ToLower() == "true") displayCount = true;
                if (xmlNod.Attributes["catreflist"] != null) catreflist = xmlNod.Attributes["catreflist"].Value;
                var grpCatCtrl = new GrpCatController(lang);
                if (parentref != "")
                {
                    var p = grpCatCtrl.GetGrpCategoryByRef(parentref);
                    if (p != null) parentid = p.categoryid;
                }
                var catid = "";
                if (filtermode != "")
                {
                    var navigationData = new NavigationData(PortalSettings.Current.PortalId, modulekey);
                    catid = Utils.RequestQueryStringParam(HttpContext.Current.Request, "catid");
                    if (String.IsNullOrEmpty(catid)) catid = navigationData.CategoryId;
                    if (Utils.IsNumeric(catid))
                    {
                        validCatList = GetCateoriesInProductList(Convert.ToInt32(catid));
                    }
                }

            }

            var rtnList = BuildPropertyList(displaylevels, showHidden, showArchived, parentid, catreflist, prefix, displayCount, showEmpty, groupref, ">", lang);

            if (validCatList != null)
            {
                var nonValid = new List<int>();
                // we have a filter on the list, so remove any categories not in valid list.
                foreach (var k in rtnList)
                {
                    if (!validCatList.Contains(k.Key)) nonValid.Add(k.Key);
                }
                foreach (var k in nonValid)
                {
                    rtnList.Remove(k);
                }
            }

            return rtnList;
        }
Ejemplo n.º 20
0
        private void PageLoad()
        {
            #region "Data Repeater"
            if (UserId > 0) // only logged in users can see data on this module.
            {

                #region "display list and detail"

                var navigationData = new NavigationData(PortalId, "AdminOrders");
                // get search data
                var sInfo = new NBrightInfo();
                sInfo.XMLData = navigationData.XmlData;
                // display search
                base.DoDetail(rpSearch, sInfo);

                if (_displayentrypage)
                {
                    DisplayDataEntryRepeater(_entryid);
                }
                else
                {

                    //setup paging
                    var pagesize = StoreSettings.Current.GetInt("pagesize");
                    var pagenumber = 1;
                    var strpagenumber = Utils.RequestParam(Context, "page");
                    if (Utils.IsNumeric(strpagenumber)) pagenumber = Convert.ToInt32(strpagenumber);
                    var recordcount = 0;

                    var strFilter = navigationData.Criteria;

                    // if we have a uid, then we want to display only that clients orders.
                    if (Utils.IsNumeric(_uid)) strFilter += " and UserId = " + _uid + " ";

                    if (Utils.IsNumeric(navigationData.RecordCount))
                    {
                        recordcount = Convert.ToInt32(navigationData.RecordCount);
                    }
                    else
                    {
                        recordcount = ModCtrl.GetListCount(PortalId, -1, "ORDER", strFilter);
                        navigationData.RecordCount = recordcount.ToString("");
                    }

                    //Default orderby if not set
                    const string strOrder = "   order by [XMLData].value('(genxml/createddate)[1]','nvarchar(20)') DESC, ModifiedDate DESC  ";
                    rpData.DataSource = ModCtrl.GetList(PortalId, -1, "ORDER", strFilter, strOrder, 0, pagenumber, pagesize, recordcount);
                    rpData.DataBind();

                    if (pagesize > 0)
                    {
                        CtrlPaging.PageSize = pagesize;
                        CtrlPaging.CurrentPage = pagenumber;
                        CtrlPaging.TotalRecords = recordcount;
                        CtrlPaging.BindPageLinks();
                    }

                    // display header (Do header after the data return so the productcount works)
                    base.DoDetail(rpDataH);

                    // display footer
                    base.DoDetail(rpDataF);

                }

                #endregion
            }

            #endregion
        }
Ejemplo n.º 21
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            _catGrpCtrl = new GrpCatController(Utils.GetCurrentCulture());

            if (ModSettings.Get("themefolder") == "")  // if we don't have module setting jump out
            {
                rpDataH.ItemTemplate = new GenXmlTemplate("NO MODULE SETTINGS");
                return;
            }

            try
            {
                _targetModuleKey = "";
                _targetModuleKey = ModSettings.Get("targetmodulekey");

                _entryid = Utils.RequestQueryStringParam(Context, "eid");
                _catid = Utils.RequestQueryStringParam(Context, "catid");
                _catname = Utils.RequestQueryStringParam(Context, "catref");
                if (_catid == "" && _catname != "") _catid = CategoryUtils.GetCatIdFromName(_catname);

                var navigationdata = new NavigationData(PortalId, _targetModuleKey);
                if (Utils.IsNumeric(_catid)) navigationdata.Delete(); // if a category button has been clicked (in url) then clear search;
                if (Utils.IsNumeric(navigationdata.CategoryId) && navigationdata.FilterMode) _catid = navigationdata.CategoryId;
                if (Utils.IsNumeric(_entryid))
                {
                    // Get catid from product
                    var prodData = ProductUtils.GetProductData(Convert.ToInt32(_entryid), Utils.GetCurrentCulture());
                    var catDef = prodData.GetDefaultCategory();
                    if (catDef != null) _catid = catDef.categoryid.ToString("");
                }
                if (_catid == "") _catid = ModSettings.Get("defaultcatid");

                _templH = ModSettings.Get("txtdisplayheader");
                _templD = ModSettings.Get("txtdisplaybody");
                _templDfoot = ModSettings.Get("txtdisplaybodyfoot");
                _templF = ModSettings.Get("txtdisplayfooter");

                _tabid = ModSettings.Get("ddllisttabid");
                if (!Utils.IsNumeric(_tabid)) _tabid = TabId.ToString("");

                // Get Display Header
                var rpDataHTempl = ModCtrl.GetTemplateData(ModSettings, _templH, Utils.GetCurrentCulture(), DebugMode);

                rpDataH.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataHTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);
                _templateHeader = (GenXmlTemplate)rpDataH.ItemTemplate;

                // insert page header text
                NBrightBuyUtils.IncludePageHeaders(ModCtrl, ModuleId, Page, _templateHeader, ModSettings.Settings(), null, DebugMode);

                // Get Display Body
                var rpDataTempl = ModCtrl.GetTemplateData(ModSettings, _templD, Utils.GetCurrentCulture(), DebugMode);
                rpData.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

                // Get Display Footer
                var rpDataFTempl = ModCtrl.GetTemplateData(ModSettings, _templF, Utils.GetCurrentCulture(), DebugMode);
                rpDataF.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpDataFTempl, ModSettings.Settings(), PortalSettings.HomeDirectory);

            }
            catch (Exception exc)
            {
                if (UserInfo.IsSuperUser) rpDataF.ItemTemplate = new GenXmlTemplate(exc.Message, ModSettings.Settings());
                // catch any error and allow processing to continue, output error as footer template.
            }
        }
Ejemplo n.º 22
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg = e.CommandArgument.ToString();
            var tabId = TabId;
            var param = new string[4];
            if (_uid != "") param[0] = "uid=" + _uid;
            var navigationData = new NavigationData(PortalId, "AdminOrders");
            var cmd = e.CommandName.ToLower();
            var resxpath = StoreSettings.NBrightBuyPath() + "/App_LocalResources/Notification.ascx.resx";
            var emailoption = "";

            switch (cmd)
            {
                case "entrydetail":
                    param[0] = "eid=" + cArg;
                    if (_page != "") param[1] = "page=" + _page;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "reorder":
                    param[0] = "";
                    if (Utils.IsNumeric(cArg))
                    {
                        var orderData = new OrderData(PortalId, Convert.ToInt32(cArg));
                        orderData.CopyToCart(DebugMode);
                        tabId = StoreSettings.Current.GetInt("carttab");
                        if (tabId == 0) tabId = TabId;
                    }
                    Response.Redirect(NBrightBuyUtils.AdminUrl(tabId, param), true);
                    break;
                case "editorder":
                    param[0] = "";
                    if (Utils.IsNumeric(cArg))
                    {
                        var orderData = new OrderData(PortalId, Convert.ToInt32(cArg));
                        orderData.ConvertToCart(DebugMode);
                        tabId = StoreSettings.Current.GetInt("carttab");
                        if (tabId == 0) tabId = TabId;
                    }
                    Response.Redirect(NBrightBuyUtils.AdminUrl(tabId, param), true);
                    break;
                case "return":
                    param[0] = "";
                    if (_page != "") param[1] = "page=" + _page;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "search":
                    var strXml = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                    navigationData.Build(strXml, _templSearch);
                    navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpSearch);
                    navigationData.XmlData = GenXmlFunctions.GetGenXml(rpSearch);
                    navigationData.Save();
                    if (StoreSettings.Current.DebugModeFileOut)
                    {
                        strXml = "<root><sql><![CDATA[" + navigationData.Criteria + "]]></sql>" + strXml + "</root>";
                        var xmlDoc = new System.Xml.XmlDocument();
                        xmlDoc.LoadXml(strXml);
                        xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_search.xml");
                    }
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "resetsearch":
                    // clear cookie info
                    navigationData.Delete();
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "orderby":
                    navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpData);
                    navigationData.Save();
                    break;
                case "viewclient":
                    param[1] = "ctrl=clients";
                    if (Utils.IsNumeric(cArg))
                    {
                        var orderData = new OrderData(PortalId, Convert.ToInt32(cArg));
                        param[0] = "uid=" + orderData.UserId.ToString("");
                    }
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
                case "save":
                    param[0] = "eid=" + _entryid;
                    var result = Update();
                    NBrightBuyUtils.SetNotfiyMessage(ModuleId, NotifyRef + cmd, result);
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "printorder":
                        param[0] = "eid=" + _entryid;
                        param[1] = "print=printorder";
                        param[2] = "template=printorder.html";
                        Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "printreceipt":
                        param[0] = "eid=" + _entryid;
                        param[1] = "print=printorder";
                        param[2] = "template=printreceipt.html";
                        Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "printdeliverylabel":
                    param[0] = "eid=" + _entryid;
                    param[1] = "print=printorder";
                    param[2] = "template=printdeliverylabel.html";
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "emailamended":
                    param[0] = "eid=" + _entryid;
                    emailoption = DnnUtils.GetLocalizedString("orderamended_emailsubject.Text", resxpath, Utils.GetCurrentCulture());
                    Update(emailoption);
                    SendOrderEmail(Convert.ToInt32(_entryid), "orderamendedemail.html", "orderamended_emailsubject.Text");
                    NBrightBuyUtils.SetNotfiyMessage(ModuleId, NotifyRef + cmd, NotifyCode.ok);
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "emailreceipt":
                    param[0] = "eid=" + _entryid;
                    emailoption = DnnUtils.GetLocalizedString("orderreceipt_emailsubject.Text", resxpath, Utils.GetCurrentCulture());
                    Update(emailoption);
                    SendOrderEmail(Convert.ToInt32(_entryid), "orderreceiptemail.html", "orderreceipt_emailsubject.Text");
                    NBrightBuyUtils.SetNotfiyMessage(ModuleId, NotifyRef + cmd, NotifyCode.ok);
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "emailshipped":
                    param[0] = "eid=" + _entryid;
                    emailoption = DnnUtils.GetLocalizedString("ordershipped_emailsubject.Text", resxpath, Utils.GetCurrentCulture());
                    Update(emailoption);
                    SendOrderEmail(Convert.ToInt32(_entryid), "ordershippedemail.html", "ordershipped_emailsubject.Text");
                    NBrightBuyUtils.SetNotfiyMessage(ModuleId, NotifyRef + cmd, NotifyCode.ok);
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "emailvalidated":
                    param[0] = "eid=" + _entryid;
                    emailoption = DnnUtils.GetLocalizedString("ordervalidated_emailsubject.Text", resxpath, Utils.GetCurrentCulture());
                    Update(emailoption);
                    SendOrderEmail(Convert.ToInt32(_entryid), "ordervalidatedemail.html", "ordervalidated_emailsubject.Text");
                    NBrightBuyUtils.SetNotfiyMessage(ModuleId, NotifyRef + cmd, NotifyCode.ok);
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "downloadinvoice":
                    DownloadInvoice(Convert.ToInt32(cArg));
                    break;
                case "deleteinvoice":
                    DeleteInvoice(Convert.ToInt32(cArg));
                    param[0] = "eid=" + _entryid;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "export":
                    DoExport();
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
            }
        }
Ejemplo n.º 23
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // must assign a redirect tab, so postback cookie works.
            _redirecttabid = TabId;
            if (Utils.IsNumeric(RedirectTabId))
                _redirecttabid = Convert.ToInt32(RedirectTabId); // use passed in value over module setting (This stops clashbetween skin object and module)
            else
                if (Utils.IsNumeric(ModSettings.Get("redirecttabid"))) _redirecttabid = Convert.ToInt32(ModSettings.Get("redirecttabid"));

            _targetModuleKey = "";
            _targetModuleKey = ModSettings.Get("targetmodulekey");

            if (Page.IsPostBack == false || _isSkinControl)
            {
                var obj = new NBrightInfo();

                var targ = _targetModuleKey.Split(',');
                var searchcookie = new NavigationData(PortalId, targ[0]);
                if (searchcookie.XmlData != "") obj.XMLData = searchcookie.XmlData;
                DoDetail(rpData, obj);
            }
        }
Ejemplo n.º 24
0
        public static string GetReturnUrl(string tabid)
        {
            var redirectTab = DotNetNuke.Entities.Portals.PortalSettings.Current.ActiveTab;
            var rdTabid = redirectTab.TabID;

            if (Utils.IsNumeric(tabid))
            {
                if (Convert.ToInt32(tabid) > 0)
                {
                    rdTabid = Convert.ToInt32(tabid);
                }
            }

            if (Utils.IsNumeric(rdTabid))
            {
                if (Convert.ToInt32(rdTabid) != redirectTab.TabID)
                {
                    var portalTabs = NBrightDNN.DnnUtils.GetPortalTabs(PortalSettings.Current.PortalId);
                    if (portalTabs != null)
                    {
                        var rTab = portalTabs[Convert.ToInt32(rdTabid)];
                        if (rTab != null)
                        {
                            redirectTab = rTab;
                        }
                    }
                }
            }

            //get last active modulekey from cookie.
            var moduleKey = NBrightCore.common.Cookie.GetCookieValue(PortalSettings.Current.PortalId, "NBrigthBuyLastActive", "ModuleKey");

            var pagename = redirectTab.TabName + ".aspx";
            var page = "";
            var pagemid = "";
            var catid = "";
            var navigationdata = new NavigationData(PortalSettings.Current.PortalId, moduleKey);
            if (navigationdata.PageNumber != "") page = "&page=" + navigationdata.PageNumber;
            if (navigationdata.PageModuleId != "") pagemid = "&pagemid=" + navigationdata.PageModuleId;
            if (navigationdata.CategoryId != "") catid = "&catid=" + navigationdata.CategoryId;
            if (navigationdata.PageName != "") pagename = navigationdata.PageName + ".aspx";
            var url = DotNetNuke.Services.Url.FriendlyUrl.FriendlyUrlProvider.Instance().FriendlyUrl(redirectTab, "~/Default.aspx?tabid=" + redirectTab.TabID.ToString("") + page + pagemid + catid, pagename);

            return url;
        }
Ejemplo n.º 25
0
 protected override void OnLoad(EventArgs e)
 {
     try
     {
         base.OnLoad(e);
         if (Page.IsPostBack == false)
         {
             PageLoad();
         }
     }
     catch (Exception exc) //Module failed to load
     {
         //remove the navigation data, it could be causing the error.
         var navigationData = new NavigationData(PortalId, "ClientAdmin");
         navigationData.Delete();
         //display the error on the template (don;t want to log it here, prefer to deal with errors directly.)
         var l = new Literal();
         l.Text = exc.ToString();
         phData.Controls.Add(l);
     }
 }
Ejemplo n.º 26
0
        private void PageLoad()
        {
            #region "Data Repeater"

            if (UserId > 0) // only logged in users can see data on this module.
            {

                if (Utils.IsNumeric(_entryid) && _entryid != "0")
                {
                    var categoryData = CategoryUtils.GetCategoryData(Convert.ToInt32(_entryid), EditLanguage);
                    base.DoDetail(rpData, categoryData.Info);
                }
                else
                {

                    var navigationData = new NavigationData(PortalId, "CategoryAdmin");

                    // get search data
                    var sInfo = new NBrightInfo();
                    sInfo.XMLData = navigationData.XmlData;

                    // display search
                    base.DoDetail(rpSearch, sInfo);

                    var grpCats = new List<NBrightInfo>();
                    if (!String.IsNullOrEmpty(Edittype) && Edittype.ToLower() == "group")
                    {
                        var selgroup = GenXmlFunctions.GetGenXmlValue(navigationData.XmlData, "genxml/dropdownlist/groupsel");
                        if (selgroup == "") selgroup = GenXmlFunctions.GetField(rpSearch, "groupsel");
                        grpCats = NBrightBuyUtils.GetCatList(_openid, selgroup,EditLanguage);
                    }
                    else
                        grpCats = NBrightBuyUtils.GetCatList(_openid, "cat", EditLanguage);

                    rpData.DataSource = grpCats;
                    rpData.DataBind();

                }
            }

            #endregion

            // display header (Do header after the data return so the productcount works)
            base.DoDetail(rpDataH);

            // display footer
            base.DoDetail(rpDataF);
        }
Ejemplo n.º 27
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg = e.CommandArgument.ToString();
            var param = new string[3];
            var navigationData = new NavigationData(PortalId, "ClientsAdmin");

            switch (e.CommandName.ToLower())
            {
                case "entrydetail":
                    param[0] = "uid=" + cArg;
                    if (_page != "") param[1] = "page=" + _page;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "return":
                    param[0] = "";
                    if (_page != "") param[1] = "page=" + _page;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "search":
                    navigationData.XmlData = GenXmlFunctions.GetGenXml(rpSearch,"","");
                    navigationData.Save();
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "resetsearch":
                    // clear cookie info
                    navigationData.Delete();
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "unlockuser":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        clientData.UnlockUser();
                    }
                    param[0] = "uid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "deleteuser":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        clientData.DeleteUser();
                    }
                    param[0] = "uid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "removeuser":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        var ok = clientData.RemoveUser();
                        if (!ok)
                        {
                            NBrightBuyUtils.SetNotfiyMessage(ModuleId,"removeuser", NotifyCode.fail);
                            param[0] = "uid=" + cArg;
                        }
                    }
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "validateuser":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        clientData.AuthoriseClient();
                        clientData.AddClientRole(ModSettings);
                        if (StoreSettings.Current.Get("resetpasswordonclientvalidate") == "True") clientData.ResetPassword();
                    }
                    param[0] = "uid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "resetpass":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        clientData.ResetPassword();
                    }
                    param[0] = "uid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
                case "viewaddressbook":
                    param[0] = "";
                    if (Utils.IsNumeric(cArg))
                    {
                        param[0] = "ctrl=addressbook";
                        param[1] = "uid=" + cArg;
                    }
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
                case "vieworders":
                    param[0] = "";
                    if (Utils.IsNumeric(cArg))
                    {
                        param[0] = "ctrl=orders";
                        param[1] = "uid=" + cArg;
                    }
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
                case "createorder":
                    param[0] = "";
                    var tabId = TabId;
                    if (Utils.IsNumeric(cArg))
                    {
                        var cart = new CartData(PortalId);
                        cart.UserId = Convert.ToInt32(cArg);
                        cart.EditMode = "C";
                        cart.Save();
                        tabId = StoreSettings.Current.GetInt("productlisttab");
                        if (tabId==0) tabId = TabId;
                    }
                    Response.Redirect(NBrightBuyUtils.AdminUrl(tabId, param), true);
                    break;
                case "save":
                    if (Utils.IsNumeric(cArg))
                    {
                        var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                        if (clientData.Exists)
                        {
                            clientData.Update(rpData);
                            clientData.Save();
                        }
                    }
                    param[0] = "uid=" + cArg;
                    Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                    break;
            }
        }
Ejemplo n.º 28
0
        private void PageLoad()
        {
            #region "Data Repeater"
            if (_templD.Trim() != "")  // if we don;t have a template, don't do anything
            {
                if (UserId > 0) // only logged in users can see data on this module.
                {

                    if (_displayentrypage)
                    {
                        DisplayDataEntryRepeater(_entryid);
                    }
                    else
                    {
                        // check the display header to see if we have a sqlfilter defined.
                        var navigationData = new NavigationData(PortalId, "OrderAdmin");
                        var strFilter = navigationData.Criteria;
                        strFilter += " and UserId = " + UserId.ToString("") + " ";
                        //Default orderby if not set
                        var strOrder = " Order by ModifiedDate DESC  ";
                        rpData.DataSource = ModCtrl.GetList(PortalId, -1, "ORDER", strFilter, strOrder, 200);
                        rpData.DataBind();

                        // display header (Do header after the data return so the productcount works)
                        base.DoDetail(rpDataH);

                        // display search
                        base.DoDetail(rpSearch);
                    }
                }
            }

            #endregion

            // display footer
            base.DoDetail(rpDataF);
        }