DFT Shift Planner

DFT Shift Planner

An appliation I created to check shifts for the team

Background

In January 2017, our office changed its core hours and we started a 10-week rotating shift pattern. This was initially a trial for 3 months, and if we ran into problems our shifts would be changed to a different, less favourable 10-week pattern.

The systems used by the whole force didn’t have the ability to show us what hours we were due work each week, and other members of the office had resorted to creating charts in a spreadsheet and pinned them up by their desk like barbarians.

I took it upon myself to create a tool which could work out what shift each person in the office was on for any given week in the year. My goal was to create this and distribute it to every member of my team including our Team Leaders, in order for our trial to have the most chance of success. After I showed an early working version to my Team Leader, he was thrilled as this would save him a lot of trouble trying to work out who was in at what time, and made planning a lot easier. The initial features I had planned were expanded to include our Team Leaders 6-week pattern, as well as giving them the ability to see all members of the teams shifts for the next 5 weeks. The completed tool was made available to all members of the office, and with its assistance we were able to complete our 3-month trial without any problems.

A look around the application

Various screenshots showing the different tabs

The tool has a very intuitive and user-friendly design. On the settings tab you’re able to assign a name to overwrite each shift starting week number, as well as setting your default tab, toggling which tabs you would like to see and setting your starting week. Hovering over items brings up tool-tips with more information on what they do.

Once you’ve tweaked your settings, selecting either the Personal 10-week or Personal 6-week tab will show you what shifts the person in the dropdown box is on for the next 5 weeks from today’s date, as well as giving you a calendar for selecting any date in the future. Below the calendar there are buttons for quickly selecting todays date, and for seeing which weekend the selected person will work next. The current day is also surrounded by a red border to make it stand out.

Screenshots showing the "All Analyst view"

The All Analyst view tab is similar to the previously mentioned 2 tabs, but has checkboxes at the top for toggling on and off individual weeks, and has a slimline drop-down calendar. This page has proven to be very useful for our Team Leaders, allowing them to plan meetings and training sessions with ease.

To work out what shift any given person will be on each week, the tool calculates an offset of the number of weeks that has passed since we started the shift plan, add this to the selected starting week to get the number of the current shift, and then looks up to see what the actual shift is and writes the next 5 weeks into the grid.

For the All Analyst view tab, it uses the same logic as the two individual tabs but calculates the next 5 weeks for all 10 of the grids, and dynamically updates each of the 400 labels with the correct values.

Code snippet

/// <summary>
/// 
/// </summary>
/// <param name="WeeksX5ToDraw">The amount of grids to draw showing the next 5 weeks</param>
/// <param name="SixOrTen">Defines which shift pattern, 6 or 10 week</param>
/// <param name="DayToCheck">The amount of days that has passed since 02/01/2017, the start of the shift pattern</param>
private void PopulateWindowX(int WeeksX5ToDraw, int SixOrTen, int DayToCheck)
{
    Label DrawLabel = (Label)this.FindName("");
    TextBlock DrawTextblock = (TextBlock)this.FindName("");    
    int FirstDigit = SixOrTen;
    int ShiftStartWeek = 1;    
    int origShiftStartWeek = ShiftStartWeek;

    // Draws each grid (Group of 5 weeks)
    for (int SecondDigit = 1; SecondDigit <= WeeksX5ToDraw; SecondDigit++)
    {
        int AddDays = 0;
        // Draws each week
        for (int ThirdDigit = 1; ThirdDigit <= 5; ThirdDigit++)
        {                    
            int DayNo = 0;
            int CurrentShiftNo = CheckWeek(DayToCheck, SixOrTen, ShiftStartWeek);
            // Draws each day
            foreach (string Day in Weekdays)
            {         
            	//Creates a reference to the current days label. Format is: (Monday-Sunday)10_(1-10)_(1-5),
                DrawLabel = (Label)this.FindName(Day + FirstDigit + "_" + SecondDigit + "_" + ThirdDigit);
                Dictionary<string, List<string>> ShiftsX = Shifts10;
                // Shifts6 / Shifts10 holds a list of the shifts for each week
                switch (FirstDigit)
                {
                    case 6:
                        ShiftsX = Shifts6;
                        break;
                    case 10:
                        ShiftsX = Shifts10;
                        break;
                    default:
                        MessageBox.Show("Error - ShiftsX");
                        break;
                }
                // Sets the labels text to the specified shift
                DrawLabel.Content = ShiftsX["Week " + CurrentShiftNo][DayNo];
                DayNo++;
            }
            ShiftStartWeek++;
            // Creates a reference to the current weeks label, and sets it to the date of the monday, and appends the shift number
            DrawTextblock = (TextBlock)this.FindName("Week" + FirstDigit + "_" + SecondDigit + "_" + ThirdDigit + "Label");         // See comment at start of for loop           
            DrawTextblock.Text = " " + ShiftStartDate.AddDays(ShiftDifferenceToNow.Days + AddDays).ToShortDateString() +" - Shift " + CurrentShiftNo + " ";
            AddDays += 7;
        }
        HighlightDay(FirstDigit, SecondDigit, 1);
        origShiftStartWeek++;
        ShiftStartWeek = origShiftStartWeek ;
    }
}