private String GetProductListData(Dictionary<String, String> settings,bool paging = true) { var strOut = ""; if (!settings.ContainsKey("header")) settings.Add("header", ""); if (!settings.ContainsKey("body")) settings.Add("body", ""); if (!settings.ContainsKey("footer")) settings.Add("footer", ""); if (!settings.ContainsKey("filter")) settings.Add("filter", ""); if (!settings.ContainsKey("orderby")) settings.Add("orderby", ""); if (!settings.ContainsKey("returnlimit")) settings.Add("returnlimit", "0"); if (!settings.ContainsKey("pagenumber")) settings.Add("pagenumber", "0"); if (!settings.ContainsKey("pagesize")) settings.Add("pagesize", "0"); if (!settings.ContainsKey("searchtext")) settings.Add("searchtext", ""); if (!settings.ContainsKey("searchcategory")) settings.Add("searchcategory", ""); if (!settings.ContainsKey("cascade")) settings.Add("cascade", "False"); var header = settings["header"]; var body = settings["body"]; var footer = settings["footer"]; var filter = settings["filter"]; var orderby = settings["orderby"]; var returnLimit = Convert.ToInt32(settings["returnlimit"]); var pageNumber = Convert.ToInt32(settings["pagenumber"]); var pageSize = Convert.ToInt32(settings["pagesize"]); var cascade = Convert.ToBoolean(settings["cascade"]); var searchText = settings["searchtext"]; var searchCategory = settings["searchcategory"]; if (searchText != "") filter += " and (NB3.[ProductName] like '%" + searchText + "%' or NB3.[ProductRef] like '%" + searchText + "%' or NB3.[Summary] like '%" + searchText + "%' ) "; if (Utils.IsNumeric(searchCategory)) { if (orderby == "{bycategoryproduct}") orderby += searchCategory; var objQual = DataProvider.Instance().ObjectQualifier; var dbOwner = DataProvider.Instance().DatabaseOwner; if (!cascade) filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") "; else filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where (typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") or (typecode = 'CATCASCADE' and XrefItemId = " + searchCategory + ")) "; } else { if (orderby == "{bycategoryproduct}") orderby = " order by NB3.productname "; } var recordCount = 0; var themeFolder = StoreSettings.Current.ThemeFolder; if (settings.ContainsKey("themefolder")) themeFolder = settings["themefolder"]; var templCtrl = NBrightBuyUtils.GetTemplateGetter(themeFolder); if (!settings.ContainsKey("portalid")) settings.Add("portalid", PortalSettings.Current.PortalId.ToString("")); // aways make sure we have portalid in settings var objCtrl = new NBrightBuyController(); var headerTempl = templCtrl.GetTemplateData(header, _lang, true, true, true, StoreSettings.Current.Settings()); var bodyTempl = templCtrl.GetTemplateData(body, _lang, true, true, true, StoreSettings.Current.Settings()); var footerTempl = templCtrl.GetTemplateData(footer, _lang, true, true, true, StoreSettings.Current.Settings()); // replace any settings tokens (This is used to place the form data into the SQL) headerTempl = Utils.ReplaceSettingTokens(headerTempl, settings); headerTempl = Utils.ReplaceUrlTokens(headerTempl); bodyTempl = Utils.ReplaceSettingTokens(bodyTempl, settings); bodyTempl = Utils.ReplaceUrlTokens(bodyTempl); footerTempl = Utils.ReplaceSettingTokens(footerTempl, settings); footerTempl = Utils.ReplaceUrlTokens(footerTempl); var obj = new NBrightInfo(true); strOut = GenXmlFunctions.RenderRepeater(obj, headerTempl); if (paging) // get record count for paging { if (pageNumber == 0) pageNumber = 1; if (pageSize == 0) pageSize = StoreSettings.Current.GetInt("pagesize"); recordCount = objCtrl.GetListCount(PortalSettings.Current.PortalId, -1, "PRD", filter,"PRDLANG",_lang); } var objList = objCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "PRD", "PRDLANG", _lang, filter, orderby, StoreSettings.Current.DebugMode,"",returnLimit,pageNumber,pageSize,recordCount); strOut += GenXmlFunctions.RenderRepeater(objList, bodyTempl); strOut += GenXmlFunctions.RenderRepeater(obj, footerTempl); // add paging if needed if (paging) { var pg = new NBrightCore.controls.PagingCtrl(); strOut += pg.RenderPager(recordCount, pageSize, pageNumber); } return strOut; }
private String GetData(HttpContext context, bool clearCache = false) { var objCtrl = new NBrightBuyController(); var strOut = ""; //get uploaded params var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context); var itemid = ajaxInfo.GetXmlProperty("genxml/hidden/itemid"); var typeCode = ajaxInfo.GetXmlProperty("genxml/hidden/typecode"); var newitem = ajaxInfo.GetXmlProperty("genxml/hidden/newitem"); var selecteditemid = ajaxInfo.GetXmlProperty("genxml/hidden/selecteditemid"); var moduleid = ajaxInfo.GetXmlProperty("genxml/hidden/moduleid"); var editlang = ajaxInfo.GetXmlProperty("genxml/hidden/editlang"); if (editlang == "") { editlang = Utils.GetCurrentCulture(); } var rundisplay = ajaxInfo.GetXmlPropertyBool("genxml/hidden/rundisplay"); if (!Utils.IsNumeric(moduleid)) { moduleid = "-2"; // use moduleid -2 for razor } if (clearCache) { NBrightBuyUtils.RemoveModCache(Convert.ToInt32(moduleid)); } if (newitem == "new") { selecteditemid = AddNew(moduleid, typeCode); } var templateControl = "/DesktopModules/NBright/OS_Reports"; if (Utils.IsNumeric(selecteditemid)) { // do edit field data if a itemid has been selected var obj = objCtrl.Get(Convert.ToInt32(selecteditemid), "", editlang); if (rundisplay) { strOut = NBrightBuyUtils.RazorTemplRender("run.cshtml", Convert.ToInt32(moduleid), itemid + editlang + selecteditemid, obj, templateControl, "config", editlang, StoreSettings.Current.Settings()); } else { strOut = NBrightBuyUtils.RazorTemplRender("datafields.cshtml", Convert.ToInt32(moduleid), itemid + editlang + selecteditemid, obj, templateControl, "config", editlang, StoreSettings.Current.Settings()); } } else { var pagenumber = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagenumber"); var pagesize = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagesize"); if (pagenumber == 0) { pagenumber = 1; } if (pagesize == 0) { pagesize = 20; } var filter = ""; var searchText = ajaxInfo.GetXmlProperty("genxml/hidden/searchtext"); if (searchText != "") { filter += " and ( "; filter += " (([xmldata].value('(genxml/textbox/ref)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/lang/genxml/textbox/ref2)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " ) "; } // get only entity type required var recordcount = objCtrl.GetListCount(PortalSettings.Current.PortalId, -1, typeCode, filter); // Return list of items var l = objCtrl.GetDataList(PortalSettings.Current.PortalId, Convert.ToInt32(moduleid), typeCode, typeCode + "LANG", editlang, filter, " order by [XMLData].value('(genxml/textbox/ref)[1]','nvarchar(50)')", true, "", 0, pagenumber, pagesize, recordcount); strOut = NBrightBuyUtils.RazorTemplRenderList("datalist.cshtml", Convert.ToInt32(moduleid), "", l, templateControl, "config", editlang, StoreSettings.Current.Settings()); if (recordcount > pagesize) { var pg = new NBrightCore.controls.PagingCtrl(); strOut += pg.RenderPager(recordcount, pagesize, pagenumber); } } return(strOut); }
public static String ClientAdminList(HttpContext context) { try { if (NBrightBuyUtils.CheckManagerRights()) { var settings = NBrightBuyUtils.GetAjaxDictionary(context); var paging = true; if (UserController.Instance.GetCurrentUserInfo().UserID <= 0) { return(""); } var strOut = ""; if (!settings.ContainsKey("themefolder")) { settings.Add("themefolder", ""); } if (!settings.ContainsKey("userid")) { settings.Add("userid", "-1"); } if (!settings.ContainsKey("razortemplate")) { settings.Add("razortemplate", ""); } if (!settings.ContainsKey("returnlimit")) { settings.Add("returnlimit", "0"); } if (!settings.ContainsKey("pagenumber")) { settings.Add("pagenumber", "0"); } if (!settings.ContainsKey("pagesize")) { settings.Add("pagesize", "0"); } if (!settings.ContainsKey("searchtext")) { settings.Add("searchtext", ""); } if (!settings.ContainsKey("dtesearchdatefrom")) { settings.Add("dtesearchdatefrom", ""); } if (!settings.ContainsKey("dtesearchdateto")) { settings.Add("dtesearchdateto", ""); } if (!settings.ContainsKey("searchorderstatus")) { settings.Add("searchorderstatus", ""); } if (!settings.ContainsKey("portalid")) { settings.Add("portalid", PortalSettings.Current.PortalId.ToString("")); // aways make sure we have portalid in settings } if (!Utils.IsNumeric(settings["userid"])) { settings["pagenumber"] = "1"; } if (!Utils.IsNumeric(settings["pagenumber"])) { settings["pagenumber"] = "1"; } if (!Utils.IsNumeric(settings["pagesize"])) { settings["pagesize"] = "20"; } if (!Utils.IsNumeric(settings["returnlimit"])) { settings["returnlimit"] = "50"; } var themeFolder = settings["themefolder"]; var razortemplate = settings["razortemplate"]; var returnLimit = Convert.ToInt32(settings["returnlimit"]); var pageNumber = Convert.ToInt32(settings["pagenumber"]); var pageSize = Convert.ToInt32(settings["pagesize"]); var portalId = Convert.ToInt32(settings["portalid"]); var userid = settings["userid"]; var searchText = settings["searchtext"]; var recordCount = 0; if (themeFolder == "") { themeFolder = StoreSettings.Current.ThemeFolder; if (settings.ContainsKey("themefolder")) { themeFolder = settings["themefolder"]; } } var objCtrl = new NBrightBuyController(); if (paging) // get record count for paging { if (pageNumber == 0) { pageNumber = 1; } if (pageSize == 0) { pageSize = 20; } // get only entity type required recordCount = objCtrl.GetDnnUsersCount(portalId, "%" + searchText + "%"); } var list = objCtrl.GetDnnUsers(portalId, "%" + searchText + "%", 0, pageNumber, pageSize, recordCount); var passSettings = settings; foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement { if (passSettings.ContainsKey(s.Key)) { passSettings[s.Key] = s.Value; } else { passSettings.Add(s.Key, s.Value); } } strOut = NBrightBuyUtils.RazorTemplRenderList(razortemplate, 0, "", list, "/DesktopModules/NBright/NBrightBuy", themeFolder, Utils.GetCurrentCulture(), passSettings); // add paging if needed if (paging && (recordCount > pageSize)) { var pg = new NBrightCore.controls.PagingCtrl(); strOut += pg.RenderPager(recordCount, pageSize, pageNumber); } return(strOut); } return(""); } catch (Exception ex) { return(ex.ToString()); } }
private static String GetOrderListData(Dictionary <String, String> settings, bool paging = true) { if (UserController.Instance.GetCurrentUserInfo().UserID <= 0) { return(""); } var strOut = ""; if (!settings.ContainsKey("selecteduserid")) { settings.Add("selecteduserid", ""); } if (!settings.ContainsKey("themefolder")) { settings.Add("themefolder", ""); } if (!settings.ContainsKey("userid")) { settings.Add("userid", "-1"); } if (!settings.ContainsKey("razortemplate")) { settings.Add("razortemplate", ""); } if (!settings.ContainsKey("returnlimit")) { settings.Add("returnlimit", "0"); } if (!settings.ContainsKey("pagenumber")) { settings.Add("pagenumber", "0"); } if (!settings.ContainsKey("pagesize")) { settings.Add("pagesize", "0"); } if (!settings.ContainsKey("searchtext")) { settings.Add("searchtext", ""); } if (!settings.ContainsKey("dtesearchdatefrom")) { settings.Add("dtesearchdatefrom", ""); } if (!settings.ContainsKey("dtesearchdateto")) { settings.Add("dtesearchdateto", ""); } if (!settings.ContainsKey("searchorderstatus")) { settings.Add("searchorderstatus", ""); } if (!settings.ContainsKey("portalid")) { settings.Add("portalid", PortalSettings.Current.PortalId.ToString("")); // aways make sure we have portalid in settings } if (!Utils.IsNumeric(settings["userid"])) { settings["pagenumber"] = "1"; } if (!Utils.IsNumeric(settings["pagenumber"])) { settings["pagenumber"] = "1"; } if (!Utils.IsNumeric(settings["pagesize"])) { settings["pagesize"] = "20"; } if (!Utils.IsNumeric(settings["returnlimit"])) { settings["returnlimit"] = "50"; } var themeFolder = settings["themefolder"]; var razortemplate = settings["razortemplate"]; var returnLimit = Convert.ToInt32(settings["returnlimit"]); var pageNumber = Convert.ToInt32(settings["pagenumber"]); var pageSize = Convert.ToInt32(settings["pagesize"]); var portalId = Convert.ToInt32(settings["portalid"]); var userid = settings["userid"]; var selecteduserid = settings["selecteduserid"]; var searchText = settings["searchtext"]; var searchdatefrom = settings["dtesearchdatefrom"]; var searchdateto = settings["dtesearchdateto"]; var searchorderstatus = settings["searchorderstatus"]; var filter = ""; if (searchText != "") { filter += " and ( (([xmldata].value('(genxml/billaddress/genxml/textbox/firstname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/lastname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/unit)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/street)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/postalcode)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/email)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/firstname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/lastname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/unit)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/street)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/postalcode)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/email)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/productrefs)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/ordernumber)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai )) ) "; } if (Utils.IsNumeric(selecteduserid)) { filter += " and (NB1.UserId = " + selecteduserid + ") "; } if (searchdateto != "" && searchdatefrom != "") { filter += " and ( ([xmldata].value('(genxml/createddate)[1]', 'datetime') >= convert(datetime,'" + searchdatefrom + "') ) and ([xmldata].value('(genxml/createddate)[1]', 'datetime') <= convert(datetime,'" + searchdateto + "') ) ) "; } if (searchdateto == "" && searchdatefrom != "") { filter += " and ([xmldata].value('(genxml/createddate)[1]', 'datetime') >= convert(datetime,'" + searchdatefrom + "') ) "; } if (searchdateto != "" && searchdatefrom == "") { filter += " and ([xmldata].value('(genxml/createddate)[1]', 'datetime') <= convert(datetime,'" + searchdateto + "') ) "; } if (searchorderstatus != "") { filter += " and ([xmldata].value('(genxml/dropdownlist/orderstatus)[1]', 'nvarchar(max)') = '" + searchorderstatus + "') "; } // check for user or manager. if (!NBrightBuyUtils.CheckRights()) { filter += " and ( userid = " + UserController.Instance.GetCurrentUserInfo().UserID + ") "; } var recordCount = 0; if (themeFolder == "") { themeFolder = StoreSettings.Current.ThemeFolder; if (settings.ContainsKey("themefolder")) { themeFolder = settings["themefolder"]; } } var objCtrl = new NBrightBuyController(); if (paging) // get record count for paging { if (pageNumber == 0) { pageNumber = 1; } if (pageSize == 0) { pageSize = 20; } // get only entity type required recordCount = objCtrl.GetListCount(PortalSettings.Current.PortalId, -1, "ORDER", filter); } var orderby = " order by [XMLData].value('(genxml/createddate)[1]','datetime') DESC, ModifiedDate DESC "; var list = objCtrl.GetList(portalId, -1, "ORDER", filter, orderby, 0, pageNumber, pageSize, recordCount); var passSettings = settings; foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement { if (passSettings.ContainsKey(s.Key)) { passSettings[s.Key] = s.Value; } else { passSettings.Add(s.Key, s.Value); } } strOut = NBrightBuyUtils.RazorTemplRenderList(razortemplate, 0, "", list, "/DesktopModules/NBright/NBrightBuy", themeFolder, Utils.GetCurrentCulture(), passSettings); // add paging if needed if (paging && (recordCount > pageSize)) { var pg = new NBrightCore.controls.PagingCtrl(); strOut += pg.RenderPager(recordCount, pageSize, pageNumber); } return(strOut); }
private String GetData(HttpContext context, bool clearCache = false) { var objCtrl = new NBrightBuyController(); var strOut = ""; //get uploaded params var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context); var itemid = ajaxInfo.GetXmlProperty("genxml/hidden/itemid"); var typeCode = ajaxInfo.GetXmlProperty("genxml/hidden/typecode"); var newitem = ajaxInfo.GetXmlProperty("genxml/hidden/newitem"); var selecteditemid = ajaxInfo.GetXmlProperty("genxml/hidden/selecteditemid"); var moduleid = ajaxInfo.GetXmlProperty("genxml/hidden/moduleid"); var editlang = ajaxInfo.GetXmlProperty("genxml/hidden/editlang"); if (editlang == "") { editlang = Utils.GetCurrentCulture(); } if (!Utils.IsNumeric(moduleid)) { moduleid = "-2"; // use moduleid -2 for razor } if (clearCache) { NBrightBuyUtils.RemoveModCache(Convert.ToInt32(moduleid)); } if (newitem == "new") { selecteditemid = AddNew(moduleid, typeCode); } var templateControl = "/DesktopModules/NBright/OS_CartReview"; if (Utils.IsNumeric(selecteditemid)) { // do edit field data if a itemid has been selected var obj = objCtrl.Get(Convert.ToInt32(selecteditemid), "", editlang); var cartobj = new CartData(PortalSettings.Current.PortalId, "", obj.ItemID.ToString("")); strOut = NBrightBuyUtils.RazorTemplRender("datafields.cshtml", Convert.ToInt32(moduleid), itemid + editlang + selecteditemid, cartobj, templateControl, "config", editlang, StoreSettings.Current.Settings()); } else { var filter = ""; var searchText = ajaxInfo.GetXmlProperty("genxml/hidden/searchtext"); if (searchText != "") { filter += " and ( (([xmldata].value('(genxml/billaddress/genxml/textbox/firstname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/lastname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/unit)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/street)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/postalcode)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/email)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/firstname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/lastname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/unit)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/street)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/postalcode)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/email)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/productrefs)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/ordernumber)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai )) ) "; } var pagenumber = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagenumber"); var pagesize = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagesize"); if (pagenumber == 0) { pagenumber = 1; } if (pagesize == 0) { pagesize = 20; } // get only entity type required var recordcount = objCtrl.GetListCount(PortalSettings.Current.PortalId, -1, typeCode, filter); // Return list of items var l = objCtrl.GetList(PortalSettings.Current.PortalId, Convert.ToInt32(moduleid), typeCode, filter, " order by NB1.ModifiedDate DESC ", 0, pagenumber, pagesize, recordcount, editlang); strOut = NBrightBuyUtils.RazorTemplRenderList("datalist.cshtml", Convert.ToInt32(moduleid), editlang + pagenumber, l, templateControl, "config", editlang, StoreSettings.Current.Settings()); if (recordcount > pagesize) { var pg = new NBrightCore.controls.PagingCtrl(); strOut += pg.RenderPager(recordcount, pagesize, pagenumber); } } return(strOut); }
public static String RenderProductAdminList(List <NBrightInfo> list, NBrightInfo ajaxInfo, int recordCount) { try { if (NBrightBuyUtils.CheckRights()) { if (list == null) { return(""); } if (UserController.Instance.GetCurrentUserInfo().UserID <= 0) { return(""); } var strOut = ""; // select a specific entity data type for the product (used by plugins) var themeFolder = "config"; var pageNumber = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagenumber"); var pageSize = ajaxInfo.GetXmlPropertyInt("genxml/hidden/pagesize"); var razortemplate = ajaxInfo.GetXmlProperty("genxml/hidden/razortemplate"); var editlang = ajaxInfo.GetXmlProperty("genxml/hidden/editlang"); if (editlang == "") { editlang = Utils.GetCurrentCulture(); } var templateControl = "/DesktopModules/NBright/OS_BulkEdit"; bool paging = pageSize > 0; var passSettings = new Dictionary <string, string>(); foreach (var s in ajaxInfo.ToDictionary()) { passSettings.Add(s.Key, s.Value); } foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement { if (passSettings.ContainsKey(s.Key)) { passSettings[s.Key] = s.Value; } else { passSettings.Add(s.Key, s.Value); } } strOut = NBrightBuyUtils.RazorTemplRenderList(razortemplate, 0, "", list, templateControl, themeFolder, editlang, passSettings); // add paging if needed if (paging && (recordCount > pageSize)) { var pg = new NBrightCore.controls.PagingCtrl(); strOut += pg.RenderPager(recordCount, pageSize, pageNumber); } return(strOut); } return(""); } catch (Exception ex) { return(ex.ToString()); } }
private String GetOrderListData(Dictionary<String, String> settings, bool paging = true) { var strOut = ""; if (!settings.ContainsKey("themefolder")) settings.Add("themefolder", ""); if (!settings.ContainsKey("userid")) settings.Add("userid", "-1"); if (!settings.ContainsKey("razortemplate")) settings.Add("razortemplate", ""); if (!settings.ContainsKey("returnlimit")) settings.Add("returnlimit", "0"); if (!settings.ContainsKey("pagenumber")) settings.Add("pagenumber", "0"); if (!settings.ContainsKey("pagesize")) settings.Add("pagesize", "0"); if (!settings.ContainsKey("searchtext")) settings.Add("searchtext", ""); if (!settings.ContainsKey("dtesearchdatefrom")) settings.Add("dtesearchdatefrom", ""); if (!settings.ContainsKey("dtesearchdateto")) settings.Add("dtesearchdateto", ""); if (!settings.ContainsKey("searchorderstatus")) settings.Add("searchorderstatus", ""); if (!settings.ContainsKey("portalid")) settings.Add("portalid", PortalSettings.Current.PortalId.ToString("")); // aways make sure we have portalid in settings if (!Utils.IsNumeric(settings["userid"])) settings["pagenumber"] = "1"; if (!Utils.IsNumeric(settings["pagenumber"])) settings["pagenumber"] = "1"; if (!Utils.IsNumeric(settings["pagesize"])) settings["pagesize"] = "20"; if (!Utils.IsNumeric(settings["returnlimit"])) settings["returnlimit"] = "50"; var themeFolder = settings["themefolder"]; var razortemplate = settings["razortemplate"]; var returnLimit = Convert.ToInt32(settings["returnlimit"]); var pageNumber = Convert.ToInt32(settings["pagenumber"]); var pageSize = Convert.ToInt32(settings["pagesize"]); var portalId = Convert.ToInt32(settings["portalid"]); var userid = settings["userid"]; var searchText = settings["searchtext"]; var searchdatefrom = settings["dtesearchdatefrom"]; var searchdateto = settings["dtesearchdateto"]; var searchorderstatus = settings["searchorderstatus"]; var filter = ""; if (searchText != "") { filter += " and ( (([xmldata].value('(genxml/billaddress/genxml/textbox/firstname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/lastname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/unit)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/street)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/postalcode)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/billaddress/genxml/textbox/email)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/firstname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/lastname)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/unit)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/street)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/postalcode)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/shipaddress/genxml/textbox/email)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/productrefs)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai ))"; filter += " or (([xmldata].value('(genxml/ordernumber)[1]', 'nvarchar(max)') like '%" + searchText + "%' collate sql_latin1_general_cp1_ci_ai )) ) "; } if (searchdateto != "" && searchdatefrom != "") { filter += " and ( ([xmldata].value('(genxml/createddate)[1]', 'datetime') >= convert(datetime,'" + searchdatefrom + "') ) and ([xmldata].value('(genxml/createddate)[1]', 'datetime') <= convert(datetime,'" + searchdateto + "') ) ) "; } if (searchdateto == "" && searchdatefrom != "") { filter += " and ([xmldata].value('(genxml/createddate)[1]', 'datetime') >= convert(datetime,'" + searchdatefrom + "') ) "; } if (searchdateto != "" && searchdatefrom == "") { filter += " and ([xmldata].value('(genxml/createddate)[1]', 'datetime') <= convert(datetime,'" + searchdateto + "') ) "; } if (searchorderstatus != "") { filter += " and ([xmldata].value('(genxml/dropdownlist/orderstatus)[1]', 'nvarchar(max)') = '" + searchorderstatus + "') "; } // check for user or manager. if (!NBrightBuyUtils.CheckRights()) { if (Utils.IsNumeric(userid) && UserController.Instance.GetCurrentUserInfo().UserID == Convert.ToInt32(userid)) { filter += " and ( userid = " + userid + ") "; } else { return ""; } } var recordCount = 0; if (themeFolder == "") { themeFolder = StoreSettings.Current.ThemeFolder; if (settings.ContainsKey("themefolder")) themeFolder = settings["themefolder"]; } var objCtrl = new NBrightBuyController(); if (paging) // get record count for paging { if (pageNumber == 0) pageNumber = 1; if (pageSize == 0) pageSize = 20; // get only entity type required recordCount = objCtrl.GetListCount(PortalSettings.Current.PortalId, -1, "ORDER", filter); } var orderby = " order by [XMLData].value('(genxml/createddate)[1]','nvarchar(20)') DESC, ModifiedDate DESC "; var list = objCtrl.GetList(portalId, -1, "ORDER", filter, orderby, 0, pageNumber, pageSize, recordCount); var passSettings = settings; foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement { if (passSettings.ContainsKey(s.Key)) passSettings[s.Key] = s.Value; else passSettings.Add(s.Key, s.Value); } strOut = NBrightBuyUtils.RazorTemplRenderList(razortemplate, 0, "", list, "/DesktopModules/NBright/NBrightBuy", themeFolder, _lang, passSettings); // add paging if needed if (paging && (recordCount > pageSize)) { var pg = new NBrightCore.controls.PagingCtrl(); strOut += pg.RenderPager(recordCount, pageSize, pageNumber); } return strOut; }
public static String ProductAdminList(Dictionary <string, string> settings, bool paging = true) { try { if (NBrightBuyUtils.CheckManagerRights()) { if (UserController.Instance.GetCurrentUserInfo().UserID <= 0) { return(""); } var strOut = ""; if (!settings.ContainsKey("themefolder")) { settings.Add("themefolder", ""); } if (!settings.ContainsKey("razortemplate")) { settings.Add("razortemplate", ""); } if (!settings.ContainsKey("header")) { settings.Add("header", ""); } if (!settings.ContainsKey("body")) { settings.Add("body", ""); } if (!settings.ContainsKey("footer")) { settings.Add("footer", ""); } if (!settings.ContainsKey("filter")) { settings.Add("filter", ""); } if (!settings.ContainsKey("orderby")) { settings.Add("orderby", ""); } if (!settings.ContainsKey("returnlimit")) { settings.Add("returnlimit", "0"); } if (!settings.ContainsKey("pagenumber")) { settings.Add("pagenumber", "0"); } if (!settings.ContainsKey("pagesize")) { settings.Add("pagesize", "0"); } if (!settings.ContainsKey("searchtext")) { settings.Add("searchtext", ""); } if (!settings.ContainsKey("searchcategory")) { settings.Add("searchcategory", ""); } if (!settings.ContainsKey("cascade")) { settings.Add("cascade", "False"); } if (!settings.ContainsKey("portalid")) { settings.Add("portalid", PortalSettings.Current.PortalId.ToString("")); // aways make sure we have portalid in settings } // select a specific entity data type for the product (used by plugins) if (!settings.ContainsKey("entitytypecode")) { settings.Add("entitytypecode", "PRD"); } if (!settings.ContainsKey("entitytypecodelang")) { settings.Add("entitytypecodelang", "PRDLANG"); } var entitytypecodelang = settings["entitytypecodelang"]; var entitytypecode = settings["entitytypecode"]; var themeFolder = settings["themefolder"]; var header = settings["header"]; var body = settings["body"]; var footer = settings["footer"]; var filter = settings["filter"]; var orderby = settings["orderby"]; var returnLimit = Convert.ToInt32(settings["returnlimit"]); var pageNumber = Convert.ToInt32(settings["pagenumber"]); var pageSize = Convert.ToInt32(settings["pagesize"]); var cascade = Convert.ToBoolean(settings["cascade"]); var razortemplate = settings["razortemplate"]; var portalId = Convert.ToInt32(settings["portalid"]); var searchText = settings["searchtext"]; var searchCategory = settings["searchcategory"]; if (searchText != "") { filter += " and (NB3.[ProductName] like '%" + searchText + "%' or NB3.[ProductRef] like '%" + searchText + "%' or NB3.[Summary] like '%" + searchText + "%' ) "; } if (Utils.IsNumeric(searchCategory)) { if (orderby == "{bycategoryproduct}") { orderby += searchCategory; } var objQual = DotNetNuke.Data.DataProvider.Instance().ObjectQualifier; var dbOwner = DotNetNuke.Data.DataProvider.Instance().DatabaseOwner; if (!cascade) { filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") "; } else { filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where (typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") or (typecode = 'CATCASCADE' and XrefItemId = " + searchCategory + ")) "; } } else { if (orderby == "{bycategoryproduct}") { orderby = " order by NB3.productname "; } } // logic for client list of products if (NBrightBuyUtils.IsClientOnly()) { filter += " and NB1.ItemId in (select ParentItemId from dbo.[NBrightBuy] as NBclient where NBclient.TypeCode = 'USERPRDXREF' and NBclient.UserId = " + UserController.Instance.GetCurrentUserInfo().UserID.ToString("") + ") "; } var recordCount = 0; if (themeFolder == "") { themeFolder = StoreSettings.Current.ThemeFolder; if (settings.ContainsKey("themefolder")) { themeFolder = settings["themefolder"]; } } var objCtrl = new NBrightBuyController(); if (paging) // get record count for paging { if (pageNumber == 0) { pageNumber = 1; } if (pageSize == 0) { pageSize = 20; } // get only entity type required recordCount = objCtrl.GetListCount(PortalSettings.Current.PortalId, -1, entitytypecode, filter, entitytypecodelang, Utils.GetCurrentCulture()); } // get selected entitytypecode. var list = objCtrl.GetDataList(PortalSettings.Current.PortalId, -1, entitytypecode, entitytypecodelang, Utils.GetCurrentCulture(), filter, orderby, StoreSettings.Current.DebugMode, "", returnLimit, pageNumber, pageSize, recordCount); var passSettings = settings; foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement { if (passSettings.ContainsKey(s.Key)) { passSettings[s.Key] = s.Value; } else { passSettings.Add(s.Key, s.Value); } } strOut = NBrightBuyUtils.RazorTemplRenderList(razortemplate, 0, "", list, "/DesktopModules/NBright/NBrightBuy", themeFolder, Utils.GetCurrentCulture(), passSettings); // add paging if needed if (paging && (recordCount > pageSize)) { var pg = new NBrightCore.controls.PagingCtrl(); strOut += pg.RenderPager(recordCount, pageSize, pageNumber); } return(strOut); } return(""); } catch (Exception ex) { return(ex.ToString()); } }