private bool CheckStaffId() { int readAttempt; if (this.Path.HasNext()) if (int.TryParse(this.Path.Next(), out readAttempt)) { Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.Int, "@StaffId", readAttempt); using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Staff/Modify/Teaching/existscheck.sql", paramBuilder.Parameters)) { if (dataReader.HasRows) { dataReader.Read(); this._staffId = (int)dataReader["StaffId"]; this._entitlement = (int)dataReader["Entitlement"]; this._name = new StaffNameFormatter(); this._name.Title = dataReader["Title"] as string; this._name.Forename = dataReader["Forename"] as string; this._name.Surname = dataReader["Surname"] as string; this._name.HoldingName = dataReader["HoldingName"] as string; this._hasAccount = (bool)dataReader["HasAccount"]; this._isAdmin = (bool)dataReader["IsAdmin"]; this._isActive = (bool)dataReader["IsActive"]; this._username = dataReader["Username"] as string; return true; } } } return false; }
private void DoUpdate() { Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.Int, "@StaffId", this._staffId); paramBuilder.AddParameter(SqlDbType.VarChar, "@Title", this._name.Title); paramBuilder.AddParameter(SqlDbType.VarChar, "@Forename", this._name.Forename); paramBuilder.AddParameter(SqlDbType.VarChar, "@Surname", this._name.Surname); paramBuilder.AddParameter(SqlDbType.VarChar, "@HoldingName", this._name.HoldingName); using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Staff/Modify/Update/Teaching/name.sql", paramBuilder.Parameters)) { dataReader.Read(); if ((bool)dataReader["Status"]) { if (Core.WebServer.PleaseTakes.Session.CurrentInstance.Account.IsTeachingAccount) { UserManagement.Accounts.TeachingAccount account = (UserManagement.Accounts.TeachingAccount)Core.WebServer.PleaseTakes.Session.CurrentInstance.Account; if (account.StaffId.Equals(this._staffId)) { account.Title = this._name.Title; account.Forename = this._name.Forename; account.Surname = this._name.Surname; account.HoldingName = this._name.HoldingName; } } Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/" + this._staffId + "/namesuccess/"); } else { Core.WebServer.PleaseTakes.Redirect("/staff/unknownteaching/#Teaching"); } } }
protected override void GenerateOutput() { if (this.HasStaffId()) { Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.Int, "@StaffId", this._staffId); using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Staff/Add/timetable.sql", paramBuilder.Parameters)) { dataReader.Read(); switch ((int)dataReader["Status"]) { case 0: this.SetToBadStaffId(); break; case 1: this.SetToTimetableExists(); break; case 2: Core.WebServer.PleaseTakes.Redirect("/staff/modify/ajax/teaching/timetable/" + this._staffId + "/"); break; } } } else { this.SetToBadStaffId(); } }
protected override void GenerateOutput() { Core.Helpers.Elements.Ajax.Xml.Collection responseXml = new Core.Helpers.Elements.Ajax.Xml.Collection(); if (this.HasStaffId() && this.HasDepartmentId()) { Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.Int, "@StaffId", this._staffId); paramBuilder.AddParameter(SqlDbType.Int, "@DepartmentId", this._departmentId); using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Staff/Modify/Update/Teaching/department.sql", paramBuilder.Parameters)) { dataReader.Read(); if (((int)dataReader["Status"]).Equals(2)) { dataReader.NextResult(); while (dataReader.Read()) { responseXml.Add("Department" + (int)dataReader["DepartmentId"], dataReader["ClassName"] as string, null); } } else { responseXml.Add("Department" + this._departmentId, "Yellow", null); } } } this.Page.Contents = responseXml.ToString(); }
protected override void GenerateOutput() { Core.Helpers.Elements.Ajax.Xml.Collection xmlCollection = new Core.Helpers.Elements.Ajax.Xml.Collection(); if (this.CheckInputValidity()) { if (this.Path.HasNext()) { int staffId; bool successfulParse = int.TryParse(this.Path.Next(), out staffId); if (successfulParse) { Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.Int, "@StaffId", staffId); paramBuilder.AddParameter(SqlDbType.SmallDateTime, "@Date", this._selectedDate); using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Cover/Arrange/Attendance/Attendance/modify.sql", paramBuilder.Parameters)) { if (dataReader.Read()) { xmlCollection.Add(null, dataReader["Colour"] as string, null); } else { xmlCollection.Add(null, "Yellow", null); } } } else { xmlCollection.Add(null, "Yellow", null); } } else { xmlCollection.Add(null, "Yellow", null); } } else { xmlCollection.Add(null, "Yellow", null); } this.Page.Contents = xmlCollection.ToString(); }
private void DoUpdate() { Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.Int, "@StaffId", this._staffId); paramBuilder.AddParameter(SqlDbType.Int, "@Entitlement", this._entitlement); using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Staff/Modify/Update/Teaching/entitlement.sql", paramBuilder.Parameters)) { dataReader.Read(); if ((bool)dataReader["Status"]) { Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/" + this._staffId + "/entitlementsuccess/#Entitlement"); } else { Core.WebServer.PleaseTakes.Redirect("/staff/unknownteaching/#Teaching"); } } }
private void DoUpdate() { string randomPassword = Core.Utils.GetRandomPassword(); Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.Int, "@StaffId", this._staffId); paramBuilder.AddParameter(SqlDbType.VarChar, "@Password", randomPassword); using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Staff/Modify/Update/Teaching/accountreset.sql", paramBuilder.Parameters)) { dataReader.Read(); switch ((int)dataReader["Status"]) { case 0: Core.WebServer.PleaseTakes.Redirect("/staff/unknownteaching/#Teaching"); break; case 1: Core.Utils.SetTemporaryStorageObject("StaffTeachingAccountAlert", "resetnoaccount"); Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/" + this._staffId + "/#Account"); break; case 2: if (Core.WebServer.PleaseTakes.Session.CurrentInstance.Account.IsTeachingAccount) { Accounts.TeachingAccount account = (Accounts.TeachingAccount)Core.WebServer.PleaseTakes.Session.CurrentInstance.Account; if (account.StaffId.Equals(this._staffId)) { account.Password = randomPassword; } } Core.Utils.SetTemporaryStorageObject("StaffTeachingAccountPassword", randomPassword); Core.Utils.SetTemporaryStorageObject("StaffTeachingAccountAlert", "created"); Core.Utils.SetTemporaryStorageObject("StaffTeachingAccountAlert", "resetsuccess"); Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/" + this._staffId + "/#Account"); break; } } }
protected override void GenerateOutput() { string searchTerm = this.GetSearchTerm(); string alertMessage = this.GetAlertMessage(); Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.VarChar, "@SearchTerm", searchTerm); if ((!string.IsNullOrEmpty(alertMessage)) && (alertMessage.Equals("unknownoutside"))) { Core.Helpers.Elements.Alerts.Alert unknownTeachingAlert = new Core.Helpers.Elements.Alerts.Alert("UnknownTeaching"); unknownTeachingAlert.Colour = Core.Helpers.Elements.Alerts.Colours.Yellow; unknownTeachingAlert.Message = new Core.Helpers.Constructor("/Alerts/Specific/Staff/Landing/Outside/unknown.html").ToString(); unknownTeachingAlert.NoScript = false; unknownTeachingAlert.ShowCloseBox = true; unknownTeachingAlert.StartHidden = false; this.Page.Contents = unknownTeachingAlert.ToString(); } using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Staff/Landing/outside.sql", paramBuilder.Parameters)) { if (dataReader.HasRows) { Core.Helpers.Elements.RecordLists.Collection recordCollection = new Core.Helpers.Elements.RecordLists.Collection(); int recordCount = 0; while (dataReader.Read()) { Records.OutsideCoverStaffMember outsideCoverStaffRecord = new Records.OutsideCoverStaffMember(); StaffNameFormatter staffName = new StaffNameFormatter(); staffName.Forename = dataReader["Forename"] as string; staffName.Surname = dataReader["Surname"] as string; outsideCoverStaffRecord.Id = (int)dataReader["OutsideCoverStaffId"]; outsideCoverStaffRecord.Name = staffName; recordCollection.Add(outsideCoverStaffRecord.Record); recordCount++; } if (Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage.ContainsKey("StaffOutsideCount")) { Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage["StaffOutsideCount"] = recordCount; } else { Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage.Add("StaffOutsideCount", recordCount); } this.Page.Contents += recordCollection.ToString(); } else { Core.Helpers.Elements.Alerts.Alert noOutsideStaffAlert = new Core.Helpers.Elements.Alerts.Alert("NoOutsideStaff"); noOutsideStaffAlert.Colour = Core.Helpers.Elements.Alerts.Colours.Yellow; noOutsideStaffAlert.Message = new Core.Helpers.Constructor("/Alerts/Specific/Staff/Landing/Outside/none.html").ToString(); noOutsideStaffAlert.NoScript = false; noOutsideStaffAlert.ShowCloseBox = false; noOutsideStaffAlert.StartHidden = false; this.Page.Contents += noOutsideStaffAlert.ToString(); } } }
protected override void InitialChecks() { if (this.HasStaffId() && this.HasWeekNo() && this.HasDayNo() && this.HasPeriod()) { this.HasAlertMessage(); Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.Int, "@StaffId", this._staffId); paramBuilder.AddParameter(SqlDbType.Int, "@WeekNo", this._weekNo); paramBuilder.AddParameter(SqlDbType.Int, "@DayNo", this._dayNo); paramBuilder.AddParameter(SqlDbType.Int, "@Period", this._period); using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Staff/Modify/Teaching/period.sql", paramBuilder.Parameters)) { dataReader.Read(); if (((int)dataReader["Status"]).Equals(1)) { this.PopulateName(dataReader); switch ((int)dataReader["PeriodStatus"]) { case 0: this._state = TimetableStates.Unavailable; break; case 1: this._state = TimetableStates.Free; break; case 2: if (((int)dataReader["PeriodType"]).Equals(2)) { this._state = TimetableStates.Busy; } else { this._state = TimetableStates.Teaching; this._isUnique = (bool)dataReader["IsUnique"]; this._yeargroupId = dataReader["YeargroupId"] as int?; this._yeargroupName = dataReader["YeargroupName"] as string; this._roomId = dataReader["RoomId"] as int?; this._roomName = dataReader["RoomName"] as string; this._subjectId = dataReader["SubjectId"] as int?; this._subjectName = dataReader["SubjectName"] as string; this._qualificationName = dataReader["QualificationName"] as string; this._subjectQualificationId = dataReader["SubjectQualificationId"] as int?; this._classId = dataReader["ClassId"] as int?; this._className = dataReader["ClassName"] as string; } this._commitmentName = dataReader["CommitmentName"] as string; break; } } else { Core.WebServer.PleaseTakes.Redirect("/staff/inputteaching/#Teaching"); } } } else { Core.WebServer.PleaseTakes.Redirect("/staff/inputteaching/#Teaching"); } }
protected override void GenerateOutput() { if (this.CheckInputValidity()) { Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.SmallDateTime, "@Date", this._selectedDate); paramBuilder.AddParameter(SqlDbType.Int, "@WeekNo", this._timetableWeek); paramBuilder.AddParameter(SqlDbType.Int, "@DayNo", (int)(this._selectedDate.DayOfWeek + 1)); if (this.Path.HasNext() && this.Path.Peek().Equals("notrequired")) { this.Path.Next(); paramBuilder.AddParameter(SqlDbType.Bit, "@GetNoCoverRequests", 1); } else { paramBuilder.AddParameter(SqlDbType.Bit, "@GetNoCoverRequests", 0); } 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/Selection/Requests/list.sql", paramBuilder.Parameters)) { if (dataReader.HasRows) { Core.Helpers.Elements.RecordLists.Collection recordCollection = new Core.Helpers.Elements.RecordLists.Collection(); int requestsCount = 0; while (dataReader.Read()) { Records.RequestBase record = new Records.RequestBase(); if ((bool)dataReader["IsBusy"]) { if ((!dataReader["IsYeargroupAway"].Equals(System.DBNull.Value)) && ((bool)dataReader["IsYeargroupAway"])) { Records.NoCoverRequired newRecord = new Records.NoCoverRequired(); newRecord.CommitmentName = dataReader["CommitmentName"] as string; newRecord.IsYeargroupAway = true; record = newRecord; } else if (!(bool)dataReader["TeachingClass"]) { Records.NoCoverRequired newRecord = new Records.NoCoverRequired(); newRecord.CommitmentName = dataReader["CommitmentName"] as string; newRecord.IsNotTeaching = true; record = newRecord; } else { if ((bool)dataReader["HasCover"]) { if ((bool)dataReader["IsInternalCover"]) { Records.CoverSelected newRecord = new Records.CoverSelected(); newRecord.IsInternalCover = true; newRecord.Id = "Request" + (int)dataReader["CoverId"]; newRecord.OnClick = "switchToSelection(" + (int)dataReader["CoverId"] + ", " + this._selectedDate.Year + ", " + this._selectedDate.Month + ", " + this._selectedDate.Day + ", true)"; newRecord.CommitmentName = dataReader["CommitmentName"] as string; UserManagement.StaffNameFormatter coveringStaffNameFormatter = new UserManagement.StaffNameFormatter(); coveringStaffNameFormatter.Forename = dataReader["CoverForename"] as string; coveringStaffNameFormatter.Surname = dataReader["CoverSurname"] as string; coveringStaffNameFormatter.HoldingName = dataReader["CoverHoldingName"] as string; newRecord.CoverStaffName = coveringStaffNameFormatter; //newRecord.CoverStaffName = Core.Utils.FormatStaffName(dataReader["CoverForename"] as string, dataReader["CoverSurname"] as string, dataReader["CoverHoldingName"] as string, false, false, false); record = newRecord; } else { Records.CoverSelected newRecord = new Records.CoverSelected(); newRecord.IsInternalCover = false; newRecord.Id = "Request" + (int)dataReader["CoverId"]; newRecord.OnClick = "switchToSelection(" + (int)dataReader["CoverId"] + ", " + this._selectedDate.Year + ", " + this._selectedDate.Month + ", " + this._selectedDate.Day + ", true)"; newRecord.CommitmentName = dataReader["CommitmentName"] as string; UserManagement.StaffNameFormatter coveringStaffNameFormatter = new UserManagement.StaffNameFormatter(); coveringStaffNameFormatter.Forename = dataReader["CoverForename"] as string; coveringStaffNameFormatter.Surname = dataReader["CoverSurname"] as string; newRecord.CoverStaffName = coveringStaffNameFormatter; //newRecord.CoverStaffName = Core.Utils.FormatStaffName(dataReader["CoverForename"] as string, dataReader["CoverSurname"] as string, null, false, false, false); record = newRecord; } } else { Records.NoCoverSelected newRecord = new Records.NoCoverSelected(); newRecord.Id = "Request" + (int)dataReader["CoverId"]; newRecord.OnClick = "switchToSelection(" + (int)dataReader["CoverId"] + ", " + this._selectedDate.Year + ", " + this._selectedDate.Month + ", " + this._selectedDate.Day + ", true)"; newRecord.CommitmentName = dataReader["CommitmentName"] as string; record = newRecord; } } } else { Records.NoCoverRequired newRecord = new Records.NoCoverRequired(); newRecord.IsYeargroupAway = false; record = newRecord; } UserManagement.StaffNameFormatter absenteeNameFormatter = new UserManagement.StaffNameFormatter(); absenteeNameFormatter.Forename = dataReader["AbsentForename"] as string; absenteeNameFormatter.Surname = dataReader["AbsentSurname"] as string; absenteeNameFormatter.HoldingName = dataReader["AbsentHoldingName"] as string; record.AbsenteeName = absenteeNameFormatter; record.AbsenteeNameToolTip = absenteeNameFormatter; //record.AbsenteeName = Core.Utils.FormatStaffName(dataReader["AbsentForename"] as string, dataReader["AbsentSurname"] as string, dataReader["AbsentHoldingName"] as string, false, false, false); //record.AbsenteeNameToolTip = Core.Utils.FormatStaffName(dataReader["AbsentForename"] as string, dataReader["AbsentSurname"] as string, dataReader["AbsentHoldingName"] as string, false, false, false); record.Period = (int)dataReader["Period"]; recordCollection.Add(record.Record); requestsCount++; } if (Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage.ContainsKey("ArrangeRequestsCount")) { Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage["ArrangeRequestsCount"] = requestsCount; } else { Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage.Add("ArrangeRequestsCount", requestsCount); } this.Page.Contents = recordCollection.ToString(); } else { Core.Helpers.Elements.Alerts.Alert a = new Core.Helpers.Elements.Alerts.Alert("NoRequests"); a.Colour = PleaseTakes.Core.Helpers.Elements.Alerts.Colours.Yellow; a.NoScript = false; a.ShowCloseBox = false; a.StartHidden = false; a.Message = new Core.Helpers.Constructor("/Alerts/Specific/Cover/Arrange/Selection/Requests/norequests.html").ToString(); this.Page.Contents = a.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(); } }
private void DoUpdate() { Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.Int, "@StaffId", this._staffId); paramBuilder.AddParameter(SqlDbType.Int, "@WeekNo", this._weekNo); paramBuilder.AddParameter(SqlDbType.Int, "@DayNo", this._dayNo); paramBuilder.AddParameter(SqlDbType.Int, "@Period", this._period); string sqlPath = ""; switch (this._state) { case TimetableStates.Unavailable: sqlPath = "/Sql/Specific/Staff/Modify/Teaching/Timetable/unavailable.sql"; break; case TimetableStates.Free: sqlPath = "/Sql/Specific/Staff/Modify/Teaching/Timetable/free.sql"; break; case TimetableStates.Teaching: sqlPath = "/Sql/Specific/Staff/Modify/Teaching/Timetable/teaching.sql"; if (!string.IsNullOrEmpty(Core.WebServer.Request["SelectedGroup"]) && (Core.WebServer.Request["SelectedGroup"].Equals("Unique") || Core.WebServer.Request["SelectedGroup"].Equals("Class"))) { bool isUnique = Core.WebServer.Request["SelectedGroup"].Equals("Unique"); if (isUnique) { paramBuilder.AddParameter(SqlDbType.Bit, "@IsUnique", true); if (this.HasYeargroupId(Core.WebServer.Request["UniqueYeargroupId"]) && this.HasCommitmentName(Core.WebServer.Request["UniqueName"])) { this.CheckRoomId(Core.WebServer.Request["UniqueRoomId"]); paramBuilder.AddParameter(SqlDbType.Int, "@YeargroupId", this._yeargroupId); paramBuilder.AddParameter(SqlDbType.Int, "@RoomId", this._roomId); paramBuilder.AddParameter(SqlDbType.VarChar, "@CommitmentName", this._commitmentName); paramBuilder.AddParameter(SqlDbType.Int, "@SubjectId", null); paramBuilder.AddParameter(SqlDbType.Int, "@SubjectQualificationId", null); paramBuilder.AddParameter(SqlDbType.Int, "@ClassId", null); } else { Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/timetable/" + this._staffId + "/" + this._weekNo + "/" + this._dayNo + "/" + this._period + "/uniquefail/#Teaching"); } } else { paramBuilder.AddParameter(SqlDbType.Bit, "@IsUnique", false); if (this.HasSubjectId() && this.HasSubjectQualificationId() && this.HasClassId()) { this.CheckRoomId(Core.WebServer.Request["ClassRoomId"]); paramBuilder.AddParameter(SqlDbType.Int, "@SubjectId", this._subjectId); paramBuilder.AddParameter(SqlDbType.Int, "@SubjectQualificationId", this._subjectQualificationId); paramBuilder.AddParameter(SqlDbType.Int, "@ClassId", this._classId); paramBuilder.AddParameter(SqlDbType.Int, "@RoomId", this._roomId); paramBuilder.AddParameter(SqlDbType.Int, "@YeargroupId", null); paramBuilder.AddParameter(SqlDbType.VarChar, "@CommitmentName", null); } else { Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/timetable/" + this._staffId + "/" + this._weekNo + "/" + this._dayNo + "/" + this._period + "/classfail/#Teaching"); } } } else { Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/timetable/" + this._staffId + "/" + this._weekNo + "/" + this._dayNo + "/" + this._period + "/teachingfail/#Teaching"); } break; case TimetableStates.Busy: sqlPath = "/Sql/Specific/Staff/Modify/Teaching/Timetable/busy.sql"; string busyCommitment = Core.WebServer.Request["BusyCommitment"]; if (string.IsNullOrEmpty(busyCommitment)) { Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/timetable/" + this._staffId + "/" + this._weekNo + "/" + this._dayNo + "/" + this._period + "/busyfailed/#Busy"); } else { paramBuilder.AddParameter(SqlDbType.VarChar, "@CommitmentName", busyCommitment); } break; } using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader(sqlPath, paramBuilder.Parameters)) { dataReader.Read(); int status = (int)dataReader["Status"]; if (status.Equals(2)) { Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/" + this._staffId + "/week/" + this._weekNo + "/success/#Timetable"); } else { Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/" + this._staffId + "/week/" + this._weekNo + "/failed/#Timetable"); } } }
protected override void SetPrintContent() { if (this.CheckInputValidity()) { DateTime creationDate = DateTime.Now; Core.Helpers.Constructor pageContent = new Core.Helpers.Constructor("/Templates/Specific/Cover/Slips/Printouts/valid.html"); Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); pageContent.SetVariable("CoverDate", this._selectedDate.ToString("dddd, dd MMMM yyyy")); paramBuilder.AddParameter(SqlDbType.SmallDateTime, "@Date", this._selectedDate); paramBuilder.AddParameter(SqlDbType.Int, "@WeekNo", this._timetableWeek); paramBuilder.AddParameter(SqlDbType.Int, "@DayNo", (int)(this._selectedDate.DayOfWeek + 1)); int internalCount = 0; int outsideCount = 0; using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Cover/Slips/Printouts/daylist.sql", paramBuilder.Parameters)) { if (dataReader.HasRows) { Core.Helpers.Constructor internalConstructor = new Core.Helpers.Constructor("/Templates/Specific/Cover/Slips/Printouts/internalcover.html"); Core.Helpers.Elements.CoverSlips.Collection internalCollection = new Core.Helpers.Elements.CoverSlips.Collection(); int pageCount = 0; int pageSlipCount = 0; while (dataReader.Read()) { Core.Helpers.Elements.CoverSlips.Slip slip = new Core.Helpers.Elements.CoverSlips.Slip(); this.PopulateSlip(ref slip, dataReader, true, creationDate); if (pageCount.Equals(0) && pageSlipCount.Equals(3)) { slip.PageBreakBefore = true; pageCount++; pageSlipCount = 0; } else if (pageSlipCount.Equals(3)) { slip.PageBreakBefore = true; pageCount++; pageSlipCount = 0; } else { pageSlipCount++; } internalCollection.Add(slip); internalCount++; } internalConstructor.SetVariable("Slips", internalCollection.ToString()); pageContent.SetVariable("InternalCoverCount", internalCount.ToString()); pageContent.SetVariable("InternalCoverSlips", internalConstructor); } else { pageContent.SetVariable("InternalCoverCount", "0"); pageContent.DeleteVariable("InternalCoverSlips"); } dataReader.NextResult(); if (dataReader.HasRows) { Core.Helpers.Constructor outsideConstructor = new Core.Helpers.Constructor("/Templates/Specific/Cover/Slips/Printouts/outsidecover.html"); Core.Helpers.Elements.CoverSlips.Collection outsideCollection = new Core.Helpers.Elements.CoverSlips.Collection(); if (internalCount > 0) { outsideConstructor.SetVariable("BreakBefore", " class=\"BreakBefore\""); } else { outsideConstructor.DeleteVariable("BreakBefore"); } int pageCount = 0; int pageSlipCount = 0; while (dataReader.Read()) { Core.Helpers.Elements.CoverSlips.Slip slip = new Core.Helpers.Elements.CoverSlips.Slip(); this.PopulateSlip(ref slip, dataReader, false, creationDate); if (!internalCount.Equals(0) && pageCount.Equals(0) && pageSlipCount.Equals(4)) { slip.PageBreakBefore = true; pageCount++; pageSlipCount = 0; } else if (internalCount.Equals(0) && pageCount.Equals(0) && pageSlipCount.Equals(3)) { slip.PageBreakBefore = true; pageCount++; pageSlipCount = 0; } else if (!pageCount.Equals(0) && pageSlipCount.Equals(3)) { slip.PageBreakBefore = true; pageCount++; pageSlipCount = 0; } else { pageSlipCount++; } outsideCollection.Add(slip); outsideCount++; } outsideConstructor.SetVariable("Slips", outsideCollection.ToString()); pageContent.SetVariable("OutsideCoverCount", outsideCount.ToString()); pageContent.SetVariable("OutsideCoverSlips", outsideConstructor); } else { pageContent.SetVariable("OutsideCoverCount", "0"); pageContent.DeleteVariable("OutsideCoverSlips"); } } this.Page.SetVariable("PrintArea", pageContent); } else { this.Page.SetVariable("PrintArea", new Core.Helpers.Constructor("/Templates/Specific/Cover/Slips/Printouts/badrequest.html")); } }
private void DoUpdate() { string randomPassword = Core.Utils.GetRandomPassword(); Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.Int, "@StaffId", this._staffId); paramBuilder.AddParameter(SqlDbType.Bit, "@HasAccount", this._hasAccount); if (Core.WebServer.PleaseTakes.Session.CurrentInstance.Account.IsTeachingAccount) { Accounts.TeachingAccount account = (Accounts.TeachingAccount)Core.WebServer.PleaseTakes.Session.CurrentInstance.Account; paramBuilder.AddParameter(SqlDbType.Int, "@CurrentStaffId", account.StaffId); } else { paramBuilder.AddParameter(SqlDbType.Int, "@CurrentStaffId", null); } if (this._hasAccount) { if (this.HasUsername() && this.HasAccountType() && this.HasAccountStatus()) { paramBuilder.AddParameter(SqlDbType.VarChar, "@Username", this._username); paramBuilder.AddParameter(SqlDbType.VarChar, "@Password", randomPassword); paramBuilder.AddParameter(SqlDbType.Bit, "@IsAdmin", this._isAdmin); paramBuilder.AddParameter(SqlDbType.Bit, "@IsActive", this._isActive); } else { Core.Utils.SetTemporaryStorageObject("StaffTeachingAccountAlert", "missing"); Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/" + this._staffId + "/#Account"); } } else { paramBuilder.AddParameter(SqlDbType.VarChar, "@Username", ""); paramBuilder.AddParameter(SqlDbType.VarChar, "@Password", ""); paramBuilder.AddParameter(SqlDbType.Bit, "@IsAdmin", false); paramBuilder.AddParameter(SqlDbType.Bit, "@IsActive", false); Core.WebServer.Response.Write("No account"); } if (Core.WebServer.PleaseTakes.Session.CurrentInstance.School.Settings.NonTeachingAccounts.Exists(this._username)) { Core.Utils.SetTemporaryStorageObject("StaffTeachingAccountAlert", "exists"); Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/" + this._staffId + "/#Account"); } else { using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Staff/Modify/Update/Teaching/account.sql", paramBuilder.Parameters)) { dataReader.Read(); switch ((int)dataReader["Status"]) { case 0: Core.WebServer.PleaseTakes.Redirect("/staff/unknownteaching/#Teaching"); break; case 1: Core.Utils.SetTemporaryStorageObject("StaffTeachingAccountAlert", "exists"); Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/" + this._staffId + "/#Account"); break; case 2: if (Core.WebServer.PleaseTakes.Session.CurrentInstance.Account.IsTeachingAccount) { Accounts.TeachingAccount account = (Accounts.TeachingAccount)Core.WebServer.PleaseTakes.Session.CurrentInstance.Account; if (account.StaffId.Equals(this._staffId)) { account.Password = randomPassword; } } Core.Utils.SetTemporaryStorageObject("StaffTeachingAccountAlert", "updated"); Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/" + this._staffId + "/#Account"); break; case 3: if (Core.WebServer.PleaseTakes.Session.CurrentInstance.Account.IsTeachingAccount) { Accounts.TeachingAccount account = (Accounts.TeachingAccount)Core.WebServer.PleaseTakes.Session.CurrentInstance.Account; if (account.StaffId.Equals(this._staffId)) { account.Password = randomPassword; } } Core.Utils.SetTemporaryStorageObject("StaffTeachingAccountPassword", randomPassword); Core.Utils.SetTemporaryStorageObject("StaffTeachingAccountAlert", "created"); Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/" + this._staffId + "/#Account"); break; case 4: Core.Utils.SetTemporaryStorageObject("StaffTeachingAccountAlert", "deleted"); Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/" + this._staffId + "/#Account"); break; case 5: Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/" + this._staffId + "/#Account"); break; case 6: Core.Utils.SetTemporaryStorageObject("StaffTeachingAccountAlert", "loggedin"); Core.WebServer.PleaseTakes.Redirect("/staff/modify/teaching/" + this._staffId + "/#Account"); break; } } } }
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(); } }
protected override void GenerateOutput() { Core.Helpers.Path.Parser sourcePath = new Core.Helpers.Path.Parser(Core.WebServer.Request["sourcepath"]); bool validSourceDate = this.CheckInputValidity(false, sourcePath); bool validAjaxDate = this.CheckInputValidity(true, this.Path); if (!validSourceDate && !validAjaxDate) { Core.Helpers.Elements.Alerts.Alert noDate = new Core.Helpers.Elements.Alerts.Alert("NoDate"); noDate.Colour = Core.Helpers.Elements.Alerts.Colours.Red; noDate.NoScript = false; noDate.ShowCloseBox = false; noDate.StartHidden = false; noDate.Message = new Core.Helpers.Constructor("/Alerts/Specific/Cover/Slips/Requests/nodate.html").ToString(); this.Page.Contents = noDate.ToString(); } else { Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); string searchTerm = ""; if (this.Path.HasNext()) { searchTerm = this.Path.Next(); } paramBuilder.AddParameter(SqlDbType.SmallDateTime, "@Date", this._selectedDate); paramBuilder.AddParameter(SqlDbType.Int, "@WeekNo", this._timetableWeek); paramBuilder.AddParameter(SqlDbType.Int, "@DayNo", (int)(this._selectedDate.DayOfWeek + 1)); paramBuilder.AddParameter(SqlDbType.VarChar, "@SearchTerm", searchTerm); using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Cover/slips/selective.sql", paramBuilder.Parameters)) { if (dataReader.HasRows) { Core.Helpers.Elements.RecordLists.Collection recordCollection = new Core.Helpers.Elements.RecordLists.Collection(); while (dataReader.Read()) { Records.CoverSelected record = new Records.CoverSelected(); record.Record.Colour = Core.Helpers.Elements.RecordLists.Colours.Blue; record.IsInternalCover = (bool)dataReader["IsInternal"]; record.Period = (int)dataReader["Period"]; record.CommitmentName = dataReader["CommitmentName"] as string; UserManagement.StaffNameFormatter absenteeNameFormatter = new UserManagement.StaffNameFormatter(); absenteeNameFormatter.Forename = dataReader["AbsentForename"] as string; absenteeNameFormatter.Surname = dataReader["AbsentSurname"] as string; absenteeNameFormatter.HoldingName = dataReader["AbsentHoldingName"] as string; record.AbsenteeName = absenteeNameFormatter; record.AbsenteeNameToolTip = absenteeNameFormatter; UserManagement.StaffNameFormatter coveringNameFormatter = new UserManagement.StaffNameFormatter(); coveringNameFormatter.Forename = dataReader["CoverForename"] as string; coveringNameFormatter.Surname = dataReader["CoverSurname"] as string; coveringNameFormatter.HoldingName = dataReader["CoverHoldingName"] as string; record.CoverStaffName = coveringNameFormatter; recordCollection.Add(record.Record); } this.Page.Contents = recordCollection.ToString(); } else { Core.Helpers.Elements.Alerts.Alert noRequests = new Core.Helpers.Elements.Alerts.Alert("NoRequests"); noRequests.Colour = Core.Helpers.Elements.Alerts.Colours.Yellow; noRequests.NoScript = false; noRequests.ShowCloseBox = false; noRequests.StartHidden = false; noRequests.Message = new Core.Helpers.Constructor("/Alerts/Specific/Cover/Slips/Requests/norequests.html").ToString(); this.Page.Contents = noRequests.ToString(); } } } }
protected override void GenerateOutput() { Core.Helpers.Elements.Ajax.Xml.Collection xmlCollection = new Core.Helpers.Elements.Ajax.Xml.Collection(); bool isInternalStaff; int coverId; int staffId; if (this.CheckInputValidity() && this.IsInternalStaff(out isInternalStaff) && this.GetValue(out coverId) && this.GetValue(out staffId)) { DateTime startDate = Core.WebServer.PleaseTakes.Session.CurrentInstance.School.Settings.Timetabling.SessionDetails.CurrentSession.GetDateSessionInformation(this._selectedDate).RotationStartDate; DateTime endDate = Core.WebServer.PleaseTakes.Session.CurrentInstance.School.Settings.Timetabling.SessionDetails.CurrentSession.GetDateSessionInformation(this._selectedDate).RotationEndDate; Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.Bit, "@IsInternalStaff", isInternalStaff); paramBuilder.AddParameter(SqlDbType.Int, "@CoverId", coverId); paramBuilder.AddParameter(SqlDbType.Int, "@StaffId", staffId); paramBuilder.AddParameter(SqlDbType.SmallDateTime, "@StartDate", startDate); paramBuilder.AddParameter(SqlDbType.SmallDateTime, "@EndDate", endDate); paramBuilder.AddParameter(SqlDbType.Int, "@WeekNo", this._timetableWeek); paramBuilder.AddParameter(SqlDbType.Int, "@DayNo", (int)(this._selectedDate.DayOfWeek + 1)); using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Cover/Arrange/Selection/Selection/modify.sql", paramBuilder.Parameters)) { dataReader.Read(); if ((bool)dataReader["Status"]) { dataReader.NextResult(); if (dataReader.HasRows) { while (dataReader.Read()) { Core.Helpers.Elements.Ajax.Xml.Element xmlElement = new Core.Helpers.Elements.Ajax.Xml.Element(); if ((bool)dataReader["IsRequest"]) { Records.RequestBase record = new Records.RequestBase(); xmlElement.Id = "Request" + (int)dataReader["Id"]; if ((bool)dataReader["RequestHasCover"]) { Records.CoverSelected newRecord = new Records.CoverSelected(); xmlElement.ClassName = "Green"; UserManagement.StaffNameFormatter staffAbsenteeNameFormatter = new UserManagement.StaffNameFormatter(); staffAbsenteeNameFormatter.Forename = dataReader["RequestAbsentForename"] as string; staffAbsenteeNameFormatter.Surname = dataReader["RequestAbsentSurname"] as string; staffAbsenteeNameFormatter.HoldingName = dataReader["RequestAbsentHoldingname"] as string; newRecord.AbsenteeName = staffAbsenteeNameFormatter; //newRecord.AbsenteeName = Core.Utils.FormatStaffName(dataReader["RequestAbsentForename"] as string, dataReader["RequestAbsentSurname"] as string, dataReader["RequestAbsentHoldingname"] as string, false, false, false); newRecord.Period = (int)dataReader["RequestPeriod"]; newRecord.CommitmentName = dataReader["RequestCommitmentName"] as string; newRecord.IsInternalCover = (bool)dataReader["IsInternalCover"]; UserManagement.StaffNameFormatter staffCoveringNameFormatter = new UserManagement.StaffNameFormatter(); staffCoveringNameFormatter.Forename = dataReader["RequestCoverForename"] as string; staffCoveringNameFormatter.Surname = dataReader["RequestCoverSurname"] as string; staffCoveringNameFormatter.HoldingName = dataReader["RequestCoverHoldingName"] as string; newRecord.CoverStaffName = staffCoveringNameFormatter; //newRecord.CoverStaffName = Core.Utils.FormatStaffName(dataReader["RequestCoverForename"] as string, dataReader["RequestCoverSurname"] as string, dataReader["RequestCoverHoldingName"] as string, false, false, false); record = newRecord; } else { Records.NoCoverSelected newRecord = new Records.NoCoverSelected(); xmlElement.ClassName = "Red"; UserManagement.StaffNameFormatter absenteeNameFormatter = new UserManagement.StaffNameFormatter(); absenteeNameFormatter.Forename = dataReader["RequestAbsentForename"] as string; absenteeNameFormatter.Surname = dataReader["RequestAbsentSurname"] as string; absenteeNameFormatter.HoldingName = dataReader["RequestAbsentHoldingName"] as string; newRecord.AbsenteeName = absenteeNameFormatter; //newRecord.AbsenteeName = Core.Utils.FormatStaffName(dataReader["RequestAbsentForename"] as string, dataReader["RequestAbsentSurname"] as string, dataReader["RequestAbsentHoldingName"] as string, false, false, false); newRecord.Period = (int)dataReader["RequestPeriod"]; newRecord.CommitmentName = dataReader["RequestCommitmentName"] as string; record = newRecord; } xmlElement.InnerHtml = record.InnerHtml; } else { Records.Selection record = new Records.Selection(); int entitlement = (int)dataReader["SelectionEntitlement"]; xmlElement.Id = "Selection" + (int)dataReader["Id"]; record.IsInternal = isInternalStaff; if (isInternalStaff) { UserManagement.StaffNameFormatter nameFormatter = new UserManagement.StaffNameFormatter(); nameFormatter.Forename = dataReader["SelectionForename"] as string; nameFormatter.Surname = dataReader["SelectionSurname"] as string; nameFormatter.HoldingName = dataReader["SelectionHoldingName"] as string; record.StaffName = nameFormatter; } else { UserManagement.StaffNameFormatter nameFormatter = new UserManagement.StaffNameFormatter(); nameFormatter.Forename = dataReader["SelectionForename"] as string; nameFormatter.Surname = dataReader["SelectionSurname"] as string; record.StaffName = nameFormatter; } if ((bool)dataReader["SelectionIsSelected"]) { xmlElement.ClassName = "Green"; } else if (entitlement.Equals(0)) { xmlElement.ClassName = "Red"; } else { xmlElement.ClassName = ""; } record.Entitlement = entitlement; xmlElement.InnerHtml = record.InnerHtml; } xmlCollection.Add(xmlElement); } } } } } this.Page.Contents = xmlCollection.ToString(); }
protected override void GenerateOutput() { Core.Helpers.Elements.Ajax.Xml.Collection xmlCollection = new Core.Helpers.Elements.Ajax.Xml.Collection(); if (this.CheckInputValidity()) { Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.Int, "@StaffId", this._staffId); paramBuilder.AddParameter(SqlDbType.SmallDateTime, "@Date", this._selectedDate); paramBuilder.AddParameter(SqlDbType.Int, "@WeekNo", this._timetableWeek); paramBuilder.AddParameter(SqlDbType.Int, "@DayNo", (int)(this._selectedDate.DayOfWeek + 1)); if (this._period.Equals(0)) { paramBuilder.AddParameter(SqlDbType.Int, "@PeriodMin", 1); paramBuilder.AddParameter(SqlDbType.Int, "@PeriodMax", this._periods); } else { paramBuilder.AddParameter(SqlDbType.Int, "@PeriodMin", this._period); paramBuilder.AddParameter(SqlDbType.Int, "@PeriodMax", this._period); } using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Cover/Arrange/Attendance/Periods/modify.sql", paramBuilder.Parameters)) { if (dataReader.HasRows) { while (dataReader.Read()) { int period = (int)dataReader["Period"]; string id = "Periods" + this._staffId + "-" + period; string classes = "Large "; Core.Helpers.Constructor innerHtml = new Core.Helpers.Constructor("/Templates/Specific/Cover/Arrange/Attendance/periodsinner.html"); switch ((dataReader["Status"] as string).ToLower()) { case "absent": classes += "Red"; innerHtml.SetVariable("Symbol", "A"); break; case "present": classes += "Green"; innerHtml.SetVariable("Symbol", "P"); break; case "presentyeargroupaway": classes += "Blue"; innerHtml.SetVariable("Symbol", "P"); break; case "presentisbusy": classes += "Indigo"; innerHtml.SetVariable("Symbol", "P"); break; } innerHtml.SetVariable("StaffId", this._staffId.ToString()); innerHtml.SetVariable("Year", this._selectedDate.Year.ToString()); innerHtml.SetVariable("Month", this._selectedDate.Month.ToString()); innerHtml.SetVariable("Day", this._selectedDate.Day.ToString()); innerHtml.SetVariable("Period", period.ToString()); xmlCollection.Add(id, classes, innerHtml.ToString()); } } } } this.Page.Contents = xmlCollection.ToString(); }
protected override void GenerateOutput() { bool isInternal = false; bool showZeroEntitlement = false; string statusMessage = ""; if (this.Path.HasNext()) { int coverId; string searchTerm; if (this.GetBoolInput(out isInternal) && this.GetBoolInput(out showZeroEntitlement) && this.CheckInputValidity() && this.GetCoverId(out coverId)) { DateTime startDate = Core.WebServer.PleaseTakes.Session.CurrentInstance.School.Settings.Timetabling.SessionDetails.CurrentSession.GetDateSessionInformation(this._selectedDate).RotationStartDate; DateTime endDate = Core.WebServer.PleaseTakes.Session.CurrentInstance.School.Settings.Timetabling.SessionDetails.CurrentSession.GetDateSessionInformation(this._selectedDate).RotationEndDate; searchTerm = this.GetSearchTerm(); Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); paramBuilder.AddParameter(SqlDbType.Int, "@CoverId", coverId); paramBuilder.AddParameter(SqlDbType.Bit, "@GetInternalStaff", isInternal); paramBuilder.AddParameter(SqlDbType.SmallDateTime, "@CurrentDate", this._selectedDate); paramBuilder.AddParameter(SqlDbType.SmallDateTime, "@StartDate", startDate); paramBuilder.AddParameter(SqlDbType.SmallDateTime, "@EndDate", endDate); paramBuilder.AddParameter(SqlDbType.Int, "@WeekNo", this._timetableWeek); paramBuilder.AddParameter(SqlDbType.Int, "@DayNo", (int)(this._selectedDate.DayOfWeek + 1)); paramBuilder.AddParameter(SqlDbType.Bit, "@ShowZeroEntitlement", showZeroEntitlement); if (string.IsNullOrEmpty(searchTerm)) { paramBuilder.AddParameter(SqlDbType.VarChar, "@SearchTerm", ""); } else { paramBuilder.AddParameter(SqlDbType.VarChar, "@SearchTerm", searchTerm); } using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Cover/Arrange/Selection/Selection/list.sql", paramBuilder.Parameters)) { dataReader.Read(); if ((bool)dataReader["DoesExist"]) { dataReader.NextResult(); int staffCount = 0; if (dataReader.HasRows) { Core.Helpers.Elements.RecordLists.Collection recordCollection = new Core.Helpers.Elements.RecordLists.Collection(); recordCollection.Id = "Selection"; while (dataReader.Read()) { Records.Selection selectionRecord = new Records.Selection(); selectionRecord.Id = ((int)dataReader["Id"]).ToString(); selectionRecord.IsInternal = isInternal; selectionRecord.Entitlement = (int)dataReader["RemainingEntitlement"]; selectionRecord.IsSelected = (bool)dataReader["IsSelected"]; if (isInternal) { UserManagement.StaffNameFormatter nameFormatter = new UserManagement.StaffNameFormatter(); nameFormatter.Forename = dataReader["Forename"] as string; nameFormatter.Surname = dataReader["Surname"] as string; nameFormatter.HoldingName = dataReader["HoldingName"] as string; selectionRecord.StaffName = nameFormatter; } else { UserManagement.StaffNameFormatter nameFormatter = new UserManagement.StaffNameFormatter(); nameFormatter.Forename = dataReader["Forename"] as string; nameFormatter.Surname = dataReader["Surname"] as string; selectionRecord.StaffName = nameFormatter; } recordCollection.Add(selectionRecord.Record); staffCount++; } this.Page.Contents = recordCollection.ToString(); } else { Core.Helpers.Elements.Alerts.Alert noResultsAlert = new Core.Helpers.Elements.Alerts.Alert("NoReults"); noResultsAlert.Colour = Core.Helpers.Elements.Alerts.Colours.Yellow; noResultsAlert.Message = new Core.Helpers.Constructor("/Alerts/Specific/Cover/Arrange/Selection/Selection/noresults.html").ToString(); noResultsAlert.NoScript = false; noResultsAlert.ShowCloseBox = false; noResultsAlert.StartHidden = false; this.Page.Contents = noResultsAlert.ToString(); } if (staffCount.Equals(0)) { statusMessage = "<strong>Couldnae find anyone!</strong>"; } else if (staffCount.Equals(1)) { if (isInternal) { statusMessage = "Found <strong>1</strong> member of teaching staff"; } else { statusMessage = "Found <strong>1</strong> member of outside cover staff"; } } else if (isInternal) { statusMessage = "Found <strong>" + staffCount + "</strong> members of teaching staff"; } else { statusMessage = "Found <strong>" + staffCount + "</strong> members of outside cover staff"; } } else { Core.Helpers.Elements.Alerts.Alert requestDoesNotExistAlert = new Core.Helpers.Elements.Alerts.Alert("RequestDoesNotExist"); requestDoesNotExistAlert.Colour = Core.Helpers.Elements.Alerts.Colours.Red; requestDoesNotExistAlert.Message = new Core.Helpers.Constructor("/Alerts/Specific/Cover/Arrange/Selection/Selection/requestdoesnotexist.html").ToString(); requestDoesNotExistAlert.NoScript = false; requestDoesNotExistAlert.ShowCloseBox = false; requestDoesNotExistAlert.StartHidden = false; this.Page.Contents = requestDoesNotExistAlert.ToString(); } } } else { Core.Helpers.Elements.Alerts.Alert badInputAlert = new Core.Helpers.Elements.Alerts.Alert("BadInput"); badInputAlert.Colour = Core.Helpers.Elements.Alerts.Colours.Red; badInputAlert.Message = new Core.Helpers.Constructor("/Alerts/Specific/Cover/Arrange/Selection/Selection/badinput.html").ToString(); badInputAlert.NoScript = false; badInputAlert.ShowCloseBox = false; badInputAlert.StartHidden = false; this.Page.Contents = badInputAlert.ToString(); } } else { Core.Helpers.Elements.Alerts.Alert noRequestSelectedAlert = new Core.Helpers.Elements.Alerts.Alert("NoRequestSelected"); noRequestSelectedAlert.Colour = Core.Helpers.Elements.Alerts.Colours.Red; noRequestSelectedAlert.Message = new Core.Helpers.Constructor("/Alerts/Specific/Cover/Arrange/Selection/Selection/norequestselected.html").ToString(); noRequestSelectedAlert.NoScript = false; noRequestSelectedAlert.ShowCloseBox = false; noRequestSelectedAlert.StartHidden = false; this.Page.Contents = noRequestSelectedAlert.ToString(); } if (!string.IsNullOrEmpty(statusMessage)) { string hoverMessage = ""; if (isInternal && showZeroEntitlement) { hoverMessage = "Showing all available teaching staff"; } else if (isInternal && !showZeroEntitlement) { hoverMessage = "Showing available teaching staff with a remaining entitlement of 1 or greater"; } else if (!isInternal && showZeroEntitlement) { hoverMessage = "Showing all available outside cover staff"; } else { hoverMessage = "Showing available outside cover staff with a remaining entitlement of 1 or greater"; } statusMessage = "<p class=\"Plain\" title=\"" + hoverMessage + "\">" + statusMessage + "</p>"; } if (Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage.ContainsKey("ArrangeSelectionInfo")) { Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage["ArrangeSelectionInfo"] = statusMessage; } else { Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage.Add("ArrangeSelectionInfo", statusMessage); } }
protected override void GenerateOutput() { if (this.HasState()) { Core.Helpers.Elements.RecordLists.Collection recordCollection = new Core.Helpers.Elements.RecordLists.Collection(); Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); string sqlPath = ""; int recordCount = 0; int subjectId; switch (this._state) { case TimetableSelectionStates.UniqueYeargroup: this.SetSearchTerm(); sqlPath = "/Sql/Specific/Staff/Modify/Teaching/Timetable/Selection/yeargroups.sql"; break; case TimetableSelectionStates.UniqueRoom: this.SetSearchTerm(); sqlPath = "/Sql/Specific/Staff/Modify/Teaching/Timetable/Selection/rooms.sql"; break; case TimetableSelectionStates.ClassSubject: this.SetSearchTerm(); sqlPath = "/Sql/Specific/Staff/Modify/Teaching/Timetable/Selection/subjects.sql"; break; case TimetableSelectionStates.ClassQualification: this.GetId(out subjectId); paramBuilder.AddParameter(SqlDbType.Int, "@SubjectId", subjectId); this.SetSearchTerm(); sqlPath = "/Sql/Specific/Staff/Modify/Teaching/Timetable/Selection/qualifications.sql"; break; case TimetableSelectionStates.ClassClass: this.GetId(out subjectId); this.SetSearchTerm(); paramBuilder.AddParameter(SqlDbType.Int, "@SubjectQualificationId", subjectId); sqlPath = "/Sql/Specific/Staff/Modify/Teaching/Timetable/Selection/classes.sql"; break; case TimetableSelectionStates.ClassRoom: this.SetSearchTerm(); sqlPath = "/Sql/Specific/Staff/Modify/Teaching/Timetable/Selection/rooms.sql"; break; } paramBuilder.AddParameter(SqlDbType.VarChar, "@SearchTerm", this._searchTerm); switch (this._state) { case TimetableSelectionStates.UniqueRoom: case TimetableSelectionStates.ClassRoom: Core.Helpers.Elements.RecordLists.Record noRoomRecord = new Core.Helpers.Elements.RecordLists.Record(); noRoomRecord.Colour = Core.Helpers.Elements.RecordLists.Colours.Yellow; noRoomRecord.LeftSide.Image.Source = "nodoor.png"; noRoomRecord.LeftSide.Image.ToolTip = "Teaching does not take place in a room"; noRoomRecord.LeftSide.MainText = "<em>Teaching does not take place in a room</em>"; if (this._state.Equals(TimetableSelectionStates.UniqueRoom)) { noRoomRecord.OnClick = "setUniqueRoom();"; } else { noRoomRecord.OnClick = "setClassRoom();"; } recordCollection.Add(noRoomRecord); break; } using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader(sqlPath, paramBuilder.Parameters)) { if (dataReader.HasRows) { while (dataReader.Read()) { switch (this._state) { case TimetableSelectionStates.UniqueYeargroup: Core.Helpers.Elements.RecordLists.Record yeargroupRecord = new Core.Helpers.Elements.RecordLists.Record(); yeargroupRecord.LeftSide.Image.Source = "yeargroup.png"; yeargroupRecord.LeftSide.Image.ToolTip = "Yeargroup"; yeargroupRecord.LeftSide.MainText = dataReader["Name"] as string; yeargroupRecord.OnClick = "setUniqueYeargroup('" + dataReader["Name"] as string + "', " + (int)dataReader["Id"] + ");"; recordCount++; recordCollection.Add(yeargroupRecord); break; case TimetableSelectionStates.UniqueRoom: case TimetableSelectionStates.ClassRoom: Core.Helpers.Elements.RecordLists.Record roomRecord = new Core.Helpers.Elements.RecordLists.Record(); roomRecord.LeftSide.Image.Source = "door.png"; roomRecord.LeftSide.Image.ToolTip = "Room"; roomRecord.LeftSide.MainText = dataReader["Name"] as string; if (this._state.Equals(TimetableSelectionStates.UniqueRoom)) { roomRecord.OnClick = "setUniqueRoom('" + dataReader["Name"] as string + "', " + (int)dataReader["Id"] + ");"; } else { roomRecord.OnClick = "setClassRoom('" + dataReader["Name"] as string + "', " + (int)dataReader["Id"] + ");"; } recordCount++; recordCollection.Add(roomRecord); break; case TimetableSelectionStates.ClassSubject: Core.Helpers.Elements.RecordLists.Record subjectRecord = new Core.Helpers.Elements.RecordLists.Record(); subjectRecord.LeftSide.Image.Source = "subject.png"; subjectRecord.LeftSide.Image.ToolTip = "Subject"; subjectRecord.LeftSide.MainText = dataReader["Name"] as string; string subjectName; if (string.IsNullOrEmpty(dataReader["Abbreviation"] as string)) { subjectName = dataReader["Name"] as string; } else { subjectName = dataReader["Abbreviation"] as string; } subjectRecord.OnClick = "setClassSubject('" + subjectName + "', " + (int)dataReader["Id"] + ");"; recordCount++; recordCollection.Add(subjectRecord); break; case TimetableSelectionStates.ClassQualification: Core.Helpers.Elements.RecordLists.Record qualificationRecord = new Core.Helpers.Elements.RecordLists.Record(); qualificationRecord.LeftSide.Image.Source = "lightbulb.png"; qualificationRecord.LeftSide.Image.ToolTip = "Qualification"; qualificationRecord.LeftSide.MainText = dataReader["Name"] as string; qualificationRecord.OnClick = "setClassQualification('" + dataReader["Name"] as string + "', " + (int)dataReader["Id"] + ");"; recordCount++; recordCollection.Add(qualificationRecord); break; case TimetableSelectionStates.ClassClass: Core.Helpers.Elements.RecordLists.Record classRecord = new Core.Helpers.Elements.RecordLists.Record(); classRecord.LeftSide.Image.Source = "class.png"; classRecord.LeftSide.Image.ToolTip = "Class"; classRecord.LeftSide.MainText = dataReader["Name"] as string; classRecord.OnClick = "setClassClass('" + dataReader["Name"] as string + "', " + (int)dataReader["Id"] + ");"; recordCount++; recordCollection.Add(classRecord); break; } } this.Page.Contents = recordCollection.ToString(); } else { switch (this._state) { case TimetableSelectionStates.UniqueYeargroup: Core.Helpers.Elements.Alerts.Alert noYeargroupsAlert = new Core.Helpers.Elements.Alerts.Alert("NoYeargroups"); noYeargroupsAlert.Colour = Core.Helpers.Elements.Alerts.Colours.Yellow; noYeargroupsAlert.Message = new Core.Helpers.Constructor("/Alerts/Specific/Staff/Modify/Teaching/Period/Selection/noyeargroups.html").ToString(); this.Page.Contents = noYeargroupsAlert.ToString(); break; case TimetableSelectionStates.UniqueRoom: case TimetableSelectionStates.ClassRoom: this.Page.Contents = recordCollection.ToString(); break; case TimetableSelectionStates.ClassSubject: Core.Helpers.Elements.Alerts.Alert noSubjectsAlert = new Core.Helpers.Elements.Alerts.Alert("NoSubjects"); noSubjectsAlert.Colour = Core.Helpers.Elements.Alerts.Colours.Yellow; noSubjectsAlert.Message = new Core.Helpers.Constructor("/Alerts/Specific/Staff/Modify/Teaching/Period/Selection/nosubjects.html").ToString(); this.Page.Contents = noSubjectsAlert.ToString(); break; case TimetableSelectionStates.ClassQualification: Core.Helpers.Elements.Alerts.Alert noQualificationsAlert = new Core.Helpers.Elements.Alerts.Alert("NoQualifications"); noQualificationsAlert.Colour = Core.Helpers.Elements.Alerts.Colours.Yellow; noQualificationsAlert.Message = new Core.Helpers.Constructor("/Alerts/Specific/Staff/Modify/Teaching/Period/Selection/noqualifications.html").ToString(); this.Page.Contents = noQualificationsAlert.ToString(); break; case TimetableSelectionStates.ClassClass: Core.Helpers.Elements.Alerts.Alert noClassesAlert = new Core.Helpers.Elements.Alerts.Alert("NoClasses"); noClassesAlert.Colour = Core.Helpers.Elements.Alerts.Colours.Yellow; noClassesAlert.Message = new Core.Helpers.Constructor("/Alerts/Specific/Staff/Modify/Teaching/Period/Selection/noclasses.html").ToString(); this.Page.Contents = noClassesAlert.ToString(); break; } } } string statusMessage = ""; switch (this._state) { case TimetableSelectionStates.UniqueYeargroup: if (recordCount.Equals(0)) { statusMessage = "Found no yeargroups!"; } else if (recordCount.Equals(1)) { statusMessage = "Found <strong>1</strong> yeargroup"; } else { statusMessage = "Found <strong>" + recordCount + "</strong> yeargroups"; } break; case TimetableSelectionStates.UniqueRoom: case TimetableSelectionStates.ClassRoom: if (recordCount.Equals(0)) { statusMessage = "Found no rooms!"; } else if (recordCount.Equals(1)) { statusMessage = "Found <strong>1</strong> room"; } else { statusMessage = "Found <strong>" + recordCount + "</strong> rooms"; } break; case TimetableSelectionStates.ClassSubject: if (recordCount.Equals(0)) { statusMessage = "Found no subjects!"; } else if (recordCount.Equals(1)) { statusMessage = "Found <strong>1</strong> subject"; } else { statusMessage = "Found <strong>" + recordCount + "</strong> subjects"; } break; case TimetableSelectionStates.ClassQualification: if (recordCount.Equals(0)) { statusMessage = "Found no qualifications!"; } else if (recordCount.Equals(1)) { statusMessage = "Found <strong>1</strong> qualification"; } else { statusMessage = "Found <strong>" + recordCount + "</strong> qualifications"; } break; case TimetableSelectionStates.ClassClass: if (recordCount.Equals(0)) { statusMessage = "Found no classes!"; } else if (recordCount.Equals(1)) { statusMessage = "Found <strong>1</strong> class"; } else { statusMessage = "Found <strong>" + recordCount + "</strong> classes"; } break; } if (Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage.ContainsKey("StaffTeachingTimetableSelection")) { Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage["StaffTeachingTimetableSelection"] = statusMessage; } else { Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage.Add("StaffTeachingTimetableSelection", statusMessage); } } else { if (this._success) { Core.Helpers.Elements.Alerts.Alert success = new Core.Helpers.Elements.Alerts.Alert("Success"); success.Colour = Core.Helpers.Elements.Alerts.Colours.Green; success.Message = new Core.Helpers.Constructor("/Alerts/Specific/Staff/Modify/Teaching/Period/Selection/success.html").ToString(); this.Page.Contents = success.ToString(); } else { Core.Helpers.Elements.Alerts.Alert noSelection = new Core.Helpers.Elements.Alerts.Alert("NoSelection"); noSelection.Colour = Core.Helpers.Elements.Alerts.Colours.Yellow; noSelection.Message = new Core.Helpers.Constructor("/Alerts/Specific/Staff/Modify/Teaching/Period/Selection/noselectionstate.html").ToString(); this.Page.Contents = noSelection.ToString(); } if (Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage.ContainsKey("StaffTeachingTimetableSelection")) { Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage["StaffTeachingTimetableSelection"] = ""; } else { Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage.Add("StaffTeachingTimetableSelection", ""); } } }
protected override void GenerateOutput() { if (this.HasStaffId()) { this.SetSearchTerm(); Core.Helpers.Database.ParameterBuilder paramBuilder = new Core.Helpers.Database.ParameterBuilder(); Core.Helpers.Elements.RecordLists.Collection recordCollection = new Core.Helpers.Elements.RecordLists.Collection(); recordCollection.Id = "Department"; paramBuilder.AddParameter(SqlDbType.Int, "@StaffId", this._staffId); paramBuilder.AddParameter(SqlDbType.VarChar, "@SearchTerm", this._searchTerm); using (SqlDataReader dataReader = Core.Helpers.Database.Provider.ExecuteReader("/Sql/Specific/Staff/Modify/Teaching/department.sql", paramBuilder.Parameters)) { dataReader.Read(); if (((bool)dataReader["Status"])) { dataReader.NextResult(); if (dataReader.HasRows) { int recordCount = 0; while (dataReader.Read()) { Core.Helpers.Elements.RecordLists.Record departmentRecord = new Core.Helpers.Elements.RecordLists.Record(); int departmentId = (int)dataReader["Id"]; departmentRecord.LeftSide.Image.Source = "books.png"; departmentRecord.LeftSide.Image.ToolTip = "Department"; departmentRecord.LeftSide.MainText = dataReader["Name"] as string; departmentRecord.Id = departmentId.ToString(); departmentRecord.OnClick = "getResponse('Department" + departmentId + "', '?path=/staff/modify/update/teaching/department/" + this._staffId + "/" + departmentId + "/', false, false, true);"; if ((bool)dataReader["IsSelected"]) { departmentRecord.Colour = Core.Helpers.Elements.RecordLists.Colours.Green; } else { departmentRecord.Colour = Core.Helpers.Elements.RecordLists.Colours.Blue; } recordCollection.Add(departmentRecord); recordCount++; } this.Page.Contents = recordCollection.ToString(); if (Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage.ContainsKey("StaffTeachingDepartmentSelection")) { Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage["StaffTeachingDepartmentSelection"] = recordCount; } else { Core.WebServer.PleaseTakes.Session.CurrentInstance.TemporaryStorage.Add("StaffTeachingDepartmentSelection", recordCount); } } else { Core.Helpers.Elements.Alerts.Alert noResultsAlert = new Core.Helpers.Elements.Alerts.Alert("NoResults"); noResultsAlert.Colour = Core.Helpers.Elements.Alerts.Colours.Yellow; noResultsAlert.Message = new Core.Helpers.Constructor("/Alerts/Specific/Staff/Modify/Teaching/Department/noresults.html").ToString(); this.Page.Contents = noResultsAlert.ToString(); } } else { Core.Helpers.Elements.Alerts.Alert invalidAlert = new Core.Helpers.Elements.Alerts.Alert("InvalidDetails"); invalidAlert.Colour = Core.Helpers.Elements.Alerts.Colours.Red; invalidAlert.Message = new Core.Helpers.Constructor("/Alerts/Specific/Staff/Modify/Teaching/Department/invalid.html").ToString(); this.Page.Contents = invalidAlert.ToString(); } } } else { Core.Helpers.Elements.Alerts.Alert missingAlert = new Core.Helpers.Elements.Alerts.Alert("MissingDetails"); missingAlert.Colour = Core.Helpers.Elements.Alerts.Colours.Red; missingAlert.Message = new Core.Helpers.Constructor("/Alerts/Specific/Staff/Modify/Teaching/Department/missing.html").ToString(); this.Page.Contents = missingAlert.ToString(); } }