protected void Page_Load(object sender, EventArgs e) { _TaxRuleId = AlwaysConvert.ToInt(Request.QueryString["TaxRuleId"]); _TaxRule = TaxRuleDataSource.Load(_TaxRuleId); if (_TaxRule == null) { Response.Redirect("TaxRules.aspx"); } Caption.Text = string.Format(Caption.Text, _TaxRule.Name); if (!Page.IsPostBack) { Name.Text = _TaxRule.Name; foreach (ListItem taxCodeItem in this.TaxCodes.Items) { TaxCode taxCode = TaxCodeDataSource.Load(AlwaysConvert.ToInt(taxCodeItem.Value)); taxCodeItem.Selected = (_TaxRule.TaxCodes.IndexOf(taxCode) > -1); } TaxRate.Text = string.Format("{0:0.00##}", _TaxRule.TaxRate); ZoneRule.SelectedIndex = (_TaxRule.ShipZones.Count == 0) ? 0 : 1; foreach (ShipZone item in _TaxRule.ShipZones) { ListItem listItem = ZoneList.Items.FindByValue(item.Id.ToString()); if (listItem != null) { listItem.Selected = true; } } UseBillingAddress.SelectedIndex = _TaxRule.UseBillingAddress ? 1 : 0; GroupRule.SelectedIndex = _TaxRule.GroupRuleId; foreach (Group item in _TaxRule.Groups) { ListItem listItem = GroupList.Items.FindByValue(item.Id.ToString()); if (listItem != null) { listItem.Selected = true; } } ListItem selectedCode = TaxCode.Items.FindByValue(_TaxRule.TaxCodeId.ToString()); if (selectedCode != null) { selectedCode.Selected = true; } Priority.Text = _TaxRule.Priority.ToString(); ListItem roundingRuleItem = RoundingRule.Items.FindByValue(_TaxRule.RoundingRuleId.ToString()); if (roundingRuleItem != null) { RoundingRule.SelectedItem.Selected = false; roundingRuleItem.Selected = true; } PerUnitCalculation.Checked = _TaxRule.UsePerItemTax; } }
protected void Page_Load(object sender, EventArgs e) { _TaxCodeId = AlwaysConvert.ToInt(Request.QueryString["TaxCodeId"]); _TaxCode = TaxCodeDataSource.Load(_TaxCodeId); if (_TaxCode == null) { Response.Redirect("TaxCodes.aspx"); } if (!Page.IsPostBack) { Caption.Text = string.Format(Caption.Text, _TaxCode.Name); } }
protected void Page_Load(object sender, EventArgs e) { _TaxCodeId = AlwaysConvert.ToInt(Request.QueryString["TaxCodeId"]); _TaxCode = TaxCodeDataSource.Load(_TaxCodeId); if (_TaxCode == null) { Response.Redirect("Default.aspx"); } if (!Page.IsPostBack) { Caption.Text = string.Format(Caption.Text, _TaxCode.Name); } FindAssignProducts1.AssignmentValue = _TaxCodeId; FindAssignProducts1.OnAssignProduct += new AssignProductEventHandler(FindAssignProducts1_AssignProduct); FindAssignProducts1.OnLinkCheck += new AssignProductEventHandler(FindAssignProducts1_LinkCheck); FindAssignProducts1.OnCancel += new EventHandler(FindAssignProducts1_CancelButton); }
protected void TaxCodeGrid_RowUpdating(object sender, GridViewUpdateEventArgs e) { int taxCodeId = AlwaysConvert.ToInt(TaxCodeGrid.DataKeys[e.RowIndex].Value); TaxCode t = TaxCodeDataSource.Load(taxCodeId); TextBox Name = (TextBox)TaxCodeGrid.Rows[e.RowIndex].FindControl("Name"); if (t != null && Name != null) { // IF NAME IS CHANGED DUPLICATE TAX CODE NAMES SHOULD NOT BE ALLOWED if (t.Name != Name.Text) { ICriteria criteria = NHibernateHelper.CreateCriteria <TaxCode>() .Add(Restrictions.Like("Name", StringHelper.SafeSqlString(AddTaxCodeName.Text))); IList <TaxCode> tempCollection = TaxCodeDataSource.LoadForCriteria(criteria); if (tempCollection.Count > 0) { PlaceHolder phGridNameValidator = (PlaceHolder)TaxCodeGrid.Rows[e.RowIndex].FindControl("phGridNameValidator"); // TAX RULE(S) WITH SAME NAME ALREADY EXIST CustomValidator customNameValidator = new CustomValidator(); customNameValidator.ValidationGroup = "EditTaxRule"; customNameValidator.ControlToValidate = "Name"; customNameValidator.Text = "A Tax Code with the same name already exists."; customNameValidator.ErrorMessage = "A Tax Code with the same name already exists."; customNameValidator.IsValid = false; phGridNameValidator.Controls.Add(customNameValidator); e.Cancel = true; return; } } t.Name = Name.Text; t.Save(); } e.Cancel = true; TaxCodeGrid.EditIndex = -1; TaxCodeGrid.DataBind(); }
private void SaveShipMethodMatrix() { //UPDATE NAME _ShipMethod.Name = Name.Text; //UPDATE SHIP RATE UpdateRanges(); //UPDATE SURCHARGE _ShipMethod.Surcharge = AlwaysConvert.ToDecimal(Surcharge.Text); if (_ShipMethod.Surcharge < 0) { _ShipMethod.Surcharge = 0; } if (_ShipMethod.Surcharge > 0) { _ShipMethod.SurchargeMode = (SurchargeMode)AlwaysConvert.ToByte(SurchargeMode.SelectedValue); _ShipMethod.SurchargeIsVisible = (SurchargeIsVisible.SelectedIndex > 0); } else { _ShipMethod.SurchargeMode = 0; _ShipMethod.SurchargeIsVisible = false; } if (_ShipMethod.SurchargeIsVisible) { _ShipMethod.SurchargeTaxCodeId = AlwaysConvert.ToInt(SurchargeTaxCode.SelectedValue); } else { _ShipMethod.SurchargeTaxCodeId = 0; } //UPDATE WAREHOUSES _ShipMethod.Warehouses.Clear(); _ShipMethod.Save(); if (UseWarehouseRestriction.SelectedIndex > 0) { foreach (ListItem item in WarehouseList.Items) { Warehouse warehouse = WarehouseDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { _ShipMethod.Warehouses.Add(warehouse); } } } //UPDATE ZONES _ShipMethod.ShipZones.Clear(); _ShipMethod.Save(); if (UseZoneRestriction.SelectedIndex > 0) { foreach (ListItem item in ZoneList.Items) { ShipZone shipZone = ShipZoneDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { _ShipMethod.ShipZones.Add(shipZone); } } } //UPDATE ROLES _ShipMethod.Groups.Clear(); _ShipMethod.Save(); if (UseGroupRestriction.SelectedIndex > 0) { foreach (ListItem item in GroupList.Items) { CommerceBuilder.Users.Group group = GroupDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { _ShipMethod.Groups.Add(group); } } } //UPDATE MIN PURCHASE _ShipMethod.MinPurchase = AlwaysConvert.ToDecimal(MinPurchase.Text); //UPDATE MAX PURCHASE _ShipMethod.MaxPurchase = AlwaysConvert.ToDecimal(MaxPurchase.Text); //UPDATE TAX CODES _ShipMethod.TaxCode = TaxCodeDataSource.Load(AlwaysConvert.ToInt(TaxCode.SelectedValue)); //SAVE METHOD AND REDIRECT TO LIST _ShipMethod.Save(); }
protected void SaveButton_Click(object sender, EventArgs e) { if (Page.IsValid) { // DUPLICATE TAX RULE NAMES SHOULD NOT BE ALLOWED int taxRuleId = TaxRuleDataSource.GetTaxRuleIdByName(Name.Text); if (taxRuleId > 0) { // TAX RULE(S) WITH SAME NAME ALREADY EXIST CustomValidator customNameValidator = new CustomValidator(); customNameValidator.ControlToValidate = "Name"; customNameValidator.Text = "*"; customNameValidator.ErrorMessage = "A Tax Rule with the same name already exists."; customNameValidator.IsValid = false; phNameValidator.Controls.Add(customNameValidator); return; } //SAVE TAX RULE TaxRule taxRule = new TaxRule(); taxRule.Name = Name.Text; taxRule.TaxRate = AlwaysConvert.ToDecimal(TaxRate.Text); taxRule.UseBillingAddress = AlwaysConvert.ToBool(UseBillingAddress.SelectedValue.Equals("1"), false); taxRule.TaxCodeId = AlwaysConvert.ToInt(TaxCode.SelectedValue); taxRule.Priority = AlwaysConvert.ToInt16(Priority.Text); taxRule.UsePerItemTax = PerUnitCalculation.Checked; taxRule.Save(); //UPDATE TAX CODES taxRule.TaxCodes.Clear(); taxRule.Save(); foreach (ListItem listItem in TaxCodes.Items) { if (listItem.Selected) { TaxCode taxCode = TaxCodeDataSource.Load(AlwaysConvert.ToInt(listItem.Value)); taxRule.TaxCodes.Add(taxCode); listItem.Selected = false; } } //UPDATE ZONES taxRule.ShipZones.Clear(); if (ZoneRule.SelectedIndex > 0) { foreach (ListItem item in ZoneList.Items) { ShipZone shipZone = ShipZoneDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { taxRule.ShipZones.Add(shipZone); } } } //UPDATE GROUP FILTER taxRule.Groups.Clear(); taxRule.GroupRule = (FilterRule)GroupRule.SelectedIndex; if (taxRule.GroupRule != FilterRule.All) { foreach (ListItem item in GroupList.Items) { Group group = GroupDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { taxRule.Groups.Add(group); } } } //IF NO GROUPS ARE SELECTED, APPLY TO ALL GROUPS if (taxRule.Groups.Count == 0) { taxRule.GroupRule = FilterRule.All; } // UPDATE ROUNDING RULE taxRule.RoundingRuleId = AlwaysConvert.ToByte(RoundingRule.SelectedValue); taxRule.Save(); //UPDATE THE ADD MESSAGE Response.Redirect("TaxRules.aspx"); } }