private void btnUpdateGroup_Click(object sender, RoutedEventArgs e) { if (grdServerGrid.SelectedIndex < 0) { return; } try { if (string.IsNullOrWhiteSpace(txtGroupLongname.Text) || string.IsNullOrWhiteSpace(txtGroupShortname.Text)) { AthleticsCommon.MsgBox("LongName and ShortName could not be null"); return; } else { ServerGroup serverGroup = grdServerGrid.SelectedItem as ServerGroup; DatabaseOperation.UpdateServerGroup(m_matchID, serverGroup.Order, txtGroupLongname.Text, txtGroupShortname.Text); m_serverGroup = DatabaseOperation.GetServerGroups(m_matchID); grdServerGrid.ItemsSource = m_serverGroup; txtGroupShortname.Text = ""; txtGroupLongname.Text = ""; } } catch { } }
private void btnDelPos_Click(object sender, RoutedEventArgs e) { if (AthleticsCommon.MsgBox("Are you sure to delete selected judge position?", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Cancel) { return; } if (grdSelJudge.SelectedIndex < 0) { AthleticsCommon.MsgBox("Please select a judge which you want to remove."); return; } JudgeInfo pos = grdSelJudge.SelectedItem as JudgeInfo; if (DatabaseOperation.DelMatchOfficial(m_matchID, pos.ServantNum)) { m_selJudge.RemoveAt(grdSelJudge.SelectedIndex); m_unSelJudge = DatabaseOperation.GetAvailableOfficial(m_matchID); grdUnSelJudge.ItemsSource = m_unSelJudge; FilterUnSelJudges(); } else { AthleticsCommon.ShowLastErrorBox(); } }
private void btnRemoveGroup_Click(object sender, RoutedEventArgs e) { if (AthleticsCommon.MsgBox("Are you sure to delete selected ServerGroup?", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Cancel) { return; } if (grdServerGrid.SelectedIndex < 0) { AthleticsCommon.MsgBox("Please select a ServerGroup which you want to remove."); return; } try { ServerGroup serverGroup = grdServerGrid.SelectedItem as ServerGroup; DatabaseOperation.DeleteServerGroup(m_matchID, serverGroup.Order); m_serverGroup = DatabaseOperation.GetServerGroups(m_matchID); grdServerGrid.ItemsSource = m_serverGroup; } catch { } }
private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Down) { e.Handled = true; TextBox tb = sender as TextBox; DataGridRow dgr = (DataGridRow)grdUnSelJudge.ItemContainerGenerator.ContainerFromIndex(0); if (dgr == null) { return; } grdUnSelJudge.SelectedIndex = 0; grdUnSelJudge.Focus(); DataGridCellsPresenter presenter = AthleticsCommon.GetVisualChild <DataGridCellsPresenter>(dgr); DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(1); if (cell != null) { cell.Focus(); } //dgr.Focus(); } }
private bool UpdateJudge() { if (grdUnSelJudge.SelectedIndex < 0) { AthleticsCommon.MsgBox("Please select a judge in left list!"); return(false); } if (grdSelJudge.SelectedIndex < 0) { AthleticsCommon.MsgBox("Please select a position in right list!"); return(false); } JudgeInfo judge = grdUnSelJudge.SelectedItem as JudgeInfo; JudgeInfo pos = grdSelJudge.SelectedItem as JudgeInfo; if (DatabaseOperation.UpdateMatchOfficial(m_matchID, pos.ServantNum, judge.RegisterID)) { m_unSelJudge = DatabaseOperation.GetAvailableOfficial(m_matchID); grdUnSelJudge.ItemsSource = m_unSelJudge; FilterUnSelJudges(); m_selJudge = DatabaseOperation.GetMatchOfficials(m_matchID, m_serverGroupID); grdSelJudge.ItemsSource = m_selJudge; } else { AthleticsCommon.ShowLastErrorBox(); return(false); } return(true); }
private void btnAddGroup_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(txtGroupLongname.Text) || string.IsNullOrWhiteSpace(txtGroupShortname.Text)) { AthleticsCommon.MsgBox("LongName and ShortName could not be null"); return; } else { DatabaseOperation.AddServerGroup(m_matchID, txtGroupLongname.Text, txtGroupShortname.Text); m_serverGroup = DatabaseOperation.GetServerGroups(m_matchID); grdServerGrid.ItemsSource = m_serverGroup; } }
private void btnNewPosition_Click(object sender, RoutedEventArgs e) { JudgeInfo judge = grdUnSelJudge.SelectedItem as JudgeInfo; JudgeInfo pos = grdSelJudge.SelectedItem as JudgeInfo; if (DatabaseOperation.AddMatchOfficial(m_matchID, m_serverGroupID)) { m_selJudge = DatabaseOperation.GetMatchOfficials(m_matchID, m_serverGroupID); grdSelJudge.ItemsSource = m_selJudge; } else { AthleticsCommon.ShowLastErrorBox(); } }
private void btnDelAll_Click(object sender, RoutedEventArgs e) { if (AthleticsCommon.MsgBox("Are you sure to delete all judge positions?", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Cancel) { return; } if (DatabaseOperation.ClearOfficialPosition(m_matchID, m_serverGroupID)) { m_unSelJudge = DatabaseOperation.GetAvailableOfficial(m_matchID); grdUnSelJudge.ItemsSource = m_unSelJudge; FilterUnSelJudges(); m_selJudge.Clear(); } else { AthleticsCommon.ShowLastErrorBox(); } }
private void ComboBox_PositionChanged(object sender, SelectionChangedEventArgs e) { ComboBox cmb = (sender as ComboBox); int positionID = (int)cmb.SelectedValue; JudgePosition pos = (cmb.ItemsSource as ObservableCollection <JudgePosition>)[cmb.SelectedIndex]; string newPosName = pos.Position; DataGridRow row = (DataGridRow)AthleticsCommon.VisualTreeSearchUp(cmb, typeof(DataGridRow)); if (row != null) { JudgeInfo judge = row.DataContext as JudgeInfo; if (DatabaseOperation.UpdateJudgePosition(m_matchID, judge.ServantNum, positionID)) { judge.Position = newPosName; } else { AthleticsCommon.ShowLastErrorBox(); } } grdSelJudge.CancelEdit(); }
private void btnRemove_Click(object sender, RoutedEventArgs e) { if (grdSelJudge.SelectedIndex < 0) { AthleticsCommon.MsgBox("Please select a judge which you want to remove."); return; } JudgeInfo pos = grdSelJudge.SelectedItem as JudgeInfo; if (DatabaseOperation.UpdateMatchOfficial(m_matchID, pos.ServantNum, -1)) { pos.Name = ""; pos.NOC = ""; m_unSelJudge = DatabaseOperation.GetAvailableOfficial(m_matchID); grdUnSelJudge.ItemsSource = m_unSelJudge; FilterUnSelJudges(); } else { AthleticsCommon.ShowLastErrorBox(); return; } }