private void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { // // Setup the data grid. // dgAttendance.ItemType = "Attendance Record"; dgAttendance.ItemBgColor = CurrentPortalPage.Setting("ItemBgColor", string.Empty, false); dgAttendance.ItemAltBgColor = CurrentPortalPage.Setting("ItemAltBgColor", string.Empty, false); dgAttendance.ItemMouseOverColor = CurrentPortalPage.Setting("ItemMouseOverColor", string.Empty, false); dgAttendance.AddEnabled = false; dgAttendance.MoveEnabled = false; dgAttendance.DeleteEnabled = false; dgAttendance.EditEnabled = false; dgAttendance.MergeEnabled = false; dgAttendance.MailEnabled = false; dgAttendance.ExportEnabled = true; dgAttendance.AllowSorting = true; dgAttendance.Columns[5].Visible = (AbilityLevelAttributeIDSetting != ""); // // Turn off either the regular name, or the hyperlink name. // if (PersonDetailPageID == -1) { dgAttendance.Columns[0].Visible = false; } else { dgAttendance.Columns[1].Visible = false; } // // Fill in the filter options. // OccurrenceTypeGroupCollection otgc = new OccurrenceTypeGroupCollection(CurrentOrganization.OrganizationID); foreach (OccurrenceTypeGroup otg in otgc) { ddlFilterTypeGroup.Items.Add(new ListItem(otg.GroupName, otg.GroupId.ToString())); } OccurrenceCollection oc = new OccurrenceCollection(DateTime.Now, DateTime.Now); if (this.Request.Params["groupID"] != null) { ddlFilterTypeGroup.SelectedValue = this.Request.Params["groupID"]; } else if (DefaultAttendanceGroupIDSetting != "") { ddlFilterTypeGroup.SelectedValue = DefaultAttendanceGroupIDSetting.ToString(); } else if (oc.Count > 0) { // // Find the first occurrence with an actual location. // foreach (Occurrence o in oc) { if (o.LocationID != -1) { ddlFilterTypeGroup.SelectedValue = new OccurrenceType(o.OccurrenceTypeID).GroupId.ToString(); break; } } } if (ddlFilterTypeGroup.SelectedValue == null || ddlFilterTypeGroup.SelectedValue == "") { ddlFilterTypeGroup.SelectedIndex = 0; } ddlFilterTypeGroup_Changed(null, null); btnFilterApply_Click(null, null); } }
public void ddlFilterTypeGroup_Changed(object sender, EventArgs e) { OccurrenceTypeCollection otc; OccurrenceCollection oc; DateTime bestDate = DateTime.MinValue, now = DateTime.Now; int matchIndex = 0, selectedValue = -1; // // Setup the basic occurrence list. // ddlFilterService.Items.Clear(); // // Determine current selection. // try { selectedValue = Convert.ToInt32(ddlFilterTypeGroup.SelectedValue); } catch { } // // Add in all valid choices. // if (selectedValue != -1) { otc = new OccurrenceTypeCollection(selectedValue); ArrayList dates = new ArrayList(); foreach (OccurrenceType ot in otc) { oc = new OccurrenceCollection(ot.OccurrenceTypeId); foreach (Occurrence o in oc) { if ((o.StartTime <= now && o.EndTime >= now) || (o.CheckInStart <= now && o.CheckInEnd >= now)) { bestDate = o.StartTime; } if (dates.Contains(o.StartTime) == false) { dates.Add(o.StartTime); } } } dates.Sort(); dates.Reverse(); foreach (DateTime dt in dates) { ddlFilterService.Items.Add(new ListItem(dt.ToString("ddd M/dd/yy h:mm tt"), dt.ToShortDateTimeString())); if (!IsPostBack && this.Request.Params["service"] != null) { if (dt.Equals(DateTime.Parse(this.Request.Params["service"])) == true) { matchIndex = (ddlFilterService.Items.Count - 1); } } else if (dt.Equals(bestDate) == true) { matchIndex = (ddlFilterService.Items.Count - 1); } } ddlFilterService.Enabled = true; } else { ddlFilterService.Enabled = false; } if (ddlFilterService.Items.Count > 0) { ddlFilterService.SelectedIndex = matchIndex; } ddlFilterService_Changed(null, null); }
public void ddlFilterService_Changed(object sender, EventArgs e) { OccurrenceTypeCollection otc; OccurrenceCollection oc; ArrayList locations = new ArrayList(), occurrences = new ArrayList(), types = new ArrayList(); DateTime selectedServiceTime; int idNumber; bool searchAvailable = true; // // Get the list of occurrence types from the selected group. // try { otc = new OccurrenceTypeCollection(Convert.ToInt32(ddlFilterTypeGroup.SelectedValue)); } catch { otc = new OccurrenceTypeCollection(); } // // Get the current selected service time. // try { selectedServiceTime = DateTime.Parse(ddlFilterService.SelectedValue); } catch { selectedServiceTime = DateTime.MinValue; } foreach (OccurrenceType ot in otc) { oc = new OccurrenceCollection(ot.OccurrenceTypeId); foreach (Occurrence o in oc) { if (o.StartTime.Equals(selectedServiceTime) == true) { occurrences.Add(o); if (locations.Contains(o.LocationID) == false) { locations.Add(o.LocationID); } if (types.Contains(o.OccurrenceTypeID) == false) { types.Add(o.OccurrenceTypeID); } } } } // // Setup the basic attendance type list. // ddlFilterType.Items.Clear(); ddlFilterType.Items.Add(new ListItem("Show All", "-1")); ddlFilterType.SelectedIndex = 0; ddlFilterType.Enabled = true; // // Setup the basic occurrence list. // ddlFilterOccurrence.Items.Clear(); ddlFilterOccurrence.Items.Add(new ListItem("Show All", "-1")); ddlFilterOccurrence.SelectedIndex = 0; ddlFilterOccurrence.Enabled = true; // // Setup the basic room list. // ddlFilterLocation.Items.Clear(); ddlFilterLocation.Items.Add(new ListItem("Show All", "-1")); ddlFilterLocation.SelectedIndex = 0; ddlFilterLocation.Enabled = true; // // Add in all valid types. // foreach (int typeID in types) { OccurrenceType ot = new OccurrenceType(typeID); ddlFilterType.Items.Add(new ListItem(ot.TypeName, ot.OccurrenceTypeId.ToString())); if (!IsPostBack && this.Request.Params["typeID"] != null) { if (typeID == Convert.ToInt32(this.Request.Params["typeID"])) { ddlFilterType.SelectedIndex = (ddlFilterType.Items.Count - 1); ddlFilterType_Changed(null, null); searchAvailable = false; } } } // // Add in all valid choices. // foreach (Occurrence o in occurrences) { OccurrenceType ot = new OccurrenceType(o.OccurrenceTypeID); Location l = new Location(o.LocationID); ddlFilterOccurrence.Items.Add(new ListItem(String.Format("{0} / {1} / {2}", o.Name, ot.TypeName, l.LocationName), o.OccurrenceID.ToString())); if (searchAvailable && !IsPostBack && Request.Params["occurrenceID"] != null) { idNumber = Convert.ToInt32(Request.Params["occurrenceID"]); if (idNumber == o.OccurrenceID) { ddlFilterOccurrence.SelectedIndex = (ddlFilterOccurrence.Items.Count - 1); ddlFilterOccurrence_Changed(null, null); searchAvailable = false; } } } // // Add all valid locations. // foreach (int locationID in locations) { Location l = new Location(locationID); ddlFilterLocation.Items.Add(new ListItem(String.Format("{0} - {1}", l.BuildingName, l.LocationName), l.LocationId.ToString())); if (searchAvailable && !IsPostBack && Request.Params["locationID"] != null) { idNumber = Convert.ToInt32(Request.Params["locationID"]); if (locationID == idNumber) { ddlFilterLocation.SelectedIndex = (ddlFilterLocation.Items.Count - 1); ddlFilterLocation_Changed(null, null); searchAvailable = false; } } } dgAttendance_ReBind(null, null); }
private void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { // // Setup the data grid. // dgOccurrence.ItemType = "Occurrence"; dgOccurrence.ItemBgColor = CurrentPortalPage.Setting("ItemBgColor", string.Empty, false); dgOccurrence.ItemAltBgColor = CurrentPortalPage.Setting("ItemAltBgColor", string.Empty, false); dgOccurrence.ItemMouseOverColor = CurrentPortalPage.Setting("ItemMouseOverColor", string.Empty, false); dgOccurrence.AddEnabled = false; dgOccurrence.MoveEnabled = false; dgOccurrence.DeleteEnabled = false; dgOccurrence.EditEnabled = false; dgOccurrence.MergeEnabled = false; dgOccurrence.MailEnabled = false; dgOccurrence.ExportEnabled = true; dgOccurrence.AllowSorting = true; dgOccurrence.Columns[kOccurrenceNameColumn].Visible = (AttendanceDetailPageID == -1); dgOccurrence.Columns[kOccurrenceNameLinkColumn].Visible = (AttendanceDetailPageID != -1); dgOccurrence.Columns[kOccurrenceTypeColumn].Visible = (AttendanceDetailPageID == -1); dgOccurrence.Columns[kOccurrenceTypeLinkColumn].Visible = (AttendanceDetailPageID != -1); // // Setup the data grid. // dgLocation.ItemType = "Location"; dgLocation.ItemBgColor = CurrentPortalPage.Setting("ItemBgColor", string.Empty, false); dgLocation.ItemAltBgColor = CurrentPortalPage.Setting("ItemAltBgColor", string.Empty, false); dgLocation.ItemMouseOverColor = CurrentPortalPage.Setting("ItemMouseOverColor", string.Empty, false); dgLocation.AddEnabled = false; dgLocation.MoveEnabled = false; dgLocation.DeleteEnabled = false; dgLocation.EditEnabled = false; dgLocation.MergeEnabled = false; dgLocation.MailEnabled = false; dgLocation.ExportEnabled = true; dgLocation.AllowSorting = true; dgLocation.Columns[kLocationLocationColumn].Visible = (AttendanceDetailPageID == -1); dgLocation.Columns[kLocationLocationLinkColumn].Visible = (AttendanceDetailPageID != -1); // // Fill in the filter options. // OccurrenceTypeGroupCollection otgc = new OccurrenceTypeGroupCollection(CurrentOrganization.OrganizationID); foreach (OccurrenceTypeGroup otg in otgc) { ddlFilterTypeGroup.Items.Add(new ListItem(otg.GroupName, otg.GroupId.ToString())); } OccurrenceCollection oc = new OccurrenceCollection(DateTime.Now, DateTime.Now); if (DefaultAttendanceGroupIDSetting != "") { ddlFilterTypeGroup.SelectedValue = DefaultAttendanceGroupIDSetting.ToString(); } else if (oc.Count > 0) { // // Find the first occurrence with an actual location. // foreach (Occurrence o in oc) { if (o.LocationID != -1) { ddlFilterTypeGroup.SelectedValue = new OccurrenceType(o.OccurrenceTypeID).GroupId.ToString(); break; } } } if (ddlFilterTypeGroup.SelectedValue == null || ddlFilterTypeGroup.SelectedValue == "") { ddlFilterTypeGroup.SelectedIndex = 0; } ddlFilterTypeGroup_Changed(null, null); btnFilterApply_Click(null, null); // // Setup options on the finalize close button. // lbCloseFinish.Style.Add("text-decoration", "none"); lbCloseFinish.Attributes.Add("onmouseover", "this.style.textDecoration='underline';"); lbCloseFinish.Attributes.Add("onmouseout", "this.style.textDecoration='none';"); } dgClose_Bind(); }