private void PopulateTaxClassList() { using (IDataReader reader = TaxClass.GetBySite(siteSettings.SiteGuid)) { ddTaxClassGuid.DataSource = reader; ddTaxClassGuid.DataBind(); } }
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; }
private void btnAddNew_Click(object sender, EventArgs e) { if (ddGeoZones.SelectedIndex > -1) { geoZoneGuid = new Guid(ddGeoZones.SelectedValue); } DataTable dataTable = new DataTable(); dataTable.Columns.Add("Guid", typeof(Guid)); dataTable.Columns.Add("SiteGuid", typeof(Guid)); dataTable.Columns.Add("GeoZoneGuid", typeof(Guid)); dataTable.Columns.Add("TaxClassGuid", typeof(Guid)); dataTable.Columns.Add("Priority", typeof(int)); dataTable.Columns.Add("Rate", typeof(decimal)); dataTable.Columns.Add("Description", typeof(string)); dataTable.Columns.Add("Created", typeof(DateTime)); dataTable.Columns.Add("CreatedBy", typeof(Guid)); dataTable.Columns.Add("LastModified", typeof(DateTime)); dataTable.Columns.Add("ModifiedBy", typeof(Guid)); DataRow row = dataTable.NewRow(); row["Guid"] = Guid.Empty; row["SiteGuid"] = siteSettings.SiteGuid; row["GeoZoneGuid"] = geoZoneGuid; row["TaxClassGuid"] = Guid.Empty; row["Priority"] = 1; row["Rate"] = 0; row["Description"] = string.Empty; row["Created"] = DateTime.UtcNow; row["CreatedBy"] = Guid.Empty; row["LastModified"] = DateTime.UtcNow; row["ModifiedBy"] = Guid.Empty; dataTable.Rows.Add(row); grdTaxRate.EditIndex = 0; grdTaxRate.DataSource = dataTable.DefaultView; grdTaxRate.DataBind(); btnAddNew.Visible = false; Button btnDelete = (Button)grdTaxRate.Rows[grdTaxRate.EditIndex].Cells[1].FindControl("btnGridDelete"); if (btnDelete != null) { btnDelete.Visible = false; } DropDownList ddTaxClass = (DropDownList)grdTaxRate.Rows[grdTaxRate.EditIndex].Cells[1].FindControl("ddTaxClass"); if (ddTaxClass != null) { using (IDataReader reader = TaxClass.GetBySite(siteSettings.SiteGuid)) { ddTaxClass.DataSource = reader; ddTaxClass.DataBind(); } if (ddTaxClass.Items.Count == 0) { TaxClass taxClass = new TaxClass(); taxClass.SiteGuid = siteSettings.SiteGuid; taxClass.Title = Resource.TaxClassTaxable; taxClass.Description = Resource.TaxClassTaxable; taxClass.Save(); taxClass = new TaxClass(); taxClass.SiteGuid = siteSettings.SiteGuid; taxClass.Title = Resource.TaxClassNotTaxable; taxClass.Description = Resource.TaxClassNotTaxable; taxClass.Save(); using (IDataReader reader = TaxClass.GetBySite(siteSettings.SiteGuid)) { ddTaxClass.DataSource = reader; ddTaxClass.DataBind(); } } } ddCountry.Enabled = false; ddGeoZones.Enabled = false; }