コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Business.Campeonatos.Support.Campeonato business =
                    new Business.Campeonatos.Support.Campeonato(base.UserName, CurrentCampeonato);

                this.cboTime.DataSource     = business.LoadTimes();
                this.cboTime.DataTextField  = "Nome";
                this.cboTime.DataValueField = "Nome";
                this.cboTime.DataBind();



                business.Nome = CurrentCampeonato.Nome;

                this.cboGrupo.DataSource     = business.LoadGrupos();
                this.cboGrupo.DataTextField  = "Nome";
                this.cboGrupo.DataValueField = "Nome";
                this.cboGrupo.DataBind();


                this.cboFase.DataSource     = business.LoadFases();
                this.cboFase.DataTextField  = "Nome";
                this.cboFase.DataValueField = "Nome";
                this.cboFase.DataBind();
            }

            BindChart();
        }
コード例 #2
0
        public void CreateFile(Model.Campeonatos.Campeonato campeonato, Model.Boloes.Bolao bolao)
        {
            if (System.IO.File.Exists(_fileName))
            {
                System.IO.File.Delete(_fileName);
            }



            //FileStream stream = new FileStream(_fileName, FileMode.Create, FileAccess.Write);
            //NPOI.HSSF.UserModel.HSSFWorkbook wb = new NPOI.HSSF.UserModel.HSSFWorkbook(stream);

            NPOI.SS.UserModel.Workbook wb = new NPOI.HSSF.UserModel.HSSFWorkbook();


            NPOI.SS.UserModel.Sheet sheetJogos = wb.CreateSheet("Jogos-Grupo");

            Business.Campeonatos.Support.Campeonato             camp  = new Business.Campeonatos.Support.Campeonato(_currentLogin, campeonato);
            IList <Framework.DataServices.Model.EntityBaseData> jogos = camp.LoadJogos(0, null, null, DateTime.MinValue, DateTime.MinValue, null);


            IList <Framework.DataServices.Model.EntityBaseData> grupos = camp.LoadGrupos();

            int count = 0;
            int line  = 0;

            foreach (Model.Campeonatos.Grupo grupo in grupos)
            {
                if (!string.IsNullOrEmpty(grupo.Nome.Trim()))
                {
                    NPOI.SS.UserModel.Row  row       = sheetJogos.CreateRow(count++);
                    NPOI.SS.UserModel.Cell grupoCell = row.CreateCell(0);
                    grupoCell.SetCellValue("Grupo " + grupo.Nome);


                    line = 0;
                    row  = sheetJogos.CreateRow(count++);
                    row.CreateCell(line++).SetCellValue("Jogo");
                    row.CreateCell(line++).SetCellValue("Data/Hora");
                    row.CreateCell(line++).SetCellValue("Local");
                    row.CreateCell(line++).SetCellValue("Time");
                    row.CreateCell(line++).SetCellValue("Gols");
                    row.CreateCell(line++).SetCellValue("");
                    row.CreateCell(line++).SetCellValue("");
                    row.CreateCell(line++).SetCellValue("x");
                    row.CreateCell(line++).SetCellValue("");
                    row.CreateCell(line++).SetCellValue("");
                    row.CreateCell(line++).SetCellValue("Gols");
                    row.CreateCell(line++).SetCellValue("Time");
                    row.CreateCell(line++).SetCellValue("");


                    foreach (Model.Campeonatos.Jogo jogo in jogos)
                    {
                        if (string.Compare(jogo.Grupo.Nome, grupo.Nome, true) == 0)
                        {
                            line = 0;
                            row  = sheetJogos.CreateRow(count++);
                            row.CreateCell(line++).SetCellValue(jogo.JogoLabel);
                            row.CreateCell(line++).SetCellValue(jogo.DataJogo.ToString("dd/MM/yy HH:mm"));
                            row.CreateCell(line++).SetCellValue(jogo.Estadio.ToString());
                            row.CreateCell(line++).SetCellValue(jogo.Time1.Nome);
                            if (jogo.PartidaValida)
                            {
                                row.CreateCell(line++).SetCellValue(jogo.GolsTime1);
                            }
                            else
                            {
                                row.CreateCell(line++).SetCellValue("");
                            }
                            row.CreateCell(line++).SetCellValue("");

                            row.CreateCell(line++).SetCellValue("");
                            row.CreateCell(line++).SetCellValue("x");

                            row.CreateCell(line++).SetCellValue("");
                            row.CreateCell(line++).SetCellValue("");

                            if (jogo.PartidaValida)
                            {
                                row.CreateCell(line++).SetCellValue(jogo.GolsTime2);
                            }
                            else
                            {
                                row.CreateCell(line++).SetCellValue("");
                            }
                            row.CreateCell(line++).SetCellValue(jogo.Time2.Nome);
                            row.CreateCell(line++).SetCellValue("");
                        }
                    }

                    sheetJogos.CreateRow(count++);
                }
            }


            sheetJogos.CreateRow(count++);
            CreateFase(sheetJogos, "Oitavas de Final", ref count, jogos);
            sheetJogos.CreateRow(count++);
            CreateFase(sheetJogos, "Quartas de Final", ref count, jogos);
            sheetJogos.CreateRow(count++);
            CreateFase(sheetJogos, "Semi Finais", ref count, jogos);
            sheetJogos.CreateRow(count++);
            CreateFase(sheetJogos, "Final", ref count, jogos);


            Business.Boloes.Support.Bolao bolaoBO = new Business.Boloes.Support.Bolao(_currentLogin, bolao.Nome);

            IList <Framework.DataServices.Model.EntityBaseData> users = bolaoBO.LoadMembros();

            foreach (Framework.Security.Model.UserData user in users)
            {
                CreateUser(wb, user.UserName, bolaoBO);
            }



            wb.Write(new FileStream(_fileName, FileMode.Create));
        }