Esempio n. 1
0
        // Loads competition from database
        private void MenuItemLoad_Click(object sender, RoutedEventArgs e)
        {
            LoadPreciseWindow lpwindow = new LoadPreciseWindow(dBManager, this);

            lpwindow.ShowDialog();

            // If lpwindow created Competition then continue
            if (!lpwindow.Created || Competition == null)
            {
                return;
            }

            // Reset Buttons
            btnNext.IsEnabled       = true;
            btnBack.IsEnabled       = false;
            btnEnd.IsEnabled        = false;
            btnResetShots.IsEnabled = true;

            // Enable Butons
            btnSearch.IsEnabled      = true;
            btnSearchClear.IsEnabled = true;
            btnSetShots.IsEnabled    = true;
            setTeamBtn.IsEnabled     = true;

            //Disable Load
            itemLoad.IsEnabled = false;

            // Set info Labels
            lblRound.Content    += Competition.Round.ToString();
            lblShooters.Content += Competition.Shooters.Count.ToString();
            lblShotsPR.Content  += Competition.Shots.ToString();
            lblTrounds.Content  += Competition.NRounds.ToString();

            FillStackPanel();

            /******************************************************************/
            dataGridShooters.ItemsSource = Competition.Shooters;
            dataGridIndivi.ItemsSource   = Competition.Shooters;
            CollectionView viewDG = (CollectionView)CollectionViewSource.GetDefaultView(dataGridShooters.ItemsSource);

            //viewDG.GroupDescriptions.Add(new PropertyGroupDescription("Club"));
            viewDG.GroupDescriptions.Add(new PropertyGroupDescription("Team"));
            /******************************************************************/

            listViewCompetitiors.ItemsSource = dBManager.GetView(dBManager.sqlLibrary["selectLVComp"], "LVComp");
            // Add view
            CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(listViewCompetitiors.ItemsSource);

            // Grouping
            view.GroupDescriptions.Add(new PropertyGroupDescription("cname"));
            // Sorting
            view.SortDescriptions.Add(new SortDescription("name", ListSortDirection.Ascending));
            view.SortDescriptions.Add(new SortDescription("surname", ListSortDirection.Ascending));
        }
Esempio n. 2
0
        private void buttonAction_Click(object sender, RoutedEventArgs e)
        {
            // Check input
            if (textBoxName.Text == string.Empty)
            {
                MessageBox.Show("Name box can't be empty!", "Warning!");
                return;
            }
            else if (textBoxSurname.Text == string.Empty)
            {
                MessageBox.Show("Surname box can't be empty!", "Warning!");
                return;
            }
            if (comboBoxClub.Text == string.Empty)
            {
                MessageBox.Show("Club combo box can't be empty!", "Warning!");
                return;
            }

            // Select mode: inserting or updating
            switch (mode)
            {
            case WindowOpenMode.Insert:
                InsertShooterRecord((long)comboBoxClub.SelectedValue, textBoxName.Text, textBoxSurname.Text, textBoxNote.Text, textBoxTeam.Text.ToUpper());
                break;

            case WindowOpenMode.Update:
                UpdateShooterRecord((long)comboBoxClub.SelectedValue, textBoxName.Text, textBoxSurname.Text, textBoxNote.Text, textBoxTeam.Text.ToUpper());
                break;
            }
            dataGridShooters.ItemsSource = dBManager.GetView(dBManager.sqlLibrary["selectShooters"], "Shooters");
            Close();
        }
Esempio n. 3
0
        // Insert or update club
        private void buttonAction_Click(object sender, RoutedEventArgs e)
        {
            // Input check
            if (textBoxClub.Text == string.Empty)
            {
                MessageBox.Show("Club box can't be empty!", "Warning!");
                return;
            }
            else if (comboBoxPlace.Text == string.Empty)
            {
                MessageBox.Show("Place combo box can't be empty!", "Warning!");
                return;
            }

            // Select mode: inserting or updating
            switch (mode)
            {
            case WindowOpenMode.Insert:
                InsertClubRecord((long)comboBoxPlace.SelectedValue, textBoxClub.Text);
                break;

            case WindowOpenMode.Update:
                UpdateClubRecord((long)comboBoxPlace.SelectedValue, textBoxClub.Text);
                break;
            }
            dataGridClubs.ItemsSource = dBManager.GetView(dBManager.sqlLibrary["selectClubs"], "Clubs");
            Close();
        }
Esempio n. 4
0
        // Insert or update place
        private void buttonAction_Click(object sender, RoutedEventArgs e)
        {
            long id;

            // Input check
            if (textBoxPlace.Text == string.Empty)
            {
                MessageBox.Show("Place box can't be empty!", "Warning!");
                return;
            }
            else if (textBoxZip.Text == string.Empty)
            {
                MessageBox.Show("Zip box can't be empty!", "Warning!");
                return;
            }
            else if (!long.TryParse(textBoxZip.Text, out id))
            {
                MessageBox.Show("Zip can only be numeric!", "Warning!");
                return;
            }

            // Select mode: inserting or updating
            switch (mode)
            {
            case WindowOpenMode.Insert:
                InsertPlaceRecord(textBoxPlace.Text, id);
                break;

            case WindowOpenMode.Update:
                UpdatePlaceRecord(textBoxPlace.Text, id);
                break;
            }
            dataGridPlaces.ItemsSource = dBManager.GetView(dBManager.sqlLibrary["selectPlaces"], "Places");
            Close();
        }
Esempio n. 5
0
 public LoadPreciseWindow(DBManager dBManager, WindowPrecise windowP)
 {
     InitializeComponent();
     this.dBManager = dBManager;
     this.windowP   = windowP;
     Created        = false;
     view           = dBManager.GetView(dBManager.sqlLibrary["selectComBox"], "ComBox");
     comboBoxCompetitions.ItemsSource       = view;
     comboBoxCompetitions.SelectedValuePath = "id";
     comboBoxCompetitions.DisplayMemberPath = "title";
     comboBoxCompetitions.SelectedIndex     = 0;
 }
Esempio n. 6
0
        // Insert or update
        private void buttonAction_Click(object sender, RoutedEventArgs e)
        {
            int tartype;

            // Check input
            if (editable)
            {
                MessageBox.Show("Competition is finished and is not editable", "Warning!");
                return;
            }
            else if (textBoxTitle.Text == string.Empty)
            {
                MessageBox.Show("Title box can't be empty!", "Warning!");
                return;
            }
            else if (textBoxTType.Text == string.Empty)
            {
                MessageBox.Show("Target box can't be empty!", "Warning!");
                return;
            }
            else if (comboBoxRange.Text == string.Empty)
            {
                MessageBox.Show("Range combo box can't be empty!", "Warning!");
                return;
            }
            else if (!(datePickerDate.SelectedDate is DateTime))
            {
                MessageBox.Show("Pick valid date!", "Warning!");
                return;
            }

            // Convert tartype text to int
            else if (!int.TryParse(textBoxTType.Text, out tartype) && !(tartype > 10 || tartype < 1))
            {
                MessageBox.Show("Target type has to be numeric, maximum 10 and minimum 1!", "Warning!");
                return;
            }

            // Convert shots text to int
            int shots;

            if (!int.TryParse(textBoxNShots.Text, out shots) && !(shots > 20 || shots < 1))
            {
                MessageBox.Show("Number of shots has to be numeric, maximum 10 and minimum 1!", "Warning!");
                return;
            }

            int nRounds;

            if (!int.TryParse(textBoxRounds.Text, out nRounds) && !(nRounds > 5 || nRounds < 1))
            {
                MessageBox.Show("Number of rounds has to be numeric, maximum 5 and minimum 1!", "Warning!");
                return;
            }

            //Convert date
            DateTime dt   = (DateTime)datePickerDate.SelectedDate;
            string   date = dt.ToString("yyyy MM dd").Replace(" ", "-");

            switch (mode)
            {
            case WindowOpenMode.Insert:
                InsertPCompetitionRecord(textBoxTitle.Text, (long)comboBoxRange.SelectedValue, date, tartype, shots, nRounds);
                break;

            case WindowOpenMode.Update:
                UpdatePCompetitionRecord(textBoxTitle.Text, (long)comboBoxRange.SelectedValue, date, tartype, shots, nRounds);
                break;
            }

            dataGridPCompetitions.ItemsSource = dBManager.GetView(dBManager.sqlLibrary["selectPCompetitions"], "PCompetitions");
            Close();
        }
Esempio n. 7
0
 void initDataGrids()
 {
     dataGridPlaces.ItemsSource        = dBManager.GetView(dBManager.sqlLibrary["selectPlaces"], "Places");
     dataGridClubs.ItemsSource         = dBManager.GetView(dBManager.sqlLibrary["selectClubs"], "Clubs");
     dataGridRanges.ItemsSource        = dBManager.GetView(dBManager.sqlLibrary["selectRanges"], "Ranges");
     dataGridPCompetitions.ItemsSource = dBManager.GetView(dBManager.sqlLibrary["selectPCompetitions"], "PCompetitions");
     dataGridShooters.ItemsSource      = dBManager.GetView(dBManager.sqlLibrary["selectShooters"], "Shooters");
 }