protected void btnSaveSelected_Click(object sender, EventArgs e) { string value = String.Empty; ArrayList regions = new ArrayList(); ArrayList locations = new ArrayList(); foreach (GridDataItem gdi in ((Telerik.WebControls.RadGrid)(LocationGrid)).Items) { if (((Telerik.WebControls.GridItem)(gdi)).HasChildItems) { foreach (GridDataItem gdiDetails in gdi.ChildItem.NestedTableViews[0].Items) { if (((System.Web.UI.WebControls.CheckBox)(gdiDetails.Cells[2].Controls[1])).Checked) { locations.Add(gdiDetails.Cells[4].Text); } } } if (((System.Web.UI.WebControls.CheckBox)(gdi.Cells[2].Controls[1])).Checked) { regions.Add(gdi.Cells[4].Text); } } Miami.Substitute.Bll.Preferred preferred = new Miami.Substitute.Bll.Preferred(); Miami.Substitute.Bll.Location location = new Miami.Substitute.Bll.Location(); preferred.DeleteForSubstitute(); for (int i = 0; i < locations.Count; i++) { int val = Convert.ToInt32(locations[i]); preferred.Insert(val); } for (int i = 0; i < regions.Count; i++) { int val = Convert.ToInt32(regions[i]); preferred.DeleteByRegion(val); DataView locs = location.LoadAllLocation(val); if (locs != null) { foreach (DataRowView dr in locs) { preferred.Insert(Convert.ToInt32(dr["LocationId"])); } } } Response.Redirect("Default.aspx"); }
protected void CheckChanged(Object sender, System.EventArgs e) { ((sender as CheckBox).Parent.Parent as GridItem).Selected = true; if (LocationGrid.SelectedValue != null) { Miami.Substitute.Bll.Preferred preferred = new Miami.Substitute.Bll.Preferred(); if (((CheckBox)sender).Checked) { if ((((sender as CheckBox).Parent.Parent as GridItem)).OwnerTableView.DataKeyNames[0] == "RegionId") { Miami.Substitute.Bll.Location location = new Miami.Substitute.Bll.Location(); DataView locs = location.LoadAllLocation(Convert.ToInt16(LocationGrid.SelectedValue)); preferred.DeleteByRegion(Convert.ToInt16(LocationGrid.SelectedValue)); foreach (DataRowView dr in locs) { preferred.Insert(Convert.ToInt32(dr["LocationId"])); } LocationGrid.DataBind(); } else { preferred.Insert(Convert.ToInt32(LocationGrid.SelectedValue)); } } else { if ((((sender as CheckBox).Parent.Parent as GridItem)).OwnerTableView.DataKeyNames[0] == "RegionId") { Miami.Substitute.Bll.Location location = new Miami.Substitute.Bll.Location(); preferred.DeleteByRegion(Convert.ToInt16(LocationGrid.SelectedValue)); LocationGrid.DataBind(); } else { preferred.Delete(Convert.ToInt32(LocationGrid.SelectedValue)); } } } }
protected void btnSaveSelected_Click(object sender, EventArgs e) { string value = String.Empty; ArrayList regions = new ArrayList(); ArrayList locations = new ArrayList(); foreach (GridDataItem gdi in ((Telerik.WebControls.RadGrid)(LocationGrid)).Items) { if (((Telerik.WebControls.GridItem)(gdi)).HasChildItems) foreach (GridDataItem gdiDetails in gdi.ChildItem.NestedTableViews[0].Items) { if (((System.Web.UI.WebControls.CheckBox)(gdiDetails.Cells[2].Controls[1])).Checked) locations.Add(gdiDetails.Cells[4].Text); } if (((System.Web.UI.WebControls.CheckBox)(gdi.Cells[2].Controls[1])).Checked) regions.Add(gdi.Cells[4].Text); } Miami.Substitute.Bll.Preferred preferred = new Miami.Substitute.Bll.Preferred(); Miami.Substitute.Bll.Location location = new Miami.Substitute.Bll.Location(); preferred.DeleteForSubstitute(); for (int i = 0; i < locations.Count; i++) { int val = Convert.ToInt32(locations[i]); preferred.Insert(val); } for (int i = 0; i < regions.Count; i++) { int val = Convert.ToInt32(regions[i]); preferred.DeleteByRegion(val); DataView locs = location.LoadAllLocation(val); if (locs != null) foreach (DataRowView dr in locs) preferred.Insert(Convert.ToInt32(dr["LocationId"])); } Response.Redirect("Default.aspx"); }
protected void CheckChanged(Object sender, System.EventArgs e) { ((sender as CheckBox).Parent.Parent as GridItem).Selected = true; if (LocationGrid.SelectedValue != null) { Miami.Substitute.Bll.Preferred preferred = new Miami.Substitute.Bll.Preferred(); if (((CheckBox)sender).Checked) { if ((((sender as CheckBox).Parent.Parent as GridItem)).OwnerTableView.DataKeyNames[0] == "RegionId") { Miami.Substitute.Bll.Location location = new Miami.Substitute.Bll.Location(); DataView locs = location.LoadAllLocation(Convert.ToInt16(LocationGrid.SelectedValue)); preferred.DeleteByRegion(Convert.ToInt16(LocationGrid.SelectedValue)); foreach (DataRowView dr in locs) preferred.Insert(Convert.ToInt32(dr["LocationId"])); LocationGrid.DataBind(); } else preferred.Insert(Convert.ToInt32(LocationGrid.SelectedValue)); } else { if ((((sender as CheckBox).Parent.Parent as GridItem)).OwnerTableView.DataKeyNames[0] == "RegionId") { Miami.Substitute.Bll.Location location = new Miami.Substitute.Bll.Location(); preferred.DeleteByRegion(Convert.ToInt16(LocationGrid.SelectedValue)); LocationGrid.DataBind(); } else preferred.Delete(Convert.ToInt32(LocationGrid.SelectedValue)); } } }