public void AddRound_Click(object sender, RoutedEventArgs e) { try { if (r_Count > 5) { throw new Exception(); } { Warning2.Visibility = Visibility.Collapsed; TextBox t = new TextBox(); t.Name = "Round" + r_Count; t.PlaceholderText = "Round " + r_Count; t.HorizontalAlignment = HorizontalAlignment.Stretch; t.VerticalAlignment = VerticalAlignment.Stretch; t.Height = 100; t.TextWrapping = TextWrapping.Wrap; t.Margin = new Thickness(0, 10, 0, 0); t.Foreground = TextBox1.Foreground; Rounds.Children.Add(t); Rounds.UpdateLayout(); r_Count++; } } catch (Exception) { Warning2.Text = "Can not add more than 5 rounds"; Warning2.Visibility = Visibility.Visible; } }
public void Add_Manager(object sender, RoutedEventArgs e) { try { if (m_Count > 5) { throw new Exception(); } { Warning1.Visibility = Visibility.Collapsed; TextBlock tb = new TextBlock(); tb.Name = "Manager" + m_Count; tb.Text = "Manager " + m_Count; 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" + m_Count; t.PlaceholderText = "Name"; t.HorizontalAlignment = HorizontalAlignment.Stretch; t.VerticalAlignment = VerticalAlignment.Stretch; t.Margin = new Thickness(0, 10, 0, 0); t.TextWrapping = TextWrapping.Wrap; t.Foreground = TextBox1.Foreground; Manager.Children.Add(t); Rounds.UpdateLayout(); TextBox n = new TextBox(); n.Name = "Number" + m_Count; n.PlaceholderText = "Phone Number"; n.Margin = new Thickness(0, 10, 0, 0); n.HorizontalAlignment = HorizontalAlignment.Stretch; n.VerticalAlignment = VerticalAlignment.Stretch; n.Foreground = TextBox1.Foreground; n.TextWrapping = TextWrapping.Wrap; Manager.Children.Add(n); Rounds.UpdateLayout(); m_Count++; } } catch (Exception) { Warning1.Text = "Can not add more than 5 managers"; Warning1.Visibility = Visibility.Visible; } }
public void RemoveRound_Click(object sender, RoutedEventArgs e) { try { if (r_Count < 3) { throw new Exception(); } --r_Count; TextBox t = (TextBox)this.Rounds.FindName("Round" + (r_Count)); this.Rounds.Children.Remove(t); Rounds.UpdateLayout(); Warning2.Visibility = Visibility.Collapsed; } catch (Exception) { Warning2.Text = "Atleast one round is required"; Warning2.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++; } }