Exemple #1
0
        private void ShowAttendance(Occurrence occurrence)
        {
            cblAttendees.Items.Clear();

            if (occurrence != null)
            {
                dtDate.SelectedDate = occurrence.StartTime.Date;

                SqlDataReader rdr2 = occurrenceData.GetOccurrenceByID(occurrence.OccurrenceID);
                while (rdr2.Read())
                {
                    defaultHeadCount = Convert.ToInt32(rdr2["head_count"].ToString());
                    defaultNote      = rdr2["occurrence_description"].ToString();
                }
                rdr2.Close();

                tbHeadCount.Text = defaultHeadCount.ToString();
                tbNote.Text      = defaultNote;

                SqlDataReader rdr = occurrenceData.GetOccurrenceAttendanceByOccurrenceID(occurrence.OccurrenceID, -1);
                while (rdr.Read())
                {
                    ListItem li = new ListItem(rdr["person_name"].ToString(), rdr["person_id"].ToString());
                    li.Selected = (Boolean)rdr["attended"];
                    cblAttendees.Items.Add(li);
                }
                rdr.Close();

                if (ViewState["OccurrenceID"] != null)
                {
                    ViewState["OccurrenceID"] = occurrence.OccurrenceID;
                }
                else
                {
                    ViewState.Add("OccurrenceID", occurrence.OccurrenceID);
                }
            }
            else
            {
                dtDate.Text = string.Empty;

                if (group.Leader.PersonID != -1)
                {
                    cblAttendees.Items.Add(new ListItem(group.Leader.FullName, group.Leader.PersonID.ToString()));
                }

                foreach (GroupMember member in group.Members)
                {
                    if (member.Active)
                    {
                        cblAttendees.Items.Add(new ListItem(member.FullName, member.PersonID.ToString()));
                    }
                }

                if (ViewState["OccurrenceID"] != null)
                {
                    ViewState.Remove("OccurrenceID");
                }
            }
        }
        private void ShowAttendance()
        {
            lMtgDate.Text  = groupDate.ToLongDateString();
            lbNext.Visible = groupDate.AddDays(7) <= DateTime.Today;

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("person_id", typeof(Int32)));
            dt.Columns.Add(new DataColumn("person_name", typeof(string)));
            dt.Columns.Add(new DataColumn("attended", typeof(bool)));

            List <int> people = new List <int>();

            GroupOccurrence occurrence = FindOccurrenceByDate(group.Occurrences, groupDate);

            if (occurrence != null)
            {
                cbNoMeet.Checked = occurrence.OccurrenceClosed;

                SqlDataReader rdr = occurrenceData.GetOccurrenceAttendanceByOccurrenceID(occurrence.OccurrenceID, -1);
                while (rdr.Read())
                {
                    int personId = (int)rdr["person_id"];
                    people.Add(personId);

                    dt.Rows.Add(BuildAttendanceRow(dt,
                                                   personId,
                                                   rdr["person_name"].ToString(),
                                                   (bool)rdr["attended"]));
                }
                rdr.Close();
            }
            else
            {
                cbNoMeet.Checked = false;
            }

            if (group.Leader.PersonID != -1 && !people.Contains(group.Leader.PersonID))
            {
                dt.Rows.Add(BuildAttendanceRow(dt, group.Leader.PersonID, group.Leader.FullName, false));
            }

            foreach (GroupMember member in group.Members)
            {
                if (member.Active && !people.Contains(member.PersonID))
                {
                    dt.Rows.Add(BuildAttendanceRow(dt, member.PersonID, member.FullName, false));
                }
            }

            lvMembers.DataSource = dt;
            lvMembers.DataBind();

            ViewState["GroupDate"] = groupDate;
        }