/// <summary> /// Handles clicking of the save button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { if (Editing) { //Update if (UpdateExistingCustomerLevel()) { ctrlAlertMessage.PushAlertMessage(AppLogic.GetString("admin.customer.level.UpdateSuccessful", SkinID, ThisCustomer.LocaleSetting), AlertMessage.AlertType.Success); } else { ctrlAlertMessage.PushAlertMessage(AppLogic.GetString("admin.customer.level.UpdateFailed", SkinID, ThisCustomer.LocaleSetting), AlertMessage.AlertType.Error); } } else { var temporaryCustomerLevelID = SaveNewCustomerLevel(); //Insert if (temporaryCustomerLevelID > 0) { CustomerLevelID = temporaryCustomerLevelID; ViewState["CustomerLevelID"] = CustomerLevelID; ctrlAlertMessage.PushAlertMessage(AppLogic.GetString("admin.customer.level.SaveNewSuccessful", SkinID, ThisCustomer.LocaleSetting), AlertMessage.AlertType.Success); } else { ctrlAlertMessage.PushAlertMessage(AppLogic.GetString("admin.customer.level.SaveNewFailed", SkinID, ThisCustomer.LocaleSetting), AlertMessage.AlertType.Error); } } SetPageValues(); NameLocaleField.BindData(); }
protected bool SaveShippingMethod() { bool saved = true; try { if (!Editing) { // ok to add: ShippingMethodGuid = new Guid(DB.GetNewGUID()); using (var updateCommand = CreateUpdateCommand()) { DB.ExecuteSQL(updateCommand); ShippingMethodID = (int)updateCommand.Parameters["@ID"].Value; } ViewState["ShippingMethodID"] = ShippingMethodID; } else { // ok to update: using (var updateCommand = CreateUpdateCommand()) { updateCommand.Parameters["@ID"].Value = ShippingMethodID; DB.ExecuteSQL(updateCommand); } } // for the store mapping if (ShippingMethodStoreFilteringEnabled) { DB.ExecuteSQL("DELETE ShippingMethodStore WHERE ShippingMethodId = @shippingMethodId", new[] { new SqlParameter("@shippingMethodId", ShippingMethodID) }); foreach (ListItem item in MappedStores.Items) { if (item.Selected) { DB.ExecuteSQL("INSERT INTO ShippingMethodStore(StoreId, ShippingMethodId) Values(@storeId, @shippingMethodId)", new[] { new SqlParameter("@storeId", item.Value), new SqlParameter("@shippingMethodId", ShippingMethodID), }); } } } BindPage(); NameLocaleField.BindData(); DisplayNameLocaleField.BindData(); AlertMessage.PushAlertMessage("Updated", AspDotNetStorefrontControls.AlertMessage.AlertType.Success); } catch (Exception exception) { AlertMessage.PushAlertMessage(exception.Message, AspDotNetStorefrontControls.AlertMessage.AlertType.Error); saved = false; } return(saved); }