public static Collection <TaxRate> GetTaxRates(Guid siteGuid, Guid geoZoneGuid) { Collection <TaxRate> taxRates = new Collection <TaxRate>(); using (IDataReader reader = DBTaxRate.GetTaxRates(siteGuid, geoZoneGuid)) { while (reader.Read()) { TaxRate taxRate = new TaxRate(siteGuid, geoZoneGuid); taxRate.guid = new Guid(reader["Guid"].ToString()); taxRate.description = reader["Description"].ToString(); taxRate.taxClassGuid = new Guid(reader["TaxClassGuid"].ToString()); taxRate.priority = Convert.ToInt32(reader["Priority"]); taxRate.rate = Convert.ToDecimal(reader["Rate"]); taxRates.Add(taxRate); } } return(taxRates); }
private static void LogHistory(Guid guid) { TaxRate previousVersion = new TaxRate(guid); if (previousVersion.Guid != Guid.Empty) { DBTaxRate.AddHistory( Guid.NewGuid(), previousVersion.Guid, previousVersion.siteGuid, previousVersion.GeoZoneGuid, previousVersion.TaxClassGuid, previousVersion.Priority, previousVersion.Rate, previousVersion.Description, previousVersion.Created, previousVersion.CreatedBy, previousVersion.LastModified, previousVersion.ModifiedBy, DateTime.UtcNow); } }
private void grdTaxRate_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridView grid = (GridView)sender; Guid guid = new Guid(grid.DataKeys[e.RowIndex].Value.ToString()); SiteUser siteUser = SiteUtils.GetCurrentSiteUser(); if (ddGeoZones.SelectedIndex > -1) { geoZoneGuid = new Guid(ddGeoZones.SelectedValue); } TextBox txtDescription = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtDescription"); DropDownList ddTaxClass = (DropDownList)grid.Rows[e.RowIndex].Cells[1].FindControl("ddTaxClass"); TextBox txtPriority = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtPriority"); TextBox txtRate = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtRate"); TaxRate taxRate; if (guid != Guid.Empty) { taxRate = new TaxRate(guid); } else { taxRate = new TaxRate(siteSettings.SiteGuid, geoZoneGuid); taxRate.Created = DateTime.UtcNow; taxRate.CreatedBy = siteUser.UserGuid; } taxRate.Description = txtDescription.Text; taxRate.GeoZoneGuid = geoZoneGuid; Guid taxClassGuid = new Guid(ddTaxClass.SelectedValue); taxRate.TaxClassGuid = taxClassGuid; int priority; if (!int.TryParse(txtPriority.Text, out priority)) { priority = 1; } taxRate.Priority = priority; decimal rate; if (!decimal.TryParse(txtRate.Text, out rate)) { rate = 0; } taxRate.Rate = rate; taxRate.LastModified = DateTime.UtcNow; taxRate.ModifiedBy = siteUser.UserGuid; taxRate.Save(); WebUtils.SetupRedirect(this, GetRefreshUrl()); }
private void grdTaxRate_RowEditing(object sender, GridViewEditEventArgs e) { if (ddGeoZones.SelectedIndex > -1) { geoZoneGuid = new Guid(ddGeoZones.SelectedValue); } GridView grid = (GridView)sender; grid.EditIndex = e.NewEditIndex; Guid guid = new Guid(grid.DataKeys[grid.EditIndex].Value.ToString()); BindGrid(); Button btnDelete = (Button)grid.Rows[e.NewEditIndex].Cells[0].FindControl("btnGridDelete"); if (btnDelete != null) { btnDelete.Attributes.Add("OnClick", "return confirm('" + Resource.TaxRateGridDeleteWarning + "');"); } DropDownList ddTaxClass = (DropDownList)grid.Rows[grid.EditIndex].Cells[0].FindControl("ddTaxClass"); if (ddTaxClass != null) { using (IDataReader reader = TaxClass.GetBySite(siteSettings.SiteGuid)) { ddTaxClass.DataSource = reader; ddTaxClass.DataBind(); } if (guid != Guid.Empty) { TaxRate taxRate = new TaxRate(guid); ListItem listItem = ddTaxClass.Items.FindByValue(taxRate.TaxClassGuid.ToString()); if (listItem != null) { ddTaxClass.ClearSelection(); listItem.Selected = true; } } } ddCountry.Enabled = false; ddGeoZones.Enabled = false; }
public static Collection<TaxRate> GetTaxRates(Guid siteGuid, Guid geoZoneGuid) { Collection<TaxRate> taxRates = new Collection<TaxRate>(); using (IDataReader reader = DBTaxRate.GetTaxRates(siteGuid, geoZoneGuid)) { while (reader.Read()) { TaxRate taxRate = new TaxRate(siteGuid, geoZoneGuid); taxRate.guid = new Guid(reader["Guid"].ToString()); taxRate.description = reader["Description"].ToString(); taxRate.taxClassGuid = new Guid(reader["TaxClassGuid"].ToString()); taxRate.priority = Convert.ToInt32(reader["Priority"]); taxRate.rate = Convert.ToDecimal(reader["Rate"]); taxRates.Add(taxRate); } } return taxRates; }