private void SetGrid() { foreach (StaffMember staffMember in this._selectedStaff) { Row staffRow = this.Rows.AddAndReturn(this); Cell nameCell = new Cell(); nameCell.Id = this.SetCellValue(this._genericCellsCollection.StaffName.Id, staffMember.Id, null); nameCell.Type = CellTypes.HeaderSmall; nameCell.Href = this.SetCellValue(this._genericCellsCollection.StaffName.Href, staffMember.Id, null); nameCell.OnClick = this.SetCellValue(this._genericCellsCollection.StaffName.OnClick, staffMember.Id, null); //nameCell.Value = Utils.FormatStaffName(staffMember.Forename, staffMember.Surname, staffMember.HoldingName, true, true, true); UserManagement.StaffNameFormatter nameFormatter = new UserManagement.StaffNameFormatter(); nameFormatter.Forename = staffMember.Forename; nameFormatter.Surname = staffMember.Surname; nameFormatter.HoldingName = staffMember.HoldingName; nameFormatter.AbbreviateForename = true; nameFormatter.DisplayForenameFirst = true; nameFormatter.DisplaySmallHoldingName = true; nameFormatter.IsToolTip = false; nameCell.Value = nameFormatter.ToString(); nameCell.Parent = this; staffRow.Add(nameCell); for (int period = 1; period <= this._periods; period++) { try { DataRow record = this._periodsTable.Select("StaffId = " + staffMember.Id + " AND Period = " + period)[0]; switch (record["Status"].ToString().ToLower()) { case "unavailable": staffRow.Add(this.CreateCell(SummaryCellTypes.Unavailable, staffMember.Id, period)); break; case "absent": staffRow.Add(this.CreateCell(SummaryCellTypes.Absent, staffMember.Id, period)); break; case "presentisbusy": staffRow.Add(this.CreateCell(SummaryCellTypes.PresentIsBusy, staffMember.Id, period)); break; case "presentandfreeyeargroupaway": staffRow.Add(this.CreateCell(SummaryCellTypes.PresentAndFreeYeargroupAway, staffMember.Id, period)); break; } } catch (IndexOutOfRangeException) { staffRow.Add(this.CreateCell(SummaryCellTypes.PresentAndFree, staffMember.Id, period)); } } } }
protected override void GenerateOutput() { if (this.CheckInputValidity()) { Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.Int, "@WeekNo", this._timetableWeek); paramBuilder.AddParameter(SqlDbType.Int, "@DayNo", (int)(this._selectedDate.DayOfWeek + 1)); paramBuilder.AddParameter(SqlDbType.Int, "@MaxPeriods", this._periods); paramBuilder.AddParameter(SqlDbType.SmallDateTime, "@Date", this._selectedDate); if (this.Path.HasNext()) { paramBuilder.AddParameter(SqlDbType.VarChar, "@SearchTerm", this.Path.Next()); } else { paramBuilder.AddParameter(SqlDbType.VarChar, "@SearchTerm", ""); } using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Cover/Arrange/Attendance/Attendance/attendance.sql", paramBuilder.Parameters)) { if (dataReader.HasRows) { Core.Helpers.Elements.RecordLists.Collection collection = new Core.Helpers.Elements.RecordLists.Collection(); collection.Id = "Attendance"; int recordCount = 0; while (dataReader.Read()) { Core.Helpers.Elements.RecordLists.Record record = new Core.Helpers.Elements.RecordLists.Record(); int staffId = (int)dataReader["StaffId"]; UserManagement.StaffNameFormatter nameFormatter = new UserManagement.StaffNameFormatter(); nameFormatter.Forename = dataReader["Forename"] as string; nameFormatter.Surname = dataReader["Surname"] as string; nameFormatter.HoldingName = dataReader["HoldingName"] as string; int attendanceRecord = (int)dataReader["AttendanceRecord"]; record.Id = "Staff" + staffId.ToString(); if (attendanceRecord > 0) { record.Colour = Core.Helpers.Elements.RecordLists.Colours.Red; } record.LeftSide.MainText = nameFormatter.ToString(); nameFormatter.IsToolTip = true; record.LeftSide.SetImage("dude.png", nameFormatter.ToString()); record.OnClick = "getResponse('AttendanceStaff" + staffId + "', '?path=/cover/arrange/attendance/ajax/attendance/modify/" + this._selectedDate.Year.ToString() + "/" + this._selectedDate.Month.ToString() + "/" + this._selectedDate.Day.ToString() + "/" + staffId + "/', false, false, true); resetSearch('Periods');"; collection.Add(record); recordCount++; } if (Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage.ContainsKey("ArrangeAttendanceCount")) { Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage["ArrangeAttendanceCount"] = recordCount; } else { Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage.Add("ArrangeAttendanceCount", recordCount); } this.Page.Contents = collection.ToString(); } else { Core.Helpers.Elements.Alerts.Alert alert = new Core.Helpers.Elements.Alerts.Alert("NoResults"); alert.Colour = Core.Helpers.Elements.Alerts.Colours.Yellow; alert.NoScript = false; alert.ShowCloseBox = false; alert.StartHidden = false; alert.Message = new Core.Helpers.Constructor("/Alerts/Ajax/noresults.html").ToString(); this.Page.Contents = alert.ToString(); } } } else { Core.Helpers.Elements.Alerts.Alert alert = new Core.Helpers.Elements.Alerts.Alert("Error"); alert.Colour = Core.Helpers.Elements.Alerts.Colours.Red; alert.NoScript = false; alert.ShowCloseBox = false; alert.StartHidden = false; alert.Message = new Core.Helpers.Constructor("/Alerts/Ajax/error.html").ToString(); this.Page.Contents = alert.ToString(); } }