public override BindingList <BasketballPlayers> GetPlayersFromFile()
        {
            BindingList <BasketballPlayers> playersToOutput = new BindingList <BasketballPlayers>();


            XSSFWorkbook workbook;

            using (FileStream fs = new FileStream(FileProcessingPath, FileMode.Open, FileAccess.Read))
            {
                workbook = new XSSFWorkbook(fs);
            }

            ISheet sheet = workbook.GetSheet("Sheet0");


            for (int row = 1; row <= sheet.LastRowNum; row++)
            {
                BasketballPlayers player = new BasketballPlayers();
                if (sheet.GetRow(row) != null)
                {
                    //if (sheet.GetRow(row).GetCell(1).ToString() != null && sheet.GetRow(row).GetCell(2).ToString() != null && sheet.GetRow(row).GetCell(7).ToString() != null &&
                    //    sheet.GetRow(row).GetCell(3).ToString() != null && sheet.GetRow(row).GetCell(5).ToString() != null && sheet.GetRow(row).GetCell(6).ToString() != null &&
                    //    sheet.GetRow(row).GetCell(4).ToString() != null && sheet.GetRow(row).GetCell(0).ToString() != null)
                    {
                        player.Picture  = sheet.GetRow(row).GetCell(0).ToString();
                        player.Name     = sheet.GetRow(row).GetCell(1).ToString();
                        player.Position = sheet.GetRow(row).GetCell(2).ToString();


                        player.Age = EditingInfo.ConvertNumber(sheet.GetRow(row).GetCell(3).ToString());

                        player.Career_age = EditingInfo.ConvertNumber(sheet.GetRow(row).GetCell(4).ToString());

                        player.Height = EditingInfo.ConvertNumberToDouble(sheet.GetRow(row).GetCell(5).ToString());

                        player.Weight = EditingInfo.ConvertNumber(sheet.GetRow(row).GetCell(6).ToString());

                        player.Current_team = sheet.GetRow(row).GetCell(7).ToString();

                        playersToOutput.Add(player);
                    }
                }
            }
            return(playersToOutput);
        }
Ejemplo n.º 2
0
        private BasketballPlayers GetPlayerFromForm(BasketballPlayers player, Teams team, Positions position)
        {
            //if (!string.IsNullOrEmpty(team.TeamName))
            //{
            player.Current_team = team.TeamName;
            //}
            //if (!string.IsNullOrEmpty(tbGetName.Text))
            //{
            player.Name = tbGetName.Text;
            //}
            //if (!string.IsNullOrEmpty(tbGetAge.Text))
            //{
            player.Age = EditingInfo.ConvertNumber(tbGetAge.Text);
            //}
            //if (!string.IsNullOrEmpty(tbGetCareerAge.Text))
            //{
            player.Career_age = EditingInfo.ConvertNumber(tbGetCareerAge.Text);
            //}
            //if (!string.IsNullOrEmpty(tbGetHeight.Text))
            //{
            player.Height = EditingInfo.ConvertNumberToDouble(tbGetHeight.Text);
            //}
            //if (!string.IsNullOrEmpty(tbGetWeight.Text))
            //{
            player.Weight = EditingInfo.ConvertNumber(tbGetWeight.Text);
            //}
            //if (!string.IsNullOrEmpty(position.Position))
            //{
            player.Position = position.Position;
            //}
            //if (!string.IsNullOrEmpty(_playerIMG))
            //{
            player.Picture = tbToShowPlayerPictureFilePath.Text;
            //}

            return(player);
        }