private void FillCombobox()
 {
     listOfTeam            = TeamHelper.GetTeam(tournament);
     cmbTeam.DataSource    = listOfTeam;
     cmbTeam.DisplayMember = "teamName";
     cmbTeam.ValueMember   = "teamID";
 }
 private void GetTeam()
 {
     teamList              = TeamHelper.GetTeam(tournament);
     cmbTeam.DataSource    = teamList;
     cmbTeam.DisplayMember = "teamName";
     cmbTeam.ValueMember   = "teamID";
 }
        private void ActivateStatus()
        {
            tournamentDetails.tournamentStatus = 2;
            List <Team>         team         = TeamHelper.GetTeam(tournamentDetails);
            List <GameOfficial> gameofficial = GameOfficialHelper.GetAllGameOfficial(tournamentDetails);
            List <Player>       player       = PlayerHelper.GetPlayer(tournamentDetails);
            List <Venue>        venue        = VenueHelper.GetVenue();

            /* if(tournamentDetails.ValidationOfActivation(team,gameofficial,player) != true)
             * {
             *   MessageBox.Show("Error Activating");
             *   return;
             * }
             */

            List <Match> match = Match.GenerateMatch(team, venue, tournamentDetails);

            foreach (Match m in match)
            {
                MatchHelper.SaveMatch(m);
            }

            if (TournamentHelper.UpdateTournamentStatus(tournamentDetails) == 0)
            {
                //report an error
                MessageBox.Show("Error activating tournament");
                this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
Пример #4
0
        private void TeamOfficial()
        {
            var tournament = GetTournament();

            if (isAvailable(tournament) == false)
            {
                MessageBox.Show("No Available Tournament");
                return;
            }
            else if (tournament.tournamentStatus == 2 || tournament.tournamentStatus == 3)
            {
                MessageBox.Show("Sorry you cannot add more team fficial because the tournament already active or the tournament is close");
                return;
            }

            var team = TeamHelper.GetTeam(tournament);

            if (team.Count <= 0)
            {
                MessageBox.Show("Theres no team been created");
                return;
            }
            using (Form f = new frmViewTeamOfficial(tournament))
            {
                f.ShowDialog();
            }
        }
Пример #5
0
        private void LoadTournament()
        {
            var tournament = GetTournament();

            if (isAvailable(tournament) == true)
            {
                if (tournament.tournamentStatus == 2)
                {
                    btnExportTeamRooster.Visible = true;
                }
                lblDate.Visible             = true;
                lblMotto.Visible            = true;
                lblTitle.Visible            = true;
                lblTournamentDate.Visible   = true;
                lblTournamentMotto.Visible  = true;
                lblTournamentTitle.Visible  = true;
                lblTournamentStatus.Visible = true;
                lblNoGameOfficial.Visible   = true;
                lblNoPlayer.Visible         = true;
                lblNoTeam.Visible           = true;
                lblGameOfficial.Visible     = true;
                lblTeam.Visible             = true;
                lblPlayer.Visible           = true;

                List <GameOfficial> gameOfficial = GameOfficialHelper.GetAllGameOfficial(tournament);
                List <Team>         team         = TeamHelper.GetTeam(tournament);
                List <Player>       player       = PlayerHelper.GetPlayer(tournament);

                lblGameOfficial.Text    = gameOfficial.Count.ToString();
                lblTeam.Text            = team.Count.ToString();
                lblPlayer.Text          = player.Count.ToString();
                lblStatus.Text          = GetStatus(tournament);
                lblTournamentTitle.Text = tournament.tournamentTitle;
                lblTournamentMotto.Text = tournament.tournamentMotto;
                lblTournamentDate.Text  = tournament.tournamentStart.ToShortDateString() + " - " + tournament.tournamentEnd.ToShortDateString();
                return;
            }
            else
            {
                btnExportTeamRooster.Visible = false;
                lblDate.Visible             = false;
                lblMotto.Visible            = false;
                lblTitle.Visible            = false;
                lblTournamentDate.Visible   = false;
                lblTournamentMotto.Visible  = false;
                lblTournamentTitle.Visible  = false;
                lblTournamentStatus.Visible = false;
                lblPlayer.Visible           = false;
                lblTeam.Visible             = false;
                lblGameOfficial.Visible     = false;
                lblStatus.Text = "No Available Tournament";
            }
        }
        private void ActivateStatus()
        {
            int si = 0;

            try
            {
                si = lvwTournaments.SelectedItems[0].Index;
            }
            catch { return; }

            Tournament selectedTournament = list[si];

            selectedTournament.tournamentStatus = 2;
            List <Team>         team         = TeamHelper.GetTeam(selectedTournament);
            List <GameOfficial> gameofficial = GameOfficialHelper.GetAllGameOfficial(selectedTournament);
            List <Player>       player       = PlayerHelper.GetPlayer(selectedTournament);
            List <Venue>        venue        = VenueHelper.GetVenue();

            if (selectedTournament.ValidationOfActivation(team, gameofficial, player) != true)
            {
                MessageBox.Show("Cannot Activate because you need follow the rules activating the tourmament[2 Teams] And [2 Game Official] require");
                return;
            }


            List <Match> match = Match.GenerateMatch(team, venue, selectedTournament);

            foreach (Match m in match)
            {
                MatchHelper.SaveMatch(m);
            }

            if (TournamentHelper.UpdateTournamentStatus(selectedTournament) == 0)
            {
                //report an error
                MessageBox.Show("Error activating tournament");
                this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            }
            lblStatus.Text               = "Activate";
            btnActivate.Visible          = false;
            btnPrint.Visible             = false;
            btnExportTeamRooster.Visible = true;
            btnClose.Visible             = true;
            displayTournament();
        }
Пример #7
0
        private void DisplayData()
        {
            listOfTeam = TeamHelper.GetTeam(tournament);
            lvTeam.Clear();
            InitListView();
            int          ctr = 0;
            ListViewItem item;

            foreach (Team team in listOfTeam)
            {
                item = lvTeam.Items.Add((++ctr).ToString());
                item.SubItems.Add(team.teamID.ToString());
                item.SubItems.Add(team.teamName);
                item.SubItems.Add(team.teamSlogan);
                item.SubItems.Add(team.barangay.id.ToString());
                item.SubItems.Add(team.tournament.tournamentID.ToString());
                item.SubItems.Add(team.barangay.name);
            }
        }
        private void ExportTeamRooster()
        {
            var tournament = new Tournament();

            int si = 0;

            try
            {
                si = lvwTournaments.SelectedItems[0].Index;
            }
            catch { return; }

            tournament = list[si];


            List <Team>         team     = TeamHelper.GetTeam(tournament);
            List <Player>       player   = PlayerHelper.GetPlayer(tournament);
            List <TeamOfficial> official = TeamOfficialHelper.GetAllOfficial(tournament);


            ExcelPackage   ExcelPkg = new ExcelPackage();
            ExcelWorksheet wsSheet1 = ExcelPkg.Workbook.Worksheets.Add("Sheet1");

            wsSheet1.Cells.Style.Font.Name = "Arial Narrow";
            wsSheet1.Cells.Style.Font.Size = 11;

            //Title Of tournament
            wsSheet1.Cells["G" + 3].Value = "Basketball Tournament 2018";
            //Date of tournament
            wsSheet1.Cells["G" + 4].Value        = "April 15, 2018 - April 25, 2018";
            wsSheet1.Cells["G9"].Value           = "Official Team Rooster";
            wsSheet1.Cells["G9"].Style.Font.Name = "Times New Roman";
            wsSheet1.Cells["G9"].Style.Font.Size = 14;
            //Header of Tournament
            wsSheet1.Cells["A11"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
            wsSheet1.Cells["A11"].Value = "NO.1";
            wsSheet1.Cells["C11"].Value = "Team name";
            wsSheet1.Cells["G11"].Value = "Head Coach";
            wsSheet1.Cells["K11"].Value = "Jersey No.";
            wsSheet1.Cells["N11"].Value = "Players";

            int rowIndex = 0;
            int colIndex = 1;



            int Height = 220;
            int Width  = 120;

            Image        img = Image.FromFile(@"C:\Users\JOSHUA\Documents\Visual Studio 2015\Projects\BATMAN\Images\seal.jpg");
            ExcelPicture pic = wsSheet1.Drawings.AddPicture("Sample", img);

            pic.SetPosition(rowIndex, 0, colIndex, 0);
            //pic.SetPosition(PixelTop, PixelLeft);
            pic.SetSize(Height, Width);



            string fileName = @"C:\Users\JOSHUA\Documents\Visual Studio 2015\Projects\BATMAN\" + wsSheet1.Cells["G" + 3].Value.ToString() + ".xls";

            //INITIALIZING COUNTER FOR CELL
            int NoCounter     = 12;
            int numberCounter = 1;
            int ctr           = 12;

            foreach (var t in team)
            {
                var playerByTeam   = BATMAN.Classes.Player.PlayerByTeam(player, t.teamID);
                var officialByTeam = TeamOfficial.ShowByTeam(official, t.teamID);
                wsSheet1.Cells["C" + NoCounter].Value = t.teamName;
                wsSheet1.Cells["G" + NoCounter].Value = officialByTeam.firstName + " " + officialByTeam.lastName;
                wsSheet1.Cells["A" + NoCounter].Value = numberCounter++;
                wsSheet1.Cells["A" + NoCounter].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;

                foreach (var p in playerByTeam)
                {
                    wsSheet1.Cells["K" + ctr].Value   = p.jerseyNO.ToString();
                    wsSheet1.Cells["N" + ctr++].Value = p.firstName + " " + p.lastName;
                    NoCounter++;
                }
                ctr++;
                NoCounter++;
            }

            wsSheet1.Protection.IsProtected            = false;
            wsSheet1.Protection.AllowSelectLockedCells = false;
            ExcelPkg.SaveAs(new FileInfo(fileName));

            FileInfo fi = new FileInfo(fileName);

            if (fi.Exists)
            {
                System.Diagnostics.Process.Start(fileName);
            }
            else
            {
                MessageBox.Show("Theres a problem while opening excel,Go to " + fileName + "Manual Open");
            }
        }
Пример #9
0
 private void frmSaveTeam_Load(object sender, EventArgs e)
 {
     InitSaveTeam();
     listOfTeam = TeamHelper.GetTeam(tournament);
 }