/// <summary>
        /// Bind a list of "start times" (OccurrenceTypeTemplate's StartTime values)
        /// for all the AttendanceTypes (OccurrenceTypes) for this group (Attendance Type Category).
        /// </summary>
        private void BindStartTimes()
        {
            OccurrenceTypeCollection         occurrenceTypes = new OccurrenceTypeCollection(groupID);
            OccurrenceTypeTemplateCollection frequencies;

            Dictionary <string, string> times = new Dictionary <string, string>();

            times.Add("*", string.Empty);

            foreach (OccurrenceType type in occurrenceTypes)
            {
                frequencies = new OccurrenceTypeTemplateCollection(type.OccurrenceTypeId);
                foreach (OccurrenceTypeTemplate frequency in frequencies)
                {
                    string time = frequency.StartTime.ToShortTimeString();

                    if (!times.ContainsKey(time))
                    {
                        times.Add(time, time);
                    }
                }
            }

            ddlStartTimes.DataSource = times;
            ddlStartTimes.DataBind();
        }
Ejemplo n.º 2
0
        public void ddlFilterTypeGroup_Changed(object sender, EventArgs e)
        {
            OccurrenceCollection oc;
            int 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)
            {
                OccurrenceTypeCollection otc = new OccurrenceTypeCollection(selectedValue);
                ArrayList dates = new ArrayList();

                foreach (OccurrenceType ot in otc)
                {
                    oc = new OccurrenceCollection(ot.OccurrenceTypeId);
                    foreach (Occurrence o in oc)
                    {
                        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()));
                }

                ddlFilterService.Enabled = true;
            }
            else
            {
                ddlFilterService.Enabled = false;
            }

            if (ddlFilterService.Items.Count > 0)
            {
                ddlFilterService.SelectedIndex = 0;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Return an OccurrenceTypeCollection for the selected group after
        /// removing all the Occurrence Types that already have an OccurrenceTypeAttribute
        /// </summary>
        /// <returns>an OccurrenceTypeCollection</returns>
        private OccurrenceTypeCollection GetAvailableOccurrenceTypes()
        {
            DataTable table = new OccurrenceTypeAttributeData().GetOccurrenceTypeAttributeByGroupId_DT(_groupID);

            Hashtable check = new Hashtable(table.Rows.Count);

            foreach (DataRow row in table.Rows)
            {
                if (row["occurrence_type_id"] != null)
                {
                    check.Add((int)row["occurrence_type_id"], true);
                }
            }

            // Now get all the occurrenceTypes and create a filtered list
            // of all the ones that do not already have an OccurrenceTypeAttribute
            OccurrenceTypeCollection types        = new OccurrenceTypeCollection(_groupID);
            OccurrenceTypeCollection listFiltered = new OccurrenceTypeCollection();

            foreach (OccurrenceType type in types)
            {
                if (!check.ContainsKey(type.OccurrenceTypeId))
                {
                    listFiltered.Add(type);
                }
            }

            return(listFiltered);
        }
Ejemplo n.º 4
0
        // Displays add/edit dialog for an item.
        protected void ShowEdit(int occurrenceTypeAttributeID)
        {
            pnlList.Visible = false;
            pnlEdit.Visible = true;

            if (occurrenceTypeAttributeID == -1)
            {
                OccurrenceTypeCollection availableOccurrenceTypes = GetAvailableOccurrenceTypes();
                // exit if there are no more available occurrence types
                // (we should never get here)
                if (availableOccurrenceTypes.Count == 0)
                {
                    return;
                }

                occurrenceTypeAttribute          = new OccurrenceTypeAttribute();
                ddlOccurrenceType.Visible        = true;
                ddlOccurrenceType.DataSource     = availableOccurrenceTypes;
                ddlOccurrenceType.DataTextField  = "TypeName";
                ddlOccurrenceType.DataValueField = "OccurrenceTypeId";
                ddlOccurrenceType.DataBind();
            }
            else
            {
                ddlOccurrenceType.Visible = false;
                LoadItem(occurrenceTypeAttributeID);
                lblOccurrenceType.Text = occurrenceTypes.FindByID(occurrenceTypeAttribute.OccurrenceTypeId).TypeName;
            }

            // If the new object returns -1 as the id, then that means it was not found in the database.
            // If -1 was passed into this function, then that means "add new".
            // If the new object returns -1 but we passed in an id other than -1, then that means it was not found in the database.
            if (occurrenceTypeAttributeID != -1 && occurrenceTypeAttribute.OccurrenceTypeAttributeId == -1)
            {
                lblErrorMessage.Text = string.Format("Could not find item with ID of {0}", occurrenceTypeAttributeID);
            }

            // Set defaults for add new
            if (occurrenceTypeAttribute.OccurrenceTypeAttributeId == Constants.NULL_INT)
            {
                InitEditForm();
            }
            // Prepopulate values from database (edit mode)
            else
            {
                hfOccurrenceTypeAttributeID.Value = occurrenceTypeAttribute.OccurrenceTypeAttributeId.ToString();
                cbIsSpecialNeeds.Checked          = occurrenceTypeAttribute.IsSpecialNeeds;
                cbIsRoomBalancing.Checked         = occurrenceTypeAttribute.IsRoomBalancing;
                txtLastnameStartingLetter.Text    = occurrenceTypeAttribute.LastNameStartingLetter;
                txtLastnameEndingLetter.Text      = occurrenceTypeAttribute.LastNameEndingLetter;
            }
            BindAbilityLevelsToDoubleListBox(occurrenceTypeAttribute);

            btnSave.Visible = _editEnabled;
            cbIsSpecialNeeds.Focus();
        }
Ejemplo n.º 5
0
        protected void Page_Init(object sender, EventArgs e)
        {
            dgList.AddItem       += dgList_AddItem;
            dgList.DeleteCommand += dgList_DeleteCommand;
            dgList.ReBind        += dgList_ReBind;
            dgList.ItemCommand   += dgList_ItemCommand;
            dgList.ItemDataBound += dgList_ItemDataBound;
            _groupID              = Request.QueryString["Group"] != null?Convert.ToInt32(Request.QueryString["Group"]) : -1;

            occurrenceTypes = new OccurrenceTypeCollection(_groupID);
        }
Ejemplo n.º 6
0
		private void BindOccurrenceTypes()
		{
			occurrence = new Occurrence( occurrenceID );
			OccurrenceType type = new OccurrenceType( occurrence.OccurrenceTypeID );
			OccurrenceTypeCollection types = new OccurrenceTypeCollection( type.GroupId );

			ddlOccurrenceTypes.DataSource = types;
			ddlOccurrenceTypes.DataBind();
			ddlOccurrenceTypes.Items.Insert (0, new ListItem("- select -", "-1"  ) );

			if ( Session[ SESS_LASTOCCTYPE ] != null )
			{
				int occurrenceTypeID = int.Parse( (string) Session[ SESS_LASTOCCTYPE ] );
				ddlOccurrenceTypes.SelectedValue = occurrenceTypeID.ToString();
				BindOccurrencesByType( occurrenceTypeID );
			}
		}
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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);
        }