private void Save()
        {
            IList <Framework.DataServices.Model.EntityBaseData> list =
                (IList <Framework.DataServices.Model.EntityBaseData>)ViewState["Grid"];



            for (int c = 0; c < this.grdApostas.Rows.Count; c++)
            {
                Model.Boloes.ApostaExtraUsuario aposta = (Model.Boloes.ApostaExtraUsuario)list[c];

                DropDownList cboNomeTime = (DropDownList)this.grdApostas.Rows[c].FindControl("cboNomeTime");

                //Se mudou o time atualizado
                if (string.Compare(cboNomeTime.Text, aposta.NomeTime, true) != 0)
                {
                    Business.Boloes.Support.ApostaExtraUsuario business =
                        new Business.Boloes.Support.ApostaExtraUsuario(base.UserName);

                    business.Copy(aposta);
                    business.Bolao    = new BolaoNet.Model.Boloes.Bolao(CurrentBolao.Nome);
                    business.UserName = base.UserName;

                    business.NomeTime = cboNomeTime.Text;

                    business.Insert();
                } //endif mudou time
            }     //end for c

            BindGrid();

            base.ShowMessages("Dados extras armazenados com sucesso.");
        }
        private void BindGrid()
        {
            Business.Boloes.Support.ApostaExtraUsuario business =
                new Business.Boloes.Support.ApostaExtraUsuario(base.UserName);

            IList <Framework.DataServices.Model.EntityBaseData> list = business.SelectByUser(
                CurrentBolao, base.UserName, null);

            ViewState["Grid"] = list;

            this.grdApostas.DataSource = ViewState["Grid"];
            this.grdApostas.DataBind();
        }
Пример #3
0
        public void Run(string nomeBolao)
        {
            string currentUserName = "******";

            //Criando os dados do excel na memória
            excel.CreateWorksheet("Estatistica");


            //Criando as instâncias dos BO
            Business.Boloes.Support.Bolao              bolao           = new Business.Boloes.Support.Bolao(currentUserName, nomeBolao);
            Business.Campeonatos.Support.Jogo          boJogo          = new Business.Campeonatos.Support.Jogo(currentUserName);
            Business.Boloes.Support.JogoUsuario        boJogosUsuarios = new Business.Boloes.Support.JogoUsuario(currentUserName);
            Business.Boloes.Support.ApostaExtraUsuario boApostaExtra   = new Business.Boloes.Support.ApostaExtraUsuario(currentUserName);
            boApostaExtra.Bolao = bolao;


            //Carregando os dados principais do bolão
            bolao.Load();

            //Indicando qual campeonato é o jogo
            boJogo.Campeonato     = bolao.Campeonato;
            boJogosUsuarios.Bolao = bolao;


            //Carregando a classificação
            IList <BolaoNet.Model.Boloes.BolaoMembros> membros = bolao.LoadClassificacao(0);

            //Buscando o jogo de disputa de 3 e 4
            IList <Framework.DataServices.Model.EntityBaseData> jogosFound = boJogo.SelectAll("NomeFase = 'Final' AND PendenteTime1Ganhador = 0");

            //Identificando o jogo do 3 e 4 lugar
            Model.Campeonatos.Jogo jogoFimPerdedor = (Model.Campeonatos.Jogo)jogosFound[0];

            //Buscando o 1 e 2 lugar
            jogosFound = boJogo.SelectAll("NomeFase = 'Final' AND PendenteTime1Ganhador = 1");

            //Atribuindo o 1 e 2 lugar
            Model.Campeonatos.Jogo jogoFimCampeao = (Model.Campeonatos.Jogo)jogosFound[0];

            //Buscando as apostas do usuário de disputa de 3 e 4 lugar
            IList <Framework.DataServices.Model.EntityBaseData> listJogos = boJogosUsuarios.LoadApostasByJogo(bolao, jogoFimPerdedor, null);

            //Buscando as apostas extras dos usuários
            IList <Framework.DataServices.Model.EntityBaseData> listApostasExtras = boApostaExtra.SelectAll(null);

            excel.SetValue(PosLineStart - 1, 0, "Gols Time 1");
            excel.SetValue(PosLineStart - 1, 1, "Gols Time 2");
            excel.SetValue(PosLineStart - 1, 2, "Desempate, 0 = Time 1");


            for (int c = 0; c < membros.Count; c++)
            {
                excel.SetValue(PosLineStart - 1, PosStartName + (c * 4), membros[c].UserName);
                excel.SetNumber(PosLineStart - 1, PosStartName + 1 + (c * 4), membros[c].TotalPontos);
                //excel.SetNumber(PosLineStart - 1, PosStartName + 2 + (c * 3), 0);
            }


            int currentLine = PosLineStart;

            ApplyLine(currentLine++, _golsTime1, _golsTime2, _ganhador, 3, 4, ref membros, listJogos, listApostasExtras, false);



            currentLine += 2;
            listJogos    = boJogosUsuarios.LoadApostasByJogo(bolao, jogoFimCampeao, null);

            //Empate
            ApplyLine(currentLine++, 0, 0, 1, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 0, 0, 2, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 1, 1, 1, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 1, 1, 2, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 2, 2, 1, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 2, 2, 2, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 3, 3, 1, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 3, 3, 2, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 4, 4, 1, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 4, 4, 2, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 5, 5, 1, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 5, 5, 2, 1, 2, ref membros, listJogos, listApostasExtras, true);

            //Ganhador 2
            ApplyLine(currentLine++, 0, 1, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 0, 2, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 0, 3, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 0, 4, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 0, 5, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);

            ApplyLine(currentLine++, 1, 2, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 1, 3, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 1, 4, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 1, 5, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);

            ApplyLine(currentLine++, 2, 3, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 2, 4, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 2, 5, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);

            ApplyLine(currentLine++, 3, 4, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 3, 5, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);

            ApplyLine(currentLine++, 4, 5, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);

            //Ganhador 1
            ApplyLine(currentLine++, 1, 0, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 2, 0, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 3, 0, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 4, 0, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 5, 0, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);

            ApplyLine(currentLine++, 2, 1, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 3, 1, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 4, 1, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 5, 1, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);

            ApplyLine(currentLine++, 3, 2, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 4, 2, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 5, 2, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);

            ApplyLine(currentLine++, 4, 3, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);
            ApplyLine(currentLine++, 5, 3, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);

            ApplyLine(currentLine++, 5, 4, 0, 1, 2, ref membros, listJogos, listApostasExtras, true);


            if (System.IO.File.Exists(".\\Excel.xls"))
            {
                System.IO.File.Delete(".\\Excel.xls");
            }

            excel.SaveFile(".\\Excel.xls");
        }