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.ApostaExtra aposta = (Model.Boloes.ApostaExtra)list[c];

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

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

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

                    business.NomeTimeValidado = cboNomeTime.Text;

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

            BindGrid();

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

            business.Bolao = CurrentBolao;
            IList <Framework.DataServices.Model.EntityBaseData> list = business.SelectAll("NomeBolao='" + CurrentBolao.Nome + "'");

            ViewState["Grid"] = list;

            this.grdApostas.DataSource = ViewState["Grid"];
            this.grdApostas.DataBind();
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Business.Campeonatos.Support.Campeonato business =
                    new Business.Campeonatos.Support.Campeonato(base.UserName, CurrentCampeonato.Nome);

                #region Buscando os times
                IList <Framework.DataServices.Model.EntityBaseData> list = business.LoadTimes();
                ViewState["Times"] = list;
                #endregion

                #region Atualizando as apostas extras

                Business.Boloes.Support.ApostaExtra businessExtra =
                    new Business.Boloes.Support.ApostaExtra(base.UserName);

                IList <Framework.DataServices.Model.EntityBaseData> listExtra = businessExtra.SelectAll("NomeBolao='" + CurrentBolao.Nome + "'");

                ViewState["Grid"] = listExtra;

                this.grdApostas.DataSource = ViewState["Grid"];
                this.grdApostas.DataBind();


                #endregion

                #region Buscando a classificação do campeonato
                Business.Boloes.Support.Bolao     businessBolao     = new BolaoNet.Business.Boloes.Support.Bolao(base.UserName, CurrentBolao.Nome);
                IList <Model.Boloes.BolaoMembros> listClassificacao = businessBolao.LoadClassificacao(0);
                #endregion

                #region Criando a lista de usuários

                List <Model.Boloes.Simulation.ApostasExtrasBolaoMembros> listSimulation = new List <Model.Boloes.Simulation.ApostasExtrasBolaoMembros>();

                foreach (Model.Boloes.BolaoMembros entry in listClassificacao)
                {
                    Model.Boloes.Simulation.ApostasExtrasBolaoMembros extraUser = new BolaoNet.Model.Boloes.Simulation.ApostasExtrasBolaoMembros();
                    extraUser.Copy((Model.Boloes.BolaoMembros)entry);
                    extraUser.LastPontos  = extraUser.TotalPontos;
                    extraUser.LastPosicao = extraUser.Posicao;

                    listSimulation.Add(extraUser);
                }
                #endregion

                #region Buscando as apostas extras dos usuários

                Business.Boloes.Support.ApostaExtraUsuario businessExtraUser = new BolaoNet.Business.Boloes.Support.ApostaExtraUsuario(base.UserName);
                businessExtra.Bolao = CurrentBolao;


                foreach (Model.Boloes.ApostaExtra entry in listExtra)
                {
                    IList <Framework.DataServices.Model.EntityBaseData> listPos = businessExtraUser.SelectByPosicao(CurrentBolao, entry.Posicao, null);

                    foreach (Model.Boloes.ApostaExtraUsuario modelExtraUser in listPos)
                    {
                        for (int c = 0; c < listSimulation.Count; c++)
                        {
                            if (string.Compare(listSimulation[c].UserName, modelExtraUser.UserName, true) == 0)
                            {
                                listSimulation[c].ListApostasExtras.Add(modelExtraUser);
                                break;
                            }
                        }
                    }
                }

                Classificacao = listSimulation;
                #endregion


                BindUsers();
            }
        }