示例#1
0
        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();
        }
示例#2
0
        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();
            }
        }