//Setup additional info timestamp list private void setupTimestampMap() { timestampMap.Add("Timestamp0", TextBoxHandler.textboxArray(Timestamphh0, Timestampmm0)); timestampMap.Add("Timestamp1", TextBoxHandler.textboxArray(Timestamphh1, Timestampmm1)); timestampMap.Add("Timestamp2", TextBoxHandler.textboxArray(Timestamphh2, Timestampmm2)); timestampMap.Add("Timestamp3", TextBoxHandler.textboxArray(Timestamphh3, Timestampmm3)); timestampMap.Add("Timestamp4", TextBoxHandler.textboxArray(Timestamphh4, Timestampmm4)); timestampMap.Add("Timestamp5", TextBoxHandler.textboxArray(Timestamphh5, Timestampmm5)); timestampMap.Add("Timestamp6", TextBoxHandler.textboxArray(Timestamphh6, Timestampmm6)); timestampMap.Add("Timestamp7", TextBoxHandler.textboxArray(Timestamphh7, Timestampmm7)); timestampMap.Add("Timestamp8", TextBoxHandler.textboxArray(Timestamphh8, Timestampmm8)); timestampMap.Add("Timestamp9", TextBoxHandler.textboxArray(Timestamphh9, Timestampmm9)); }
//Initialize the shift form private void PopulateShiftForm() { //Set up default shift properties currentShift = new Shift("-", "-", shiftDuration); shiftline = new ShiftLine(currentShift); shiftline.getStartTimeButton().Click += NextShiftTime; shiftline.getSectorNameTextBox().KeyDown += NewSector; RowDefinition sectorRowDefinition = new RowDefinition(); sectorRowDefinition.Height = new GridLength(50); Shifts_grid.RowDefinitions.Add(sectorRowDefinition); //populate sector Shifts_grid.Children.Add(shiftline.getSectorNameTextBox()); Grid.SetColumn(shiftline.getSectorNameTextBox(), 0); Grid.SetRow(shiftline.getSectorNameTextBox(), rowPosition); Grid.SetColumn(shiftline.getSectorNameBorder(), 0); Grid.SetRow(shiftline.getSectorNameBorder(), rowPosition); sectorMap.Add("Sector" + (rowPosition - 1).ToString(), shiftline.getSectorNameTextBox()); //populate team Shifts_grid.Children.Add(shiftline.getTeamNameTextBox()); Grid.SetColumn(shiftline.getTeamNameTextBox(), columnPosition); Grid.SetRow(shiftline.getTeamNameTextBox(), rowPosition); teamMap.Add("Team" + (teamNumber).ToString() + "Sector" + (sectorPosition - 1), shiftline.getTeamNameTextBox()); //populate time Shifts_grid.Children.Add(shiftline.getStartTimeBorder()); Grid.SetColumn(shiftline.getStartTimeBorder(), columnPosition); Grid.SetRow(shiftline.getStartTimeBorder(), 1); shiftStartTimeMap.Add("Start Time " + (columnPosition).ToString(), TextBoxHandler.textboxArray(shiftline.getStartTimeHHTextBox(), shiftline.getStartTimeMMTextBox())); }
//Populate the new request line with values public void populateRequestForm() { BuildLine(); //Set up the grid content of the follow up form PopulateLine(); //Set up default values of the follow up contents //Set up default shift properties request = new Request(init, init, init, init, init, init, init, init, init, init); requestline = new RequestLine(); RowDefinition sectorRowDefinition = new RowDefinition(); sectorRowDefinition.Height = new GridLength(40); followupPage.getRequestGrid().RowDefinitions.Add(sectorRowDefinition); //populate time followupPage.getRequestGrid().Children.Add(this.getTimeBorder()); Grid.SetColumn(this.getTimeBorder(), 0); Grid.SetRow(this.getTimeBorder(), rowNumber); timestampMap.Add("Time" + rowNumber, TextBoxHandler.textboxArray(this.getTimeHHTextBox(), this.getTimeMMTextBox())); //populate client followupPage.getRequestGrid().Children.Add(this.getClientNameTextBox()); Grid.SetColumn(this.getClientNameBorder(), 1); Grid.SetRow(this.getClientNameBorder(), rowNumber); Grid.SetColumn(this.getClientNameTextBox(), 1); Grid.SetRow(this.getClientNameTextBox(), rowNumber); clientMap.Add("Client" + rowNumber, this.getClientNameTextBox()); //populate recipient followupPage.getRequestGrid().Children.Add(this.getRecipientNameTextBox()); Grid.SetColumn(this.getRecipientNameBorder(), 2); Grid.SetRow(this.getRecipientNameBorder(), rowNumber); Grid.SetColumn(this.getRecipientNameTextBox(), 2); Grid.SetRow(this.getRecipientNameTextBox(), rowNumber); recipientMap.Add("Recipient" + rowNumber, this.getRecipientNameTextBox()); //populate request followupPage.getRequestGrid().Children.Add(this.getRequestNameTextBox()); Grid.SetColumn(this.getRequestNameBorder(), 3); Grid.SetRow(this.getRequestNameBorder(), rowNumber); Grid.SetColumn(this.getRequestNameTextBox(), 3); Grid.SetRow(this.getRequestNameTextBox(), rowNumber); requestMap.Add("Request" + rowNumber, this.getRequestNameTextBox()); //populate handled by followupPage.getRequestGrid().Children.Add(this.getHandledByNameTextBox()); Grid.SetColumn(this.getHandledByNameBorder(), 4); Grid.SetRow(this.getHandledByNameBorder(), rowNumber); Grid.SetColumn(this.getHandledByNameTextBox(), 4); Grid.SetRow(this.getHandledByNameTextBox(), rowNumber); handledbyMap.Add("HandledBy" + rowNumber, this.getHandledByNameTextBox()); //populate follow up followupPage.getRequestGrid().Children.Add(this.getFollowUpBorder()); Grid.SetColumn(this.getFollowUpBorder(), 5); Grid.SetRow(this.getFollowUpBorder(), rowNumber); followupTimestampMap.Add("FollowUpTimestamp" + rowNumber, TextBoxHandler.textboxArray(this.getFollowUpHHTextBox(), this.getFollowUpMMTextBox())); //populate completion followupPage.getRequestGrid().Children.Add(this.getCompletionBorder()); Grid.SetColumn(this.getCompletionBorder(), 6); Grid.SetRow(this.getCompletionBorder(), rowNumber); completionTimestampMap.Add("CompletionTimestamp" + rowNumber, TextBoxHandler.textboxArray(this.getCompletionHHTextBox(), this.getCompletionMMTextBox())); requestLineList.Add(this); }
//Predict the next shift time and team rotation public void NextShiftTime(object sender, RoutedEventArgs e) { rowPosition++; columnPosition++; teamNumber++; int sectorRowPosition = 2; shiftDuration = Convert.ToInt32(ShiftDuration.Text.ToString()); //Create a new shift ShiftLine newShift = new ShiftLine(currentShift); newShift.getStartTimeButton().Click += NextShiftTime; //Set up new shift properties ColumnDefinition colDefinition = new ColumnDefinition(); colDefinition.Width = new GridLength(172); Shifts_grid.ColumnDefinitions.Add(colDefinition); Shifts_grid.Children.Add(newShift.getStartTimeBorder()); Grid.SetColumn(newShift.getStartTimeBorder(), columnPosition); Grid.SetRow(newShift.getStartTimeBorder(), 1); shiftStartTimeMap.Add("Start Time " + (columnPosition).ToString(), TextBoxHandler.textboxArray(newShift.getStartTimeHHTextBox(), newShift.getStartTimeMMTextBox())); //Predict next shift String newShiftHH = shiftStartTimeMap["Start Time " + (columnPosition - 1).ToString()][0].Text.ToString(); String newShiftMM = shiftStartTimeMap["Start Time " + (columnPosition - 1).ToString()][1].Text.ToString(); bool isallDigitsNewShiftsHH = newShiftHH.All(char.IsDigit); bool isallDigitsNewShiftsMM = newShiftMM.All(char.IsDigit); if (!newShiftHH.Equals("hh") && !newShiftMM.Equals("mm")) { if (isallDigitsNewShiftsHH && isallDigitsNewShiftsMM) //If the time input is a number, predict next shift time { if ((Convert.ToInt32(newShiftMM) + shiftDuration) >= 60) //If the next shift time is higher than 60,Loop back to 0min plus the difference between the minutes fromt he old and new shift { int newMM = (Convert.ToInt32(newShiftMM) + shiftDuration) - 60; newShift.getStartTimeMMTextBox().Text = Convert.ToString(newMM); if (Convert.ToInt32(newShiftHH) == 12) //Loop back to 1am { newShift.getStartTimeHHTextBox().Text = "1"; } else { newShift.getStartTimeHHTextBox().Text = Convert.ToString(Convert.ToInt32(newShiftHH) + 1); } } else //Shift time is equal to the input time plus the shift duration { newShift.getStartTimeMMTextBox().Text = Convert.ToString(Convert.ToInt32(newShiftMM) + shiftDuration); newShift.getStartTimeHHTextBox().Text = Convert.ToString(Convert.ToInt32(newShiftHH)); } } } /*Team rotation * The next team to be assigned a sector(eg: sector 1) is the one that was responsible for the other sector (eg : sector 2)*/ int originalshiftpos = 2; int sector = 2; if (sectorMap.Count() == 1)//if there is only one sector and one team, no team rotation { ShiftLine newShift2 = new ShiftLine(currentShift); Shifts_grid.Children.Add(newShift2.getTeamNameTextBox()); Grid.SetColumn(newShift2.getTeamNameTextBox(), columnPosition); Grid.SetRow(newShift2.getTeamNameTextBox(), originalshiftpos); teamMap.Add("Team" + (teamNumber).ToString() + "Sector" + (sectorRowPosition - 1).ToString(), newShift2.getTeamNameTextBox()); } for (int i = 0; i < sectorMap.Count() && sectorMap.Count() > 1; i++)//if there is more than one sector, predict the next team that will be replacing the team currently assigned in that sector { ShiftLine newShift2 = new ShiftLine(currentShift); String rotatedTeam; Shifts_grid.Children.Add(newShift2.getTeamNameTextBox()); Grid.SetColumn(newShift2.getTeamNameTextBox(), columnPosition); Grid.SetRow(newShift2.getTeamNameTextBox(), originalshiftpos); teamMap.Add("Team" + (teamNumber).ToString() + "Sector" + (sectorRowPosition - 1).ToString(), newShift2.getTeamNameTextBox()); if ((sectorMap.Count()) == (sectorRowPosition - 1))//If the number of sectors is the same as the its row position, the next team assigned to the sector is the one that was responsible for the first sector { rotatedTeam = teamMap["Team" + (teamNumber - 1) + "Sector" + 1.ToString()].Text.ToString(); teamMap["Team" + (teamNumber).ToString() + "Sector" + (sectorRowPosition - 1).ToString()].Text = rotatedTeam; } else//The next team assigned to the sector is the one that was responsible for the one under it. eg: team A on sector 1 will be responsible for sector 2 and team B sector 2 will be responsible for sector 1 { rotatedTeam = teamMap["Team" + (teamNumber - 1) + "Sector" + (sector).ToString()].Text.ToString(); teamMap["Team" + (teamNumber).ToString() + "Sector" + (sectorRowPosition - 1).ToString()].Text = rotatedTeam; } sector++; sectorRowPosition++; originalshiftpos++; } }