internal static string ToApiValue(this TaxRuleType value) { switch (value) { case TaxRuleType.Tax: return(value.ToString().ToUpperInvariant()); case TaxRuleType.NoTax: return("NO_TAX"); default: return(value.ToString().ToUpperInvariant()); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { bool status = false; if (ddlRuleTypes.SelectedValue == "0") // Promotions { if (!CheckAssemblyClass(typeof(ZNodePromotionOption))) return; DiscountType entity = new DiscountType(); if(_ItemId > 0) entity = _RuleTypeAdmin.GetDiscountTypeById(_ItemId); entity.Name = txtRuleName.Text.Trim(); entity.ClassName = txtRuleClassName.Text.Trim(); entity.Description = txtRuleDesc.Text.Trim(); entity.ActiveInd = chkEnable.Checked; if (_ItemId > 0) status = _RuleTypeAdmin.UpdateDicountType(entity); else status = _RuleTypeAdmin.AddDicountType(entity); } else if (ddlRuleTypes.SelectedValue == "1") // Shipping { if (!CheckAssemblyClass(typeof(ZNodeShippingOption))) return; ShippingType shipType = new ShippingType(); if (_ItemId > 0) shipType = _RuleTypeAdmin.GetShippingTypeById(_ItemId); shipType.Name = txtRuleName.Text.Trim(); shipType.Description = txtRuleDesc.Text.Trim(); shipType.ClassName = txtRuleClassName.Text.Trim(); shipType.IsActive = chkEnable.Checked; if (_ItemId > 0) status = _RuleTypeAdmin.UpdateShippingType(shipType); else status = _RuleTypeAdmin.AddShippingType(shipType); } else if (ddlRuleTypes.SelectedValue == "2") // Taxes { if (!CheckAssemblyClass(typeof(ZNodeTaxOption))) return; TaxRuleType taxRuleType = new TaxRuleType(); if (_ItemId > 0) taxRuleType = _RuleTypeAdmin.GetTaxRuleTypeById(_ItemId); taxRuleType.Name = txtRuleName.Text.Trim(); taxRuleType.Description = txtRuleDesc.Text.Trim(); taxRuleType.ClassName = txtRuleClassName.Text.Trim(); taxRuleType.ActiveInd = chkEnable.Checked; if (_ItemId > 0) status = _RuleTypeAdmin.UpdateTaxRuleType(taxRuleType); else status = _RuleTypeAdmin.AddTaxRuleType(taxRuleType); } else if (ddlRuleTypes.SelectedValue == "3") // supplier { if (!CheckAssemblyClass(typeof(ZNodeSupplierOption))) return; SupplierType supplierType = new SupplierType(); if (_ItemId > 0) supplierType = _RuleTypeAdmin.GetSupplierTypeById(_ItemId); supplierType.Name = txtRuleName.Text.Trim(); supplierType.Description = txtRuleDesc.Text.Trim(); supplierType.ClassName = txtRuleClassName.Text.Trim(); supplierType.ActiveInd = chkEnable.Checked; if (_ItemId > 0) status = _RuleTypeAdmin.UpdateSupplierType(supplierType); else status = _RuleTypeAdmin.AddSupplierType(supplierType); } if (status) { Response.Redirect(RedirectUrl); } else { lblErrorMsg.Text = "Unable to process your request. Please try again."; } }