protected void Page_Load(object sender, System.EventArgs e) { try { Controller = new BBStoreController(); LocaleController lc = new LocaleController(); Dictionary <string, Locale> loc = lc.GetLocales(PortalId); ModuleController objModules = new ModuleController(); // If this is the first visit to the page if (Page.IsPostBack == false) { UnitInfo unit = null; if (Request["unitid"] != null) { UnitId = Convert.ToInt32(Request["unitid"]); } // if unit exists if (UnitId > 0) { unit = Controller.GetUnit(UnitId); } List <ILanguageEditorInfo> dbLangs = new List <ILanguageEditorInfo>(); if (unit == null) { txtDecimals.Text = "0"; foreach (KeyValuePair <string, Locale> keyValuePair in loc) { UnitLangInfo unitLang = new UnitLangInfo(); unitLang.Language = keyValuePair.Key; dbLangs.Add(unitLang); } } else { txtDecimals.Text = unit.Decimals.ToString(); foreach (UnitLangInfo unitLang in Controller.GetUnitLangs(UnitId)) { dbLangs.Add(unitLang); } } lngUnits.Langs = dbLangs; } } catch (Exception exc) { //Module failed to load Exceptions.ProcessModuleLoadException(this, exc); } }
protected void cmdUpdate_Click(object sender, EventArgs e) { try { // First lets save the product UnitInfo unit = null; bool isNew = false; if (UnitId >= 0) { unit = Controller.GetUnit(UnitId); } else { isNew = true; } if (unit != null) { unit.Decimals = Convert.ToInt32(txtDecimals.Text); Controller.UpdateUnit(unit); } else { unit = new UnitInfo(); unit.PortalId = PortalId; unit.Decimals = Convert.ToInt32(txtDecimals.Text); UnitId = Controller.NewUnit(unit); } // Now lets update Language information lngUnits.UpdateLangs(); Controller.DeleteUnitLangs(UnitId); foreach (UnitLangInfo ul in lngUnits.Langs) { ul.UnitId = UnitId; Controller.NewUnitLang(ul); } List <string> addParams = new List <string>(); if (Request["adminmode"] != null) { addParams.Add("adminmode=unitlist"); } addParams.Add("unitId=" + UnitId.ToString()); Response.Redirect(Globals.NavigateURL(TabId, "", addParams.ToArray()), true); } catch (Exception exc) { //Module failed to load Exceptions.ProcessModuleLoadException(this, exc); } }