Esempio n. 1
0
        private void SaveItem()
        {
            if (hfOccurrenceTypeAttributeID.Value == "-1")
            {
                occurrenceTypeAttribute = new OccurrenceTypeAttribute();
                occurrenceTypeAttribute.OccurrenceTypeId = Convert.ToInt32(ddlOccurrenceType.SelectedValue);
            }
            else
            {
                LoadItem(Convert.ToInt32(hfOccurrenceTypeAttributeID.Value));
            }

            occurrenceTypeAttribute.IsSpecialNeeds         = cbIsSpecialNeeds.Checked;
            occurrenceTypeAttribute.IsRoomBalancing        = cbIsRoomBalancing.Checked;
            occurrenceTypeAttribute.LastNameStartingLetter = txtLastnameStartingLetter.Text.ToUpper();
            occurrenceTypeAttribute.LastNameEndingLetter   = txtLastnameEndingLetter.Text.ToUpper();

            // get the set ability levels
            occurrenceTypeAttribute.AbilityLevelLookupIDs.Clear();
            foreach (ListItem item in dlbAbilityLevels.ListBoxRight.Items)
            {
                occurrenceTypeAttribute.AbilityLevelLookupIDs.Add(int.Parse(item.Value));
            }

            // save the object
            occurrenceTypeAttribute.Save(Page.User.Identity.Name);
        }
        public static List <Occurrence> SetupOccurrenceSearchRoomBalancing(ComputerSystem kiosk)
        {
            List <Occurrence> occurrences = SetupOccurrenceSearchMultipleOccurrences(kiosk);
            var attribute = new OccurrenceTypeAttribute
            {
                OccurrenceTypeId = occurrences.First().OccurrenceTypeID,
                IsRoomBalancing  = true
            };

            attribute.Save(CheckInTestConstants.USER_ID);

            var person = CheckInTestFactories.CreateFamilyMember();

            person.Save(CheckInTestConstants.ORG_ID, CheckInTestConstants.USER_ID, false);
            var attendance = new OccurrenceAttendance
            {
                OccurrenceID = occurrences.First().OccurrenceID,
                PersonID     = person.PersonID,
                Attended     = true,
                CheckInTime  = DateTime.Now.AddMinutes(-2)
            };

            attendance.Save(CheckInTestConstants.USER_ID);
            return(occurrences);
        }
Esempio n. 3
0
        private void BindAbilityLevelsToDoubleListBox(OccurrenceTypeAttribute ota)
        {
            LookupCollection allAbilityLevels       = new LookupCollection(Convert.ToInt32(LookupTypeIDSetting));
            LookupCollection availableAbilityLevels = new LookupCollection();
            LookupCollection selectedAbilityLevels  = new LookupCollection();

            foreach (Lookup abilityLevel in allAbilityLevels)
            {
                if (ota.AbilityLevelLookupIDs.Contains(abilityLevel.LookupID))
                {
                    selectedAbilityLevels.Add(abilityLevel);
                }
                else
                {
                    availableAbilityLevels.Add(abilityLevel);
                }
            }

            dlbAbilityLevels.ListBoxRight.DataSource     = selectedAbilityLevels;
            dlbAbilityLevels.ListBoxRight.DataTextField  = "Value";
            dlbAbilityLevels.ListBoxRight.DataValueField = "LookupID";
            dlbAbilityLevels.ListBoxRight.DataBind();

            dlbAbilityLevels.ListBoxLeft.DataSource     = availableAbilityLevels;
            dlbAbilityLevels.ListBoxLeft.DataTextField  = "Value";
            dlbAbilityLevels.ListBoxLeft.DataValueField = "LookupID";
            dlbAbilityLevels.ListBoxLeft.DataBind();
        }
Esempio 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();
        }
        public static Occurrence SetupOccurrenceSearchSpecialNeeds(ComputerSystem kiosk)
        {
            var occurrence = SetupOccurrenceSearch(kiosk);
            var attribute  = new OccurrenceTypeAttribute
            {
                IsSpecialNeeds   = true,
                OccurrenceTypeId = occurrence.OccurrenceTypeID
            };

            attribute.Save(CheckInTestConstants.USER_ID);
            return(occurrence);
        }
        public static Occurrence SetupOccurrenceSearchLastName(ComputerSystem kiosk)
        {
            var occurrence = SetupOccurrenceSearch(kiosk);
            var attribute  = new OccurrenceTypeAttribute
            {
                IsSpecialNeeds         = false,
                OccurrenceTypeId       = occurrence.OccurrenceTypeID,
                LastNameStartingLetter = "A",
                LastNameEndingLetter   = "L"
            };

            attribute.Save(CheckInTestConstants.USER_ID);
            return(occurrence);
        }
Esempio n. 7
0
        // Perform any custom actions on each row of datagrid
        private void dgList_ItemDataBound(object source, DataGridItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case ListItemType.Item:
            case ListItemType.AlternatingItem:
            {
                OccurrenceTypeAttribute dataItem = (OccurrenceTypeAttribute)e.Item.DataItem;
                // Change the OccurrenceType ID to its name
                if (dataItem.OccurrenceTypeAttributeId != Constants.NULL_INT)
                {
                    e.Item.Cells[1].Text = GetOccurrenceTypeName(dataItem.OccurrenceTypeId);
                }

                StringBuilder sb = new StringBuilder();
                foreach (int lookupID in dataItem.AbilityLevelLookupIDs)
                {
                    sb.Append(GetAbilityLevelName(lookupID) + seperator);
                }
                // clean off the trailing seperator
                if (sb.Length > 0)
                {
                    sb.Remove(sb.Length - seperator.Length, seperator.Length);
                }
                e.Item.Cells[2].Text = sb.ToString();

                // Hide the checkbox if Is Special Needs is not true
                if (!dataItem.IsSpecialNeeds)
                {
                    e.Item.Cells[3].Text = Constants.NULL_STRING;
                }

                // Hide the checkbox if Is Room Blancing is not true
                if (!dataItem.IsRoomBalancing)
                {
                    e.Item.Cells[4].Text = Constants.NULL_STRING;
                }

                break;
            }
            }
        }
        public static Occurrence SetupOccurrenceSearchAbilityLevel(ComputerSystem kiosk)
        {
            var occurrence = SetupOccurrenceSearch(kiosk);
            var attribute  = new OccurrenceTypeAttribute
            {
                IsSpecialNeeds   = true,
                OccurrenceTypeId = occurrence.OccurrenceTypeID
            };

            var abilityLevels = new LookupType(SystemGuids.ABILITY_LEVEL_LOOKUP_TYPE);
            var lookup        = (from al in abilityLevels.Values.OfType <Lookup>()
                                 orderby al.Order ascending
                                 select al).Last();

            attribute.AbilityLevelLookupIDs = new List <int> {
                lookup.LookupID
            };
            attribute.Save(CheckInTestConstants.USER_ID);
            return(occurrence);
        }
        /// <summary>
        /// Used to custom bind related stuff such as the OccurrenceTypeAttributes, locations, etc.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        private void dgList_ItemDataBound(object source, DataGridItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case ListItemType.Item:
            case ListItemType.AlternatingItem:
            {
                DataRowView dataItem         = (DataRowView)e.Item.DataItem;
                int         attendanceTypeID = (int)dataItem["occurrence_type_id"];
                CacheOTAs(attendanceTypeID);

                // set the start time column value(s)
                OccurrenceTypeTemplateCollection startTimes = new OccurrenceTypeTemplateCollection(attendanceTypeID);
                StringBuilder sb          = new StringBuilder();
                bool          matchTime   = false;
                bool          oneTimeFlag = false;
                foreach (OccurrenceTypeTemplate ott in startTimes)
                {
                    switch (ott.OccurrenceFreqType)
                    {
                    case OccurrenceFrequencyType.Daily:
                        sb.Append("* ");
                        sb.Append(ott.StartTime.ToShortTimeString() + seperator);
                        break;

                    case OccurrenceFrequencyType.Monthly:
                        sb.Append("/" + ott.FreqQualifier + "/ ");
                        sb.Append(ott.StartTime.ToShortTimeString() + seperator);
                        break;

                    case OccurrenceFrequencyType.OneTime:
                        oneTimeFlag = true;
                        DateTime ottDate = DateTime.Parse(ott.FreqQualifier);
                        if (DateTime.Now.AddDays(-1) <= ottDate && ottDate <= DateTime.Now.AddDays(7 * OneTimeWindowWeeks))
                        {
                            sb.Append(ott.FreqQualifier + " ");
                            sb.Append(ott.StartTime.ToShortTimeString() + seperator);
                        }
                        break;

                    case OccurrenceFrequencyType.Undefined:
                        sb.Append(ott.StartTime.ToShortTimeString() + seperator);
                        break;

                    case OccurrenceFrequencyType.Weekly:
                        sb.Append(Days[int.Parse(ott.FreqQualifier)] + " ");
                        sb.Append(ott.StartTime.ToShortTimeString() + seperator);
                        break;

                    default:
                        break;
                    }

                    // Filter by time if the filter is set
                    if (matchTime != true && ott.StartTime.ToShortTimeString() == timeFilter)
                    {
                        matchTime = true;
                    }

                    lblOneTimeFreqNotice.Visible = oneTimeFlag;
                }
                // clean off the trailing seperator
                if (sb.Length > 0)
                {
                    sb.Remove(sb.Length - seperator.Length, seperator.Length);
                }
                e.Item.Cells[2].Text = sb.ToString();

                // Filter by time if the FILTER IS SET and we did not find a matching time
                // above when we were looping through all the occurrence type templates
                if (!timeFilter.Equals(string.Empty) && !matchTime)
                {
                    e.Item.Visible = false;
                }
                else
                {
                    filteredList.Add(dataItem);
                }

                // set the age column value
                if ((decimal)dataItem["max_age"] != 0)
                {
                    e.Item.Cells[3].Text = String.Format("{0}-{1}", (decimal)dataItem["min_age"], (decimal)dataItem["max_age"]);
                }

                // set the grade column value
                if ((int)dataItem["min_grade"] != -1 && (int)dataItem["max_grade"] != -1)
                {
                    if ((int)dataItem["min_grade"] == (int)dataItem["max_grade"])
                    {
                        e.Item.Cells[4].Text = String.Format("{0}", (int)dataItem["min_grade"]).Replace('0', 'K');
                    }
                    else
                    {
                        e.Item.Cells[4].Text = String.Format("{0}-{1}", (int)dataItem["min_grade"], (int)dataItem["max_grade"]).Replace('0', 'K');
                    }
                }

                // set the extended, Attribute column values
                if (cachedOTAs.ContainsKey(attendanceTypeID))
                {
                    OccurrenceTypeAttribute ota = cachedOTAs[attendanceTypeID];

                    // set the Ability level column value
                    if (ota.AbilityLevelLookupIDs.Count == 0)
                    {
                        e.Item.Cells[5].Text = "";
                    }
                    else
                    {
                        sb = new StringBuilder();
                        foreach (int abilityLevelID in ota.AbilityLevelLookupIDs)
                        {
                            sb.Append(new Lookup(abilityLevelID, true) + seperator);
                        }
                        // clean off the trailing seperator
                        if (sb.Length > 0)
                        {
                            sb.Remove(sb.Length - seperator.Length, seperator.Length);
                        }

                        e.Item.Cells[5].Text = sb.ToString();
                    }

                    // set the Special Needs column value
                    if (!ota.IsSpecialNeeds)
                    {
                        e.Item.Cells[6].Text = "";
                    }

                    // set the lastname letter range
                    string lastNameRange = String.Format("{0}-{1}", ota.LastNameStartingLetter, ota.LastNameEndingLetter);
                    if (lastNameRange.Length > 1)
                    {
                        e.Item.Cells[8].Text = lastNameRange;
                    }
                    else
                    {
                        e.Item.Cells[8].Text = "";
                    }
                }
                else
                {
                    e.Item.Cells[6].Text = "";
                }

                // set the Gender preference column
                if ((int)dataItem["gender_preference"] != 2)
                {
                    e.Item.Cells[7].Text = (int)dataItem["gender_preference"] == 1 ? "F" : "M";
                }

                // set the Location/Rooms column value
                sb = new StringBuilder();
                LocationCollection locations = new LocationCollection();
                locations.LoadByOccurrenceTypeID(attendanceTypeID);
                foreach (Location location in locations)
                {
                    if (location.RoomClosed)
                    {
                        sb.Append("<del style='text-decoration: line-through; color: red;' title='closed'><span style='color:#000'>" + location.LocationName + "</span></del>" + seperator);
                    }
                    else
                    {
                        sb.Append(location.LocationName + seperator);
                    }
                }
                if (sb.Length > 0)
                {
                    sb.Remove(sb.Length - seperator.Length, seperator.Length);
                }

                e.Item.Cells[9].Text = sb.ToString();
                break;
            }
            }
        }
Esempio n. 10
0
 private void LoadItem(int occurrenceTypeAttributeID)
 {
     occurrenceTypeAttribute = new OccurrenceTypeAttribute(occurrenceTypeAttributeID);
 }
Esempio n. 11
0
 // Delete selected item
 void dgList_DeleteCommand(object source, DataGridCommandEventArgs e)
 {
     OccurrenceTypeAttribute.Delete(Int32.Parse(e.Item.Cells[0].Text));
     ShowList();
 }