/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { CheckConfigurationModification(); string errorMessage = new Validator() .NotEmpty(txtTaxClassDisplayName.Text.Trim(), GetString("general.requiresdisplayname")) .NotEmpty(txtTaxClassName.Text.Trim(), GetString("general.requirescodename")).Result; if (!ValidationHelper.IsCodeName(txtTaxClassName.Text.Trim())) { errorMessage = GetString("General.ErrorCodeNameInIdentificatorFormat"); } if (errorMessage == "") { // TaxClassName must be unique TaxClassInfo taxClassObj = TaxClassInfoProvider.GetTaxClassInfo(txtTaxClassName.Text.Trim(), SiteInfoProvider.GetSiteName(ConfiguredSiteID)); // If taxClassName value is unique if ((taxClassObj == null) || (taxClassObj.TaxClassID == taxclassid)) { // If taxClassName value is unique -> determine whether it is update or insert if (taxClassObj == null) { // Get TaxClassInfo object by primary key taxClassObj = TaxClassInfoProvider.GetTaxClassInfo(taxclassid); } if (taxClassObj != null) { taxClassObj.TaxClassDisplayName = txtTaxClassDisplayName.Text.Trim(); taxClassObj.TaxClassName = txtTaxClassName.Text.Trim(); taxClassObj.TaxClassZeroIfIDSupplied = chkTaxZero.Checked; TaxClassInfoProvider.SetTaxClassInfo(taxClassObj); lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); } } else { lblError.Visible = true; lblError.Text = GetString("TaxClass_Edit.TaxClassNameExists"); } } else { lblError.Visible = true; lblError.Text = errorMessage; } }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { CheckConfigurationModification(); string errorMessage = new Validator() .NotEmpty(txtTaxClassDisplayName.Text.Trim(), GetString("general.requiresdisplayname")) .NotEmpty(txtTaxClassName.Text.Trim(), GetString("general.requirescodename")).Result; if (!ValidationHelper.IsCodeName(txtTaxClassName.Text.Trim())) { errorMessage = GetString("General.ErrorCodeNameInIdentificatorFormat"); } if (errorMessage == "") { TaxClassInfo taxClassObj = TaxClassInfoProvider.GetTaxClassInfo(txtTaxClassName.Text.Trim(), SiteInfoProvider.GetSiteName(ConfiguredSiteID)); if (taxClassObj == null) { // If taxClassName value is unique for configured site taxClassObj = new TaxClassInfo(); taxClassObj.TaxClassDisplayName = txtTaxClassDisplayName.Text.Trim(); taxClassObj.TaxClassName = txtTaxClassName.Text.Trim(); taxClassObj.TaxClassZeroIfIDSupplied = chkTaxZero.Checked; taxClassObj.TaxClassSiteID = ConfiguredSiteID; TaxClassInfoProvider.SetTaxClassInfo(taxClassObj); URLHelper.Redirect("TaxClass_Frameset.aspx?taxclassid=" + Convert.ToString(taxClassObj.TaxClassID) + "&saved=1&siteId=" + SiteID); } else { lblError.Visible = true; lblError.Text = GetString("TaxClass_Edit.TaxClassNameExists"); } } else { lblError.Visible = true; lblError.Text = errorMessage; } }