protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Utility u = new Utility(); Guid g1 = u.GetPersonIdfromRequest(Request); MessageList ml1 = new MessageList(); MessageGroupList mgl1 = new MessageGroupList(); Group group1 = new Group(); PupilDetails pupil1 = new PupilDetails(); MessageStudentList msl1 = new MessageStudentList(); PersonDetails p2 = new PersonDetails(g1.ToString()); ml1.LoadList_Person(g1, 20); bool first = true; string s = "<h4>Last 20 messages sent from " + p2.m_GivenName + " " + p2.m_Surname + "</h4>"; s += "<br><table border class=\"EventsTable\" >"; s += "<tr><th>Valid From</th><th>Message</th><th>To</th><th>Delivered</th></tr>"; foreach (Message m1 in ml1.m_list) { first = true; s += "<tr><td>" + m1.ValidFrom.ToShortDateString() + "</td><td>" + m1.Msg + "</td>"; //fi nd groups mgl1.LoadList_Message(m1.Id); foreach (MessageGroup mg1 in mgl1.m_list) { group1.Load(mg1.GroupId); if (!first) { s += "<tr><td></td><td></td>"; } s += "<td>" + group1._GroupCode + "</td>"; if (mg1.Delivered) { s += "<td>" + mg1.DateDelivered + "</td>"; } s += "</tr>"; first = false; } msl1.LoadList_Message(m1.Id); foreach (MessageStudent ms1 in msl1.m_list) { pupil1.Load(ms1.StudentId.ToString()); if (!first) { s += "<tr><td></td><td></td>"; } s += "<td>" + pupil1.m_GivenName + " " + pupil1.m_Surname + "</td>"; if (ms1.Delivered) { s += "<td>" + ms1.DateDelivered.ToString() + "</td>"; } s += "</tr>"; first = false; } } s += "</table>"; content0.InnerHtml = s; } }
private void DisplayGroupMSgG(Group gr1) { Table1.Visible = true; Table tb1 = (Table)form1.FindControl("table1"); tb1.Width = 400; tb1.EnableViewState = true; tb1.Controls.Clear(); TableRow r0 = new TableRow(); tb1.Controls.Add(r0); TableCell c01 = new TableCell(); r0.Controls.Add(c01); SetCellStyle(c01, tb1); c01.Text = "For"; TableCell c02 = new TableCell(); r0.Controls.Add(c02); SetCellStyle(c02, tb1); c02.Text = "From"; TableCell c03 = new TableCell(); r0.Controls.Add(c03); SetCellStyle(c03, tb1); c03.Text = "Message"; TableCell c04 = new TableCell(); r0.Controls.Add(c04); SetCellStyle(c04, tb1); c04.Text = "Deliv'd"; bool display = false; MessageGroupList mlg1 = new MessageGroupList(); mlg1.LoadList(gr1._GroupID); foreach (MessageGroup m1 in mlg1.m_list) { display = true; if (m1._Message.ValidFrom > DateTime.Now) { display = false; } if (m1._Message.ValidUntil < DateTime.Now) { display = false; } //so is valid.... if (!CheckBox1.Checked) { display = !m1.Delivered; //only display old msgs if checked.... } if (display) { TableRow r1 = new TableRow(); AddMsgRow(tb1, r1, m1.Id.ToString(), m1._Message, gr1._GroupCode, true, !m1.Delivered, m1.DateDelivered); } } MessageStudentList ml1 = new MessageStudentList(); ml1.LoadList_Group(gr1._GroupID, DateTime.Now); SimplePupil pupil1 = new SimplePupil(); foreach (MessageStudent m1 in ml1.m_list) { display = true; if (m1._Message.ValidFrom > DateTime.Now) { display = false; } if (m1._Message.ValidUntil < DateTime.Now) { display = false; } if (!CheckBox1.Checked) { display = !m1.Delivered; //only display old msgs if checked.... } if (display) { pupil1.Load(m1.StudentId); TableRow r1 = new TableRow(); AddMsgRow(tb1, r1, m1.Id.ToString(), m1._Message, pupil1.m_GivenName + " " + pupil1.m_Surname, false, !m1.Delivered, m1.DateDelivered); } } }