private void UpdateTeamOfficial()
        {
            int          si   = 0;
            TeamOfficial temp = null;

            try
            {
                si   = lsvTeamOfficial.SelectedItems[0].Index;
                temp = teamOfficialByTeam[si];
            }
            catch
            {
                MessageBox.Show("Please select you wish to update");
                return;
            }

            Team team = Team.GetTeam(listOfTeam, (int)cmbTeam.SelectedValue);

            using (Form f = new frmSaveTeamOfficial(team, teamOfficialByTeam, temp))
            {
                if (DialogResult.OK == f.ShowDialog())
                {
                    MessageBox.Show("Sucessfully updated team official");
                    listOfTeamOfficial = TeamOfficialHelper.GetAllOfficial(tournament);
                    GetAllTeamOfficial();
                }
            }
        }
Esempio n. 2
0
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Image image = Image.FromFile(@"F:\Generic Basketball Score Sheet-1.png");

            List <Player>       listPlayer   = PlayerHelper.GetPlayer(tournament);
            List <Player>       playerByTeam = Player.PlayerByTeam(listPlayer, match.homeTeam.teamID);
            List <TeamOfficial> listOfficial = TeamOfficialHelper.GetAllOfficial(tournament);
            var official = TeamOfficial.ShowByTeam(listOfficial, match.homeTeam.teamID);

            //HEADER GAMESCORESHEET
            e.Graphics.DrawImage(image, e.PageBounds);
            e.Graphics.DrawString("Abella Vs Tinago", new Font("Courier New", 24, FontStyle.Bold), Brushes.Black, new Point(250, 25));
            e.Graphics.DrawString(match.venue.venueName, new Font("Courier New", 11, FontStyle.Regular), Brushes.Black, new Point(700, 85));
            //TEAM 1
            int counter = 250;

            e.Graphics.DrawString(match.homeTeam.teamName, new Font("Courier New", 14, FontStyle.Bold), Brushes.Black, new Point(90, 80));
            e.Graphics.DrawString(official.firstName + " " + official.lastName, new Font("Courier New", 14, FontStyle.Bold), Brushes.Black, new Point(80, 215));
            foreach (var pl in playerByTeam)
            {
                e.Graphics.DrawString(pl.firstName + " " + pl.lastName, new Font("Courier New", 11, FontStyle.Bold), Brushes.Black, new Point(25, counter));
                e.Graphics.DrawString(pl.jerseyNO.ToString(), new Font("Courier New", 11, FontStyle.Bold), Brushes.Black, new Point(290, counter));
                counter += 20;
            }

            //TEAM 2
            counter      = 725;
            playerByTeam = Player.PlayerByTeam(listPlayer, match.guestTeam.teamID);
            foreach (var pl in playerByTeam)
            {
                e.Graphics.DrawString(pl.firstName + " " + pl.lastName, new Font("Courier New", 10, FontStyle.Bold), Brushes.Black, new Point(25, counter));
                e.Graphics.DrawString(pl.jerseyNO.ToString(), new Font("Courier New", 11, FontStyle.Bold), Brushes.Black, new Point(290, counter));
                counter += 18;
            }
        }
        private void DeleteTeamOfficial()
        {
            int          si   = 0;
            TeamOfficial temp = null;

            try
            {
                si   = lsvTeamOfficial.SelectedItems[0].Index;
                temp = teamOfficialByTeam[si];
            }
            catch
            {
                MessageBox.Show("Please select you wish to delete");
                return;
            }

            if (DialogResult.Yes == MessageBox.Show("Do you really wish to delete[" + temp.firstName + " " + temp.lastName + "]", "System", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
            {
                if (TeamOfficialHelper.DeleteTeamOfficial(temp) == 1)
                {
                    MessageBox.Show("Sucessfully deleted team official");
                    listOfTeamOfficial = TeamOfficialHelper.GetAllOfficial(tournament);
                    GetAllTeamOfficial();
                }
                else
                {
                    MessageBox.Show("Error Deleting team official");
                }
            }
        }
        private void AddTeamOfficial()
        {
            Team team = Team.GetTeam(listOfTeam, (int)cmbTeam.SelectedValue);

            if (teamOfficialByTeam.Count >= 3)
            {
                MessageBox.Show("There's no available slot for team official [" + team.teamName + "]");
                return;
            }
            using (Form f = new frmSaveTeamOfficial(team, teamOfficialByTeam))
            {
                if (DialogResult.OK == f.ShowDialog())
                {
                    MessageBox.Show("Sucessfully added team official");
                    listOfTeamOfficial = TeamOfficialHelper.GetAllOfficial(tournament);
                    GetAllTeamOfficial();
                }
            }
        }
        private void SaveTeamOfficial(TeamOfficial official, int position)
        {
            TeamOfficial official1 = new TeamOfficial()
            {
                id        = (official == null) ? 0 : official.id,
                firstName = txtFirstName1.Text,
                lastName  = txtLastName1.Text,
                position  = new StaffPosition()
                {
                    positionID = (short)position,
                },
                team = team
            };

            if (TeamOfficialHelper.SaveTeamOfficial(official1) == 0)
            {
                MessageBox.Show("Error Saving Team Official");
                return;
            }

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            TeamOfficial official1 = new TeamOfficial()
            {
                id        = (official == null) ? 0 : official.id,
                firstName = txtFirstName1.Text,
                lastName  = txtLastName1.Text,
                position  = new StaffPosition()
                {
                    positionID     = (short)cmbPosition.SelectedValue,
                    positionDetail = cmbPosition.SelectedItem.ToString(),
                },
                team = team
            };

            if (TeamOfficialHelper.SaveTeamOfficial(official1) == 0)
            {
                MessageBox.Show("Error Saving Team Official");
                return;
            }

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
        private void ShowByTeam()
        {
            List <TeamOfficial> listTeamOfficial = TeamOfficialHelper.GetAllOfficial(tournament);

            if (listTeamOfficial == null)
            {
                return;
            }
            int ci   = (team == null)?0:team.teamID;
            var data = from st in listTeamOfficial
                       where st.team.teamID == ci
                       select st;

            teamOfficialByTeam = new List <TeamOfficial>();
            foreach (var dr in data.AsEnumerable())
            {
                TeamOfficial official = new TeamOfficial()
                {
                    id        = dr.id,
                    firstName = dr.firstName,
                    lastName  = dr.lastName,
                    position  = new StaffPosition()
                    {
                        positionID     = dr.position.positionID,
                        positionDetail = dr.position.positionDetail,
                    },
                    team = new Team()
                    {
                        teamID   = dr.team.teamID,
                        teamLogo = dr.team.teamName
                    }
                };

                teamOfficialByTeam.Add(official);
            }
        }
 private void frmVIewTeamOfficial_Load(object sender, EventArgs e)
 {
     FillCombobox();
     listOfTeamOfficial = TeamOfficialHelper.GetAllOfficial(tournament);
     GetAllTeamOfficial();
 }
        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");
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtFirstName1.Text == "" || txtFirstName2.Text == "" || txtFirstName3.Text == "" || txtLastName1.Text == "" || txtLastName2.Text == "" || txtLastName3.Text == "")
            {
                MessageBox.Show("Fill up the empty blank");
                return;
            }

            if (!SaveTeam())
            {
                return;
            }


            team = Team.GetTeamByName(tournament, txtName.Text);
            int id1 = 0;
            int id2 = 0;
            int id3 = 0;

            if (!(teamOfficialByTeam.Count <= 0))
            {
                id1 = (teamOfficialByTeam[0] == null) ? 0 : teamOfficialByTeam[0].id;
                id2 = (teamOfficialByTeam[1] == null) ? 0 : teamOfficialByTeam[1].id;
                id3 = (teamOfficialByTeam[2] == null) ? 0 : teamOfficialByTeam[2].id;
            }

            TeamOfficial coach = new TeamOfficial()
            {
                id        = id1,
                firstName = txtFirstName1.Text,
                lastName  = txtLastName1.Text,
                position  = new StaffPosition()
                {
                    positionID     = 1,
                    positionDetail = "Coach",
                },
                team = new Team()
                {
                    teamID = team.teamID
                }
            };

            TeamOfficial assistant_coach = new TeamOfficial()
            {
                id        = id2,
                firstName = txtFirstName2.Text,
                lastName  = txtLastName2.Text,
                position  = new StaffPosition()
                {
                    positionID     = 2,
                    positionDetail = "Assistant Coach"
                },
                team = new Team()
                {
                    teamID = team.teamID
                }
            };

            TeamOfficial manager = new TeamOfficial()
            {
                id        = id3,
                firstName = txtFirstName3.Text,
                lastName  = txtLastName3.Text,
                position  = new StaffPosition()
                {
                    positionID     = 3,
                    positionDetail = "Manager"
                },
                team = new Team()
                {
                    teamID = team.teamID
                }
            };

            TeamOfficialHelper.SaveTeamOfficial(coach);
            TeamOfficialHelper.SaveTeamOfficial(assistant_coach);
            TeamOfficialHelper.SaveTeamOfficial(manager);
        }