//Set first responder arrival time private void FirstResponder_Click(object sender, RoutedEventArgs e) { TextBoxHandler.setNow(FirstResponderArrivalhh, FirstResponderArrivalmm); try { if (intervention.getCall911Time() != DateTime.MinValue) { int hh = int.Parse(FirstResponderArrivalhh.Text); int mm = int.Parse(FirstResponderArrivalmm.Text); DateTime startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, hh, mm, DateTime.Now.Second); intervention.setFirstResponderArrivalTime(startTime); int offset = (int)DateTime.Now.Subtract(startTime).TotalMinutes; if (offset < 0) { MessageBox.Show(ETD.Properties.Resources.MessageBox_Notification_FutureTime); } intervention.ResourceModified(); } } catch (Exception ex) { MessageBox.Show(ETD.Properties.Resources.MessageBox_Notification_InvalidTime); } }
//Set 911 call time private void Call_Click(object sender, RoutedEventArgs e) { TextBoxHandler.setNow(Call911hh, Call911mm); try { int hh = int.Parse(Call911hh.Text); int mm = int.Parse(Call911mm.Text); DateTime startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, hh, mm, DateTime.Now.Second); intervention.setCall911Time(startTime); intervention.ResourceModified(); int offset = (int)DateTime.Now.Subtract(startTime).TotalSeconds; if (offset < 0) { MessageBox.Show(ETD.Properties.Resources.MessageBox_Notification_FutureTime); } else { } } catch (Exception ex) { MessageBox.Show(ETD.Properties.Resources.MessageBox_Notification_InvalidTime); } }
//Called when the colon in the arrival column is clicked private void Arrival_Click(object sender, RoutedEventArgs e) { if (arrivalHHTextBox.Text.Equals("hh")) { TextBoxHandler.setNow(arrivalHHTextBox, arrivalMMTextBox); } try { int hh = int.Parse(arrivalHHTextBox.Text); int mm = int.Parse(arrivalMMTextBox.Text); DateTime endTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, hh, mm, DateTime.Now.Second); int offset = (int)DateTime.Now.Subtract(endTime).TotalMinutes; if (offset < 0) { MessageBox.Show(ETD.Properties.Resources.MessageBox_Notification_FutureTime); } else { resource.setArrival(endTime); } } catch (Exception ex) { MessageBox.Show(ETD.Properties.Resources.MessageBox_Notification_InvalidTime); } resource.getTeam().setStatus("intervening"); }
//Called when we lose focus on text boxes private void TextBoxes_LostFocus(object sender, RoutedEventArgs e) { TextBoxHandler.LostFocus(sender, e); if (((TextBox)sender == CallerName) && !this.CallerName.Text.Equals(ETD.Properties.Resources.TextBox_CallerName)) { intervention.setCallerName(this.CallerName.Text); } if (((TextBox)sender == Location) && !this.Location.Text.Equals(ETD.Properties.Resources.TextBox_Location)) { intervention.setLocation(this.Location.Text); } if (((TextBox)sender == NatureOfCall) && !this.NatureOfCall.Text.Equals(ETD.Properties.Resources.TextBox_Nature)) { intervention.setNatureOfCall(this.NatureOfCall.Text); } if (((TextBox)sender == Age) && !this.Age.Text.Equals("")) { intervention.setAge(this.Age.Text); } if (((TextBox)sender == OtherChiefComplaint) && !this.OtherChiefComplaint.Text.Equals("")) { intervention.setOtherChiefComplaint(OtherChiefComplaint.Text); } if (((TextBox)sender == Callhh) || ((TextBox)sender == Callmm)) { int hh = int.Parse(Callhh.Text); int mm = int.Parse(Callmm.Text); DateTime timeOfCall = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, hh, mm, 0); intervention.setTimeOfCall(timeOfCall); } }
//Sets the current hours and minutes in the passed TextBoxes public void TimeStampCompletion_Click(object sender, RoutedEventArgs e) { Button bt = (Button)sender; TextBoxHandler.setNow(completionTimestampMap[bt.Name + rowNumber][0], completionTimestampMap[bt.Name + rowNumber][1]); request.setCompletionHH(completionTimestampMap[bt.Name + rowNumber][0].Text.ToString()); request.setCompletionMM(completionTimestampMap[bt.Name + rowNumber][1].Text.ToString()); }
//Sets the current hours and minutes in the passed TextBoxes public void TimestampTime_Click(object sender, RoutedEventArgs e) { Button bt = (Button)sender; TextBoxHandler.setNow(timestampMap[bt.Name + rowNumber][0], timestampMap[bt.Name + rowNumber][1]); request.setTimeHH(timestampMap[bt.Name + rowNumber][0].Text.ToString()); request.setTimeMM(timestampMap[bt.Name + rowNumber][1].Text.ToString()); }
//Sets the current hours and minutes in the passed TextBoxes public void TimestampFollowUp_Click(object sender, RoutedEventArgs e) { Button bt = (Button)sender; TextBoxHandler.setNow(followupTimestampMap[bt.Name + rowNumber][0], followupTimestampMap[bt.Name + rowNumber][1]); request.setFollowUpHH(followupTimestampMap[bt.Name + rowNumber][0].Text.ToString()); request.setFollowUpMM(followupTimestampMap[bt.Name + rowNumber][1].Text.ToString()); }
//Called on additional info text box lost focus private void AdditionalInformation_GotFocus(object sender, RoutedEventArgs e) { TextBox tb = (TextBox)sender; if (tb.Text.Equals("")) { TextBoxHandler.setNow(timestampMap[equivalentKeyMap[tb.Name]][0], timestampMap[equivalentKeyMap[tb.Name]][1]); } }
//Called when the textboxes lose focus private void TextBoxes_LostFocus(object sender, RoutedEventArgs e) { TextBoxHandler.LostFocus(sender, e); //If the textbox is for the a request field, update the request if ((TextBox)sender == requestTextBox) { UpdateRequest(); } }
//Called when the textboxes lose focus private void TextBoxes_LostFocus(object sender, RoutedEventArgs e) { TextBoxHandler.LostFocus(sender, e); //If the textbox is for the resource name, update the resource if ((TextBox)sender == resourceNameTextBox) { UpdateResource(); } }
//Setup initial form private void FillForm(Intervention intervention) { if (intervention.getCallerName() != null) { CallerName.Text = intervention.getCallerName(); } if (intervention.getLocation() != null) { Location.Text = intervention.getLocation(); } if (intervention.getNatureOfCall() != null) { NatureOfCall.Text = intervention.getNatureOfCall(); } if (intervention.getAge() != null) { Age.Text = intervention.getAge(); } if (intervention.getCode() != 0) { Priority.SelectedIndex = intervention.getCode() - 1; } if (intervention.getGender() != null) { int index = -1; foreach (ComboBoxItem cb in Gender.Items) { index++; if (cb.Content.ToString() == intervention.getGender()) { break; } } Gender.SelectedIndex = index; } if (intervention.getChiefComplaint() != null) { int index = -1; foreach (ComboBoxItem cb in Complaint.Items) { index++; if (cb.Content.ToString() == intervention.getChiefComplaint()) { break; } } Complaint.SelectedIndex = index; } if (intervention.getTimeOfCall() != null) { TextBoxHandler.setTime(Callhh, Callmm, intervention.getTimeOfCall().Hour, intervention.getTimeOfCall().Minute); } }
//Set conclusion time of an intervention private void End_Click(object sender, RoutedEventArgs e) { TextBoxHandler.setNow(Endhh, Endmm); try { int hh = int.Parse(Endhh.Text); int mm = int.Parse(Endmm.Text); DateTime concTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, hh, mm, DateTime.Now.Second); intervention.setConclusionTime(concTime); intervention.ResourceModified(); } catch { } }
//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)); }
//Called When we lost focus on text boxes private void TextBoxes_LostFocus(object sender, RoutedEventArgs e) { try { DateTime concTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Convert.ToInt32(Endhh.Text), Convert.ToInt32(Endmm.Text), 0); intervention.setConclusionTime(concTime); } catch { } intervention.setConclusionAdditionalInfo(AdditionalInformation.Text); intervention.setAmbulanceCompany(AmbulanceCompany.Text); intervention.setAmbulanceVehicle(AmbulanceVehicle.Text); intervention.setFirstResponderCompany(FirstResponderCompany.Text); intervention.setFirstResponderVehicle(FirstResponderVehicle.Text); intervention.setMeetingPoint(MeetingPoint.Text); TextBoxHandler.LostFocus(sender, e); }
//Setup initial form private void FillForm(Intervention intervention) { AdditionalInformation.Text = intervention.getConclusionAdditionalInfo(); if (intervention.getConclusion() != null) { int index = 0; foreach (ComboBoxItem cb in ConclusionBox.Items) { index++; if (cb.Content.ToString() == intervention.getConclusion()) { break; } } ConclusionBox.SelectedIndex = index - 1; } if (intervention.getConclusionTime().Hour != 0 && intervention.getConclusionTime().Minute != 0) { TextBoxHandler.setTime(Endhh, Endmm, intervention.getConclusionTime().Hour, intervention.getConclusionTime().Minute); } if (intervention.getConclusion() == Properties.Resources.ComboBoxItem_Conclusion_911) { if (intervention.getCall911Time().Hour != 0 && intervention.getCall911Time().Minute != 0) { TextBoxHandler.setTime(Call911hh, Call911mm, intervention.getCall911Time().Hour, intervention.getCall911Time().Minute); } if (intervention.getFirstResponderArrivalTime().Hour != 0 && intervention.getFirstResponderArrivalTime().Minute != 0) { TextBoxHandler.setTime(FirstResponderArrivalhh, FirstResponderArrivalmm, intervention.getFirstResponderArrivalTime().Hour, intervention.getFirstResponderArrivalTime().Minute); } if (intervention.getAmbulanceArrivalTime().Hour != 0 && intervention.getAmbulanceArrivalTime().Minute != 0) { TextBoxHandler.setTime(AmbulanceArrivalhh, AmbulanceArrivalmm, intervention.getAmbulanceArrivalTime().Hour, intervention.getAmbulanceArrivalTime().Minute); } AmbulanceCompany.Text = intervention.getAmbulanceCompany(); AmbulanceVehicle.Text = intervention.getAmbulanceVehicle(); FirstResponderCompany.Text = intervention.getFirstResponderCompany(); FirstResponderVehicle.Text = intervention.getFirstResponderVehicle(); MeetingPoint.Text = intervention.getMeetingPoint(); } }
//Update fields private void SelectionChanged(object sender, SelectionChangedEventArgs e) { //By default, for all selections, the ambulance form is hidden MainGrid.RowDefinitions[1].Height = new GridLength(0); MainGrid.RowDefinitions[2].Height = new GridLength(0); MainGrid.RowDefinitions[3].Height = new GridLength(0); MainGrid.RowDefinitions[4].Height = new GridLength(0); ComboBox comboBox = (ComboBox)sender; ComboBoxItem item = (ComboBoxItem)comboBox.SelectedItem; intervention.setConclusion(item.Content.ToString()); if (item.Name.Equals("call911") || item.Name.Equals("other") || item.Name.Equals("doctor")) { Grid.SetColumnSpan(ComboBoxBorder, 1); AdditionalInformationBorder.Visibility = Visibility.Visible; if (item.Name.Equals("call911")) { AdditionalInformation.Text = intervention.getConclusionAdditionalInfo(); //If the ambulance requires an ambulance, show the ambulance form MainGrid.RowDefinitions[1].Height = new GridLength(1, GridUnitType.Star); MainGrid.RowDefinitions[2].Height = new GridLength(1, GridUnitType.Star); MainGrid.RowDefinitions[3].Height = new GridLength(1, GridUnitType.Star); MainGrid.RowDefinitions[4].Height = new GridLength(1, GridUnitType.Star); } else if (item.Name.Equals("other")) { AdditionalInformation.Text = ETD.Properties.Resources.TextBox_AdditionalInformation_Conclusion; } else if (item.Name.Equals("doctor")) { AdditionalInformation.Text = ETD.Properties.Resources.TextBox_AdditionalInformation_Hospital; } TextBoxHandler.ResetHandling(AdditionalInformation); } else { AdditionalInformationBorder.Visibility = Visibility.Collapsed; Grid.SetColumnSpan(ComboBoxBorder, 2); } selectionChanged = true; }
//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); }
//Called when we get focus on text boxxes private void TextBoxes_GotFocus(object sender, RoutedEventArgs e) { TextBoxHandler.GotFocus(sender, e); }
//Set up time to current time public void Timestamp_Click(object sender, RoutedEventArgs e) { Button bt = (Button)sender; TextBoxHandler.setNow(timestampMap[bt.Name][0], timestampMap[bt.Name][1]); }
/// <summary> /// 计算评分的方法 /// </summary> public void CalculateRiskAssessmentData() { //获取相关控件 if (_text1 == null || _text2 == null || _text3 == null || _text4 == null) { foreach (IUIElementHandler handler in base.MedicalPaperUIElementHandlers) { if (handler is TextBoxHandler) { TextBoxHandler h = handler as TextBoxHandler; foreach (MTextBox text in h.GetCurrentControls) { if (text.Name.Trim() == "MTextBox6") { _text1 = text; } else if (text.Name.Trim() == "MTextBox7") { _text2 = text; } else if (text.Name.Trim() == "MTextBox8") { _text3 = text; } else if (text.Name.Trim() == "MTextBox11") { _text4 = text; } else if (text.Name.Trim() == "MTxt_Steward") { _text5 = text; } } break; } } } // 计算手术切口清洁程度 if (_text1 != null) { _text1.Text = string.Empty; this.SetControlValue(_groupCustomControls["手术切口清洁程度"], _text1); } // 计算麻醉ASA分级 if (_text2 != null) { _text2.Text = string.Empty; this.SetControlValue(_groupCustomControls["ASA分级"], _text2); } // 计算手术持续时间 if (_text3 != null) { _text3.Text = string.Empty; this.SetControlValue(_groupCustomControls["手术持续时间"], _text3); } // 恢复室Steward苏醒评分 if (_text5 != null) { _text5.Text = string.Empty; this.SetGroupControlValue(_groupCustomControls["恢复室Steward苏醒评分"], _text5); } // 计算总分 if (_text4 != null) { _text4.Text = "0"; if (!string.IsNullOrEmpty(_text1.Text.Trim())) { _text4.Text = (Convert.ToInt32(_text4.Text) + Convert.ToInt32(_text1.Text.Trim())).ToString(); } if (!string.IsNullOrEmpty(_text2.Text.Trim())) { _text4.Text = (Convert.ToInt32(_text4.Text) + Convert.ToInt32(_text2.Text.Trim())).ToString(); } if (!string.IsNullOrEmpty(_text3.Text.Trim())) { _text4.Text = (Convert.ToInt32(_text4.Text) + Convert.ToInt32(_text3.Text.Trim())).ToString(); } _nnisControl.SimpleValue = Convert.ToInt32(_text4.Text.Trim()); } }
//Called when the textboxes lose focus private void AdditionalTextInputTextBoxOnLostFocus(object sender, RoutedEventArgs e) { TextBoxHandler.LostFocus(sender, e); }
//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++; } }