private void Modify_Click(object sender, RoutedEventArgs e) { Ring.IsActive = true; if (EventList.SelectedIndex >= 0) { Ring.IsActive = false; No_Events.Visibility = Visibility.Collapsed; int index = EventList.SelectedIndex; EditObject obj1 = obj[index]; SelectedEvent s = new SelectedEvent(); s.obj = obj1; s.token = token; this.Frame.Navigate(typeof(Edit), s); } else { Ring.IsActive = false; No_Events.Visibility = Visibility.Visible; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { s = (SelectedEvent)e.Parameter; obj = s.obj; token = s.token; if (obj.eventType == "Technical") { Type.SelectedIndex = 0; Department.IsEnabled = true; if (obj.department.ToString() == "Computer/IT") { Department.SelectedIndex = 0; } else if (obj.department.ToString() == "Civil") { Department.SelectedIndex = 1; } else if (obj.department.ToString() == "Electrical") { Department.SelectedIndex = 2; } else if (obj.department.ToString() == "Mechanical/Production") { Department.SelectedIndex = 3; } else { Department.SelectedIndex = 4; } } else if (obj.eventType == "Non-Technical") { Type.SelectedIndex = 1; Department.IsEnabled = false; } else if (obj.eventType == "Cultural") { Type.SelectedIndex = 2; Department.IsEnabled = false; } else if (obj.eventType == "Treasure_Hunt") { Type.SelectedIndex = 3; Department.IsEnabled = false; } else if (obj.eventType == "Girls") { Type.SelectedIndex = 4; Department.IsEnabled = false; } else { Type.SelectedIndex = 5; Department.IsEnabled = false; } TextBox1.Text = obj.eventName.ToString(); TextBox2.Text = obj.tagline.ToString(); TextBox3.TextWrapping = TextWrapping.Wrap; TextBox3.Text = obj.description.ToString(); TextBox4.Text = obj.teamSize.ToString(); TextBox5.Text = obj.entryFee.ToString(); List <int> prizeList = obj.prizeMoney.ToList(); Winner.Text = prizeList[0].ToString(); Runner_Up.Text = prizeList[1].ToString(); List <Manager> m1 = obj.managers.ToList(); TextBox6.TextWrapping = TextWrapping.Wrap; TextBox6.Text = m1[0].name.ToString(); TextBox7.TextWrapping = TextWrapping.Wrap; TextBox7.Text = m1[0].phone.ToString(); TextBox8.TextWrapping = TextWrapping.Wrap; TextBox8.Text = obj.rounds[0].ToString(); TextBox6.TextWrapping = TextWrapping.Wrap; m_Count = m1.Count() + 1; r_Count = obj.rounds.Count + 1; j = 1; i = 2; while (i < m_Count) { Warning1.Visibility = Visibility.Collapsed; TextBlock tb = new TextBlock(); tb.Name = "Manager" + i; tb.Text = "Manager " + i; tb.Margin = new Thickness(0, 10, 0, 0); tb.HorizontalAlignment = HorizontalAlignment.Stretch; tb.VerticalAlignment = VerticalAlignment.Stretch; tb.Foreground = TextBox1.Foreground; Manager.Children.Add(tb); Rounds.UpdateLayout(); TextBox t = new TextBox(); t.Name = "ManagerName" + i; t.PlaceholderText = "Name"; t.Text = m1[j].name.ToString(); t.HorizontalAlignment = HorizontalAlignment.Stretch; t.VerticalAlignment = VerticalAlignment.Stretch; t.Margin = new Thickness(0, 10, 0, 0); t.Foreground = TextBox1.Foreground; t.TextWrapping = TextWrapping.Wrap; Manager.Children.Add(t); Rounds.UpdateLayout(); TextBox n = new TextBox(); n.Name = "Number" + i; n.PlaceholderText = "Phone Number"; n.Text = m1[j].phone.ToString(); n.HorizontalAlignment = HorizontalAlignment.Stretch; n.VerticalAlignment = VerticalAlignment.Stretch; n.Margin = new Thickness(0, 10, 0, 0); n.Foreground = TextBox1.Foreground; n.TextWrapping = TextWrapping.Wrap; Manager.Children.Add(n); Rounds.UpdateLayout(); j++; i++; } j = 1; i = 2; while (i < r_Count) { Warning2.Visibility = Visibility.Collapsed; TextBox t = new TextBox(); t.Name = "Round" + i; t.PlaceholderText = "Round " + i; t.Text = obj.rounds[j].ToString(); t.HorizontalAlignment = HorizontalAlignment.Stretch; t.VerticalAlignment = VerticalAlignment.Stretch; t.Height = 100; t.Margin = new Thickness(0, 10, 0, 0); t.Foreground = TextBox1.Foreground; t.TextWrapping = TextWrapping.Wrap; Rounds.Children.Add(t); Rounds.UpdateLayout(); j++; i++; } }