/// <summary> /// Generates where condition for uniselector. /// </summary> protected override string GenerateWhereCondition() { CurrencyInfo main = CurrencyInfoProvider.GetMainCurrency(SiteID); int mainCurrencyId = (main != null) ? main.CurrencyID : 0; // Prepare where condition string where = ""; if (DisplayOnlyWithExchangeRate) { ExchangeTableInfo tableInfo = ExchangeTableInfoProvider.GetLastExchangeTableInfo(SiteID); if (tableInfo != null) { where = "(CurrencyID = " + mainCurrencyId + " OR CurrencyID IN (SELECT ExchangeRateToCurrencyID FROM COM_CurrencyExchangeRate WHERE COM_CurrencyExchangeRate.ExchangeTableID = " + tableInfo.ExchangeTableID + ") AND CurrencyEnabled = 1)"; } else { where = "(0=1)"; } } // Add site main currency when required if (AddSiteDefaultCurrency && (main != null)) { where = SqlHelper.AddWhereCondition(where, "CurrencyID = " + mainCurrencyId, "OR"); } // Exclude site main currency when required if (ExcludeSiteDefaultCurrency && (main != null)) { where = SqlHelper.AddWhereCondition(where, "(NOT CurrencyID = " + mainCurrencyId + ")"); } // Add base where condition return(SqlHelper.AddWhereCondition(where, base.GenerateWhereCondition())); }
/// <summary> /// Exclude main currency and currencies without exchange rate according selector settings. /// </summary> /// <param name="whereCondition">Where condition.</param> protected override string AppendExclusiveWhere(string whereCondition) { // Prepare where condition var where = new WhereCondition(whereCondition); if (DisplayOnlyWithExchangeRate) { var tableInfo = ExchangeTableInfoProvider.GetLastExchangeTableInfo(SiteID); if (tableInfo != null) { where.Where(w => w.WhereEquals("CurrencyID", MainCurrencyID) .Or() .WhereIn("CurrencyID", new IDQuery(ExchangeRateInfo.OBJECT_TYPE, "ExchangeRateToCurrencyID") .WhereEquals("ExchangeTableID", tableInfo.ExchangeTableID) .WhereTrue("CurrencyEnabled"))); } else { where.NoResults(); } } // Exclude site main currency when required if (ExcludeSiteDefaultCurrency && (MainCurrencyID > 0)) { where.WhereNotEquals("CurrencyID", MainCurrencyID); } // Restrict disabled or site not related currencies return(base.AppendExclusiveWhere(where.ToString(true))); }
/// <summary> /// Copies site-specific exchange rates from last valid global exchange table. /// </summary> protected void CopyFromGlobal() { CheckConfigurationModification(); ExchangeTableInfo globalTable = ExchangeTableInfoProvider.GetLastExchangeTableInfo(0); if (globalTable != null) { ExchangeRateInfoProvider.CopyExchangeRates(globalTable.ExchangeTableID, mExchangeTableId); } }
private void FindCurrentTableID() { mCurrentTableId = 0; // Get current table (it will be highlighted in the listing) ExchangeTableInfo eti = ExchangeTableInfoProvider.GetLastExchangeTableInfo(SiteID); if (eti != null) { mCurrentTableId = eti.ExchangeTableID; } }
protected void Page_Load(object sender, EventArgs e) { editGrid.RowDataBound += editGrid_RowDataBound; btnOk.Click += (s, args) => { Save(); }; // Get main currency mMainCurrency = CurrencyInfoProvider.GetMainCurrency(ConfiguredSiteID); rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname"); // Help image imgHelp.ImageUrl = GetImageUrl("General/HelpSmall.png"); imgHelp.ToolTip = GetString("ExchangeTable_Edit.ExchangeRateHelp"); imgHelpFromGlobal.ImageUrl = GetImageUrl("General/HelpSmall.png"); imgHelpFromGlobal.ToolTip = GetString("ExchangeTable_Edit.ExchangeRateHelp"); dtPickerExchangeTableValidFrom.SupportFolder = "~/CMSAdminControls/Calendar"; dtPickerExchangeTableValidTo.SupportFolder = "~/CMSAdminControls/Calendar"; string currentTableTitle = GetString("ExchangeTable_Edit.NewItemCaption"); // Get exchangeTable id from querystring mExchangeTableId = QueryHelper.GetInteger("exchangeid", 0); if (mExchangeTableId > 0) { exchangeTableObj = EditedObject as ExchangeTableInfo; if (exchangeTableObj != null) { // Check tables site id CheckEditedObjectSiteID(exchangeTableObj.ExchangeTableSiteID); // Set title currentTableTitle = exchangeTableObj.ExchangeTableDisplayName; LoadData(exchangeTableObj); // Fill editing form if (!RequestHelper.IsPostBack()) { // Show that the exchangeTable was created or updated successfully if (QueryHelper.GetString("saved", "") == "1") { // Show message ShowChangesSaved(); } } } // Init Copy from global link InitCopyFromGlobalLink(); } // Creating a new exchange table else { if (!RequestHelper.IsPostBack()) { // Preset valid from date ExchangeTableInfo tableInfo = ExchangeTableInfoProvider.GetLastExchangeTableInfo(ConfiguredSiteID); if (tableInfo != null) { dtPickerExchangeTableValidFrom.SelectedDateTime = tableInfo.ExchangeTableValidTo; } } // Grids are visible only in edit mode plcGrid.Visible = false; } // Initializes page title breadcrumbs control string[,] breadcrumbs = new string[2, 3]; breadcrumbs[0, 0] = GetString("ExchangeTable_Edit.ItemListLink"); breadcrumbs[0, 1] = "~/CMSModules/Ecommerce/Pages/Tools/Configuration/ExchangeRates/ExchangeTable_List.aspx?siteId=" + SiteID; breadcrumbs[0, 2] = ""; breadcrumbs[1, 0] = currentTableTitle; breadcrumbs[1, 1] = ""; breadcrumbs[1, 2] = ""; CurrentMaster.Title.Breadcrumbs = breadcrumbs; plcRateFromGlobal.Visible = IsFromGlobalRateNeeded(); // Check presence of main currency string currencyWarning = CheckMainCurrency(ConfiguredSiteID); if (!string.IsNullOrEmpty(currencyWarning)) { ShowWarning(currencyWarning, null, null); plcGrid.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { editGrid.RowDataBound += editGrid_RowDataBound; btnOk.Click += (s, args) => Save(); // Get main currency mMainCurrency = CurrencyInfoProvider.GetMainCurrency(ConfiguredSiteID); rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname"); // Help image iconHelpGlobalExchangeRate.ToolTip = GetString("ExchangeTable_Edit.ExchangeRateHelp"); iconHelpMainExchangeRate.ToolTip = GetString("ExchangeTable_Edit.ExchangeRateHelp"); // Use time zones for DateTimePickers CMS.Globalization.TimeZoneInfo tzi = TimeZoneHelper.GetTimeZoneInfo(MembershipContext.AuthenticatedUser, SiteContext.CurrentSite); dtPickerExchangeTableValidFrom.TimeZone = TimeZoneTypeEnum.Custom; dtPickerExchangeTableValidFrom.CustomTimeZone = tzi; dtPickerExchangeTableValidTo.TimeZone = TimeZoneTypeEnum.Custom; dtPickerExchangeTableValidTo.CustomTimeZone = tzi; // Get exchangeTable id from query string mExchangeTableId = QueryHelper.GetInteger("exchangeid", 0); if (mExchangeTableId > 0) { exchangeTableObj = EditedObject as ExchangeTableInfo; if (exchangeTableObj != null) { // Check tables site id CheckEditedObjectSiteID(exchangeTableObj.ExchangeTableSiteID); LoadData(exchangeTableObj); // Fill editing form if (!RequestHelper.IsPostBack()) { // Show that the exchangeTable was created or updated successfully if (QueryHelper.GetString("saved", "") == "1") { // Show message ShowChangesSaved(); } } } // Init Copy from global link InitCopyFromGlobalLink(); // Check presence of main currency plcGrid.Visible = CheckMainCurrency(ConfiguredSiteID); plcRateFromGlobal.Visible = IsFromGlobalRateNeeded(); } // Creating a new exchange table else { if (!RequestHelper.IsPostBack()) { // Preset valid from date ExchangeTableInfo tableInfo = ExchangeTableInfoProvider.GetLastExchangeTableInfo(ConfiguredSiteID); if (tableInfo != null) { dtPickerExchangeTableValidFrom.SelectedDateTime = tableInfo.ExchangeTableValidTo; } } // Grids are visible only in edit mode plcGrid.Visible = false; } // Register bootstrap tooltip over help icons ScriptHelper.RegisterBootstrapTooltip(Page, ".info-icon > i"); }
/// <summary> /// Inits the selector. /// </summary> protected void InitSelector() { if (this.RenderInline) { this.pnlUpdate.RenderMode = UpdatePanelRenderMode.Inline; } if (this.ShowAllItems) { this.uniSelector.MaxDisplayedItems = 1000; } this.uniSelector.EnabledColumnName = "CurrencyEnabled"; this.uniSelector.IsLiveSite = this.IsLiveSite; this.uniSelector.AllowEmpty = this.AddNoneRecord; if (DoFullPostback) { ControlsHelper.RegisterPostbackControl(this.uniSelector.DropDownSingleSelect); } if (AddSelectRecord) { string[,] fields = new string[1, 2]; fields[0, 0] = GetString("currencyselector.select"); fields[0, 1] = "-1"; this.uniSelector.SpecialFields = fields; } CurrencyInfo main = CurrencyInfoProvider.GetMainCurrency(this.SiteID); int mainCurrencyId = (main != null) ? main.CurrencyID : 0; string where = ""; if (DisplayOnlyWithExchangeRate) { ExchangeTableInfo tableInfo = ExchangeTableInfoProvider.GetLastExchangeTableInfo(this.SiteID); if (tableInfo != null) { where = "(CurrencyID = " + mainCurrencyId + " OR CurrencyID IN (SELECT ExchangeRateToCurrencyID FROM COM_CurrencyExchangeRate WHERE COM_CurrencyExchangeRate.ExchangeTableID = " + tableInfo.ExchangeTableID + ") AND CurrencyEnabled = 1)"; } else { where = "(0=1)"; } } if (this.AddSiteDefaultCurrency && (main != null)) { where = SqlHelperClass.AddWhereCondition(where, "CurrencyID = " + mainCurrencyId, "OR"); } if (this.ExcludeSiteDefaultCurrency && (main != null)) { where = SqlHelperClass.AddWhereCondition(where, "(NOT CurrencyID = " + mainCurrencyId + ")"); } // Select only records by speciffied site if (SiteID >= 0) { // Show global records by default int filteredSiteId = 0; // Check configuration when site specified if (SiteID > 0) { // Show site specific records when not using global statuses filteredSiteId = UsingGlobalObjects ? 0 : SiteID; } where = SqlHelperClass.AddWhereCondition(where, "(ISNULL(CurrencySiteID, 0) = " + filteredSiteId + ")"); } // Filter out only enabled items if (this.DisplayOnlyEnabled) { where = SqlHelperClass.AddWhereCondition(where, "CurrencyEnabled = 1"); } // Add items which have to be on the list (if any) string additionalList = SqlHelperClass.GetSafeQueryString(this.AdditionalItems, false); if ((!string.IsNullOrEmpty(where)) && (!string.IsNullOrEmpty(additionalList))) { where = SqlHelperClass.AddWhereCondition(where, "(CurrencyID IN (" + additionalList + "))", "OR"); } // Selected value (if any) must be on the list if ((!string.IsNullOrEmpty(where)) && (CurrencyID > 0) && (IncludeSelected)) { where = SqlHelperClass.AddWhereCondition(where, "(CurrencyID = " + CurrencyID + ")", "OR"); } // Set where condition this.uniSelector.WhereCondition = where; }
protected void Page_Load(object sender, EventArgs e) { editGrid.RowDataBound += new GridViewRowEventHandler(editGrid_RowDataBound); // Get main currency mMainCurrency = CurrencyInfoProvider.GetMainCurrency(this.ConfiguredSiteID); rfvDisplayName.ErrorMessage = GetString("general.requiresdisplayname"); // Control initializations lblExchangeTableValidFrom.Text = GetString("ExchangeTable_Edit.ExchangeTableValidFromLabel"); lblExchangeTableDisplayName.Text = GetString("ExchangeTable_Edit.ExchangeTableDisplayNameLabel"); lblExchangeTableValidTo.Text = GetString("ExchangeTable_Edit.ExchangeTableValidToLabel"); // Help image this.imgHelp.ImageUrl = GetImageUrl("General/HelpSmall.png"); this.imgHelp.ToolTip = GetString("ExchangeTable_Edit.ExchangeRateHelp"); this.imgHelpFromGlobal.ImageUrl = GetImageUrl("General/HelpSmall.png"); this.imgHelpFromGlobal.ToolTip = GetString("ExchangeTable_Edit.ExchangeRateHelp"); lblRates.Text = GetString("ExchangeTable_Edit.ExchangeRates"); btnOk.Text = GetString("General.OK"); dtPickerExchangeTableValidFrom.SupportFolder = "~/CMSAdminControls/Calendar"; dtPickerExchangeTableValidTo.SupportFolder = "~/CMSAdminControls/Calendar"; string currentTableTitle = GetString("ExchangeTable_Edit.NewItemCaption"); // Get exchangeTable id from querystring mExchangeTableId = QueryHelper.GetInteger("exchangeid", 0); if (mExchangeTableId > 0) { exchangeTableObj = ExchangeTableInfoProvider.GetExchangeTableInfo(mExchangeTableId); EditedObject = exchangeTableObj; if (exchangeTableObj != null) { // Check tables site id CheckEditedObjectSiteID(exchangeTableObj.ExchangeTableSiteID); // Set title currentTableTitle = exchangeTableObj.ExchangeTableDisplayName; LoadData(exchangeTableObj); // Fill editing form if (!RequestHelper.IsPostBack()) { // Show that the exchangeTable was created or updated successfully if (QueryHelper.GetString("saved", "") == "1") { lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); } } } this.CurrentMaster.Title.TitleText = GetString("ExchangeTable_Edit.HeaderCaption"); this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Ecommerce_ExchangeTable/object.png"); // Init Copy from global link InitCopyFromGlobalLink(); } // Creating a new exchange table else { if (!RequestHelper.IsPostBack()) { // Preset valid from date ExchangeTableInfo tableInfo = ExchangeTableInfoProvider.GetLastExchangeTableInfo(this.ConfiguredSiteID); if (tableInfo != null) { dtPickerExchangeTableValidFrom.SelectedDateTime = tableInfo.ExchangeTableValidTo; } } // Grids are visible only in edit mode plcGrid.Visible = false; this.CurrentMaster.Title.TitleText = GetString("ExchangeTable_New.HeaderCaption"); this.CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Ecommerce_ExchangeTable/new.png"); } // Initializes page title breadcrumbs control string[,] breadcrumbs = new string[2, 3]; breadcrumbs[0, 0] = GetString("ExchangeTable_Edit.ItemListLink"); breadcrumbs[0, 1] = "~/CMSModules/Ecommerce/Pages/Tools/Configuration/ExchangeRates/ExchangeTable_List.aspx?siteId=" + SiteID; breadcrumbs[0, 2] = ""; breadcrumbs[1, 0] = currentTableTitle; breadcrumbs[1, 1] = ""; breadcrumbs[1, 2] = ""; this.CurrentMaster.Title.Breadcrumbs = breadcrumbs; this.CurrentMaster.Title.HelpTopicName = "new_rateexchange_rate_edit"; this.CurrentMaster.Title.HelpName = "helpTopic"; plcRateFromGlobal.Visible = IsFromGlobalRateNeeded(); // Check presence of main currency string currencyErr = CheckMainCurrency(ConfiguredSiteID); if (!string.IsNullOrEmpty(currencyErr)) { // Show message lblNoMainCurrency.Text = currencyErr; plcNoMainCurrency.Visible = true; plcRates.Visible = false; } }