Esempio n. 1
0
        public Framework.DataServices.Model.EntityBaseData Load(string currentUser, Framework.DataServices.Model.EntityBaseData entry, out int errorNumber, out string errorDescription)
        {
            errorNumber      = 0;
            errorDescription = null;

            Model.Boloes.ApostaExtraUsuario entryData = (Model.Boloes.ApostaExtraUsuario)entry;


            DataTable table = base.ExecuteFill(CommandType.StoredProcedure, base._commandSelect, true, currentUser,
                                               base.Parameters.Create("@Posicao", DbType.Int32, entryData.Posicao),
                                               base.Parameters.Create("@UserName", DbType.Int32, entryData.UserName),
                                               base.Parameters.Create("@NomeBolao", DbType.Int32, entryData.Bolao.Nome),
                                               base.Parameters.Create("@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null)
                                               );

            int rowsFound = Convert.ToInt32(base.ExecutionStatus.Command.Parameters["@ReturnValue"].Value);

            if (rowsFound == 0)
            {
                return(null);
            }
            //throw new Exception("There is no item found in database with this ID.");


            errorNumber      = base.ExecutionStatus.ErrorNumber;
            errorDescription = base.ExecutionStatus.ErrorDescription;


            return(Util.ApostaExtraUsuario.ConvertToObject(table.Rows[0]));
        }
        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.");
        }
Esempio n. 3
0
        public bool Delete(string currentUser, Framework.DataServices.Model.EntityBaseData entry, out int errorNumber, out string errorDescription)
        {
            errorNumber      = 0;
            errorDescription = null;

            Model.Boloes.ApostaExtraUsuario entryData = (Model.Boloes.ApostaExtraUsuario)entry;

            base.ExecuteNonQuery(CommandType.StoredProcedure, base._commandDelete, true, currentUser,
                                 base.Parameters.Create("@Posicao", DbType.Int32, entryData.Posicao),
                                 base.Parameters.Create("@UserName", DbType.String, entryData.UserName),
                                 base.Parameters.Create("@NomeBolao", DbType.String, entryData.Bolao.Nome),
                                 base.Parameters.Create("@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue, null)
                                 );

            errorNumber      = base.ExecutionStatus.ErrorNumber;
            errorDescription = base.ExecutionStatus.ErrorDescription;


            return(Convert.ToInt32(base.ExecutionStatus.Command.Parameters["@ReturnValue"].Value) >= 1 ? true : false);
        }
Esempio n. 4
0
        public void GenerateApostasUsuariosFim(Stream outputStream, Document document, string imagePath, Model.Campeonatos.Campeonato campeonato, Model.Boloes.Bolao bolao, List <Framework.Security.Model.UserData> users)
        {
            PdfWriter writer = PdfWriter.GetInstance(document, outputStream);

            // we Add a Footer that will show up on PAGE 1
            HeaderFooter footer = new HeaderFooter(new Phrase("Página: "), true);

            footer.Border   = Rectangle.NO_BORDER;
            document.Footer = footer;

            // we Add a Header that will show up on PAGE 2
            HeaderFooter header = new HeaderFooter(new Phrase("Bolão: " + bolao.Nome), false);

            document.Header = header;

            document.Open();



            document.NewPage();

            _businessBolao = new Business.Boloes.Support.Bolao(_currentLogin, bolao.Nome);
            IList <Model.Boloes.BolaoMembros> classificacao = _businessBolao.LoadClassificacao(0);
            IList <Framework.DataServices.Model.EntityBaseData> listPosicoes = _businessBolao.SelectPremios();


            PdfPTable titulo = new PdfPTable(1);
            PdfPCell  cell   = new PdfPCell(new Phrase("Classificação", new Font(Font.HELVETICA, 12f, Font.BOLD, Color.BLACK)));

            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_CENTER;
            cell.BackgroundColor     = Color.YELLOW;
            titulo.AddCell(cell);
            titulo.TotalWidth = 250;
            titulo.WriteSelectedRows(0, -1, 175, 790, writer.DirectContent);


            int       max    = 55;
            PdfPTable class1 = base.CreateClassificacao(writer, imagePath, 0, max, classificacao, listPosicoes);


            if (classificacao.Count >= max)
            {
                class1.WriteSelectedRows(0, -1, 30, 765, writer.DirectContent);
                PdfPTable class2 = base.CreateClassificacao(writer, imagePath, max, max * 2, classificacao, listPosicoes);

                class2.WriteSelectedRows(0, -1, 315, 765, writer.DirectContent);
            }
            else
            {
                class1.TotalWidth = 535;
                class1.WriteSelectedRows(0, -1, 30, 765, writer.DirectContent);
            }


            PdfPTable legendas = new PdfPTable(1);

            cell = new PdfPCell(new Phrase(
                                    "Pontos = Total de Pontos, E = Total de Empates, VDE = Total de Vitórias/Derrotas/Empates, GT1 = Total de Gols do time 1, GT2 = Total de Gols do time 2, C = Acertos em cheio, EX = Pontuação extra."
                                    , new Font(Font.HELVETICA, 7f, Font.NORMAL, Color.BLACK)));
            cell.HorizontalAlignment = Element.ALIGN_LEFT;
            cell.VerticalAlignment   = Element.ALIGN_TOP;
            legendas.AddCell(cell);
            legendas.TotalWidth = 550;
            legendas.WriteSelectedRows(0, -1, 23, 70, writer.DirectContent);



            document.NewPage();

            IList <Framework.DataServices.Model.EntityBaseData> listExtra1 = new List <Framework.DataServices.Model.EntityBaseData>();//_businessApostaExtra.SelectByUser(bolao, user.UserName, null);
            IList <Framework.DataServices.Model.EntityBaseData> listAux    = _businessJogo.SelectAllByPeriod(
                campeonato, 0, DateTime.MinValue, DateTime.MaxValue, null, null, null, null, null);
            IList <Framework.DataServices.Model.EntityBaseData> listJogos = new List <Framework.DataServices.Model.EntityBaseData>();

            foreach (Model.Campeonatos.Jogo jogo in listAux)
            {
                Model.Boloes.JogoUsuario jogoUsr = new Model.Boloes.JogoUsuario();
                jogoUsr.ApostaTime1    = jogo.GolsTime1;
                jogoUsr.ApostaTime2    = jogo.GolsTime2;
                jogoUsr.Campeonato     = jogo.Campeonato;
                jogoUsr.DataJogo       = jogo.DataJogo;
                jogoUsr.DescricaoTime1 = jogo.DescricaoTime1;
                jogoUsr.DescricaoTime2 = jogo.DescricaoTime2;
                jogoUsr.Estadio        = jogo.Estadio;
                jogoUsr.Fase           = jogo.Fase;
                jogoUsr.GolsTime1      = jogo.GolsTime1;
                jogoUsr.GolsTime2      = jogo.GolsTime2;
                jogoUsr.Grupo          = jogo.Grupo;
                jogoUsr.IDJogo         = jogo.IDJogo;
                jogoUsr.JogoLabel      = jogo.JogoLabel;
                jogoUsr.PenaltisTime1  = jogo.PenaltisTime1;
                jogoUsr.PenaltisTime2  = jogo.PenaltisTime2;
                jogoUsr.Rodada         = jogo.Rodada;
                jogoUsr.Time1          = jogo.Time1;
                jogoUsr.Time2          = jogo.Time2;
                jogoUsr.Titulo         = jogo.Titulo;
                listJogos.Add(jogoUsr);


                //Campão e vice
                if (jogo.PendenteIdTime1 > 0 && jogo.PendenteIdTime1 > 0 &&
                    jogo.PendenteTime1Ganhador && jogo.PendenteTime2Ganhador && jogo.PartidaValida &&
                    string.Compare(jogo.Fase.Nome, "Final", true) == 0)
                {
                    string timeGanhador;
                    string timePerdedor;

                    if (jogo.GolsTime1 >= jogo.GolsTime2)
                    {
                        timeGanhador = jogo.Time1.Nome;
                        timePerdedor = jogo.Time2.Nome;
                    }
                    else
                    {
                        timeGanhador = jogo.Time2.Nome;
                        timePerdedor = jogo.Time1.Nome;
                    }


                    Model.Boloes.ApostaExtraUsuario extra = new Model.Boloes.ApostaExtraUsuario(1, jogoUsr.Bolao.Nome, "");
                    extra.NomeTime = timeGanhador;
                    extra.Posicao  = 1;
                    extra.Titulo   = "Campeão";
                    listExtra1.Add(extra);

                    extra          = new Model.Boloes.ApostaExtraUsuario(2, jogoUsr.Bolao.Nome, "");
                    extra.NomeTime = timePerdedor;
                    extra.Posicao  = 2;
                    extra.Titulo   = "Vice Campeão";
                    listExtra1.Add(extra);
                }


                //Terceiro e quarto
                if (jogo.PendenteIdTime1 > 0 && jogo.PendenteIdTime1 > 0 &&
                    !jogo.PendenteTime1Ganhador && !jogo.PendenteTime2Ganhador && jogo.PartidaValida &&
                    string.Compare(jogo.Fase.Nome, "Final", true) == 0)
                {
                    string timeGanhador;
                    string timePerdedor;

                    if (jogo.GolsTime1 >= jogo.GolsTime2)
                    {
                        timeGanhador = jogo.Time1.Nome;
                        timePerdedor = jogo.Time2.Nome;
                    }
                    else
                    {
                        timeGanhador = jogo.Time2.Nome;
                        timePerdedor = jogo.Time1.Nome;
                    }


                    Model.Boloes.ApostaExtraUsuario extra = new Model.Boloes.ApostaExtraUsuario(3, jogoUsr.Bolao.Nome, "");
                    extra.NomeTime = timeGanhador;
                    extra.Posicao  = 3;
                    extra.Titulo   = "Terceiro";
                    listExtra1.Add(extra);

                    extra          = new Model.Boloes.ApostaExtraUsuario(4, jogoUsr.Bolao.Nome, "");
                    extra.NomeTime = timePerdedor;
                    extra.Posicao  = 4;
                    extra.Titulo   = "Quarto";
                    listExtra1.Add(extra);
                }
            }
            //Criando a página com a lista dos dados
            base.CreatePage(false, false, 0, 0, writer, imagePath, null, listJogos, listExtra1);



            foreach (Framework.Security.Model.UserData user in users)
            {
                document.NewPage();

                //Buscando as apostas auxiliares do usuário
                IList <Framework.DataServices.Model.EntityBaseData> listExtra = _businessApostaExtra.SelectByUser(bolao, user.UserName, null);

                //Buscando as apostas dos jogos do usuário
                IList <Framework.DataServices.Model.EntityBaseData> list = _businessJogoUsuario.SelectAllByPeriod(
                    bolao, user.UserName, 0, DateTime.MinValue, DateTime.MinValue, null, null, null, null);



                int posicao = 0;
                int pontos  = 0;
                for (int c = 0; c < classificacao.Count; c++)
                {
                    if (string.Compare(classificacao[c].UserName, user.UserName, true) == 0)
                    {
                        posicao = classificacao[c].Posicao;
                        pontos  = classificacao[c].TotalPontos;
                        break;
                    }
                }



                //Criando a página com a lista dos dados
                base.CreatePage(false, true, posicao, pontos, writer, imagePath, user, list, listExtra);
            }

            document.Close();
        }
Esempio n. 5
0
        public static Framework.DataServices.Model.EntityBaseData ConvertToObject(DataRow row)
        {
            int    posicao   = 0;
            string userName  = "";
            string nomeBolao = "";


            if (row.Table.Columns.Contains("Posicao") && !Convert.IsDBNull(row["Posicao"]))
            {
                posicao = Convert.ToInt32(row["Posicao"]);
            }
            if (row.Table.Columns.Contains("UserName") && !Convert.IsDBNull(row["UserName"]))
            {
                userName = Convert.ToString(row["UserName"]);
            }
            if (row.Table.Columns.Contains("NomeBolao") && !Convert.IsDBNull(row["NomeBolao"]))
            {
                nomeBolao = Convert.ToString(row["NomeBolao"]);
            }

            Model.Boloes.ApostaExtraUsuario entry = new Model.Boloes.ApostaExtraUsuario(posicao, nomeBolao, userName);
            entry.LoadDataRow(row);

            if (row.Table.Columns.Contains("Titulo") && !Convert.IsDBNull(row["Titulo"]))
            {
                entry.Titulo = Convert.ToString(row["Titulo"]);
            }
            if (row.Table.Columns.Contains("Descricao") && !Convert.IsDBNull(row["Descricao"]))
            {
                entry.Descricao = Convert.ToString(row["Descricao"]);
            }
            if (row.Table.Columns.Contains("TotalPontos") && !Convert.IsDBNull(row["TotalPontos"]))
            {
                entry.TotalPontos = Convert.ToInt32(row["TotalPontos"]);
            }
            if (row.Table.Columns.Contains("IsValido") && !Convert.IsDBNull(row["IsValido"]))
            {
                entry.IsValido = Convert.ToBoolean(row["IsValido"]);
            }
            if (row.Table.Columns.Contains("DataValidacao") && !Convert.IsDBNull(row["DataValidacao"]))
            {
                entry.DataValidacao = Convert.ToDateTime(row["DataValidacao"]);
            }
            if (row.Table.Columns.Contains("ValidadoBy") && !Convert.IsDBNull(row["ValidadoBy"]))
            {
                entry.ValidadoBy = Convert.ToString(row["ValidadoBy"]);
            }
            if (row.Table.Columns.Contains("NomeTimeValidado") && !Convert.IsDBNull(row["NomeTimeValidado"]))
            {
                entry.NomeTimeValidado = Convert.ToString(row["NomeTimeValidado"]);
            }
            if (row.Table.Columns.Contains("DataAposta") && !Convert.IsDBNull(row["DataAposta"]))
            {
                entry.DataAposta = Convert.ToDateTime(row["DataAposta"]);
            }
            if (row.Table.Columns.Contains("Pontos") && !Convert.IsDBNull(row["Pontos"]))
            {
                entry.Pontos = Convert.ToInt32(row["Pontos"]);
            }
            if (row.Table.Columns.Contains("NomeTime") && !Convert.IsDBNull(row["NomeTime"]))
            {
                entry.NomeTime = Convert.ToString(row["NomeTime"]);
            }
            if (row.Table.Columns.Contains("IsApostaValida") && !Convert.IsDBNull(row["IsApostaValida"]))
            {
                entry.IsApostaValida = Convert.ToBoolean(row["IsApostaValida"]);
            }



            return(entry);
        }
        protected void grdApostas_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType != DataControlRowType.DataRow)
            {
                return;
            }


            DropDownList cboNomeTime = (DropDownList)e.Row.FindControl("cboNomeTime");

            Image imgTime = (Image)e.Row.FindControl("imgTime");


            IList <Framework.DataServices.Model.EntityBaseData> list =
                (IList <Framework.DataServices.Model.EntityBaseData>)ViewState["Times"];

            cboNomeTime.DataSource     = list;
            cboNomeTime.DataValueField = "Nome";
            cboNomeTime.DataTextField  = "Nome";
            cboNomeTime.DataBind();


            Model.Boloes.ApostaExtraUsuario aposta = (Model.Boloes.ApostaExtraUsuario)e.Row.DataItem;


            if (!string.IsNullOrEmpty(aposta.NomeTime))
            {
                cboNomeTime.SelectedValue = aposta.NomeTime;
            }

            Label lblPontos     = (Label)e.Row.FindControl("lblPontos");
            Label lblDataAposta = (Label)e.Row.FindControl("lblDataAposta");
            Label lblNomeTime   = (Label)e.Row.FindControl("lblNomeTime");


            if (aposta.DataAposta == DateTime.MinValue)
            {
                lblDataAposta.Text = "-";
            }
            else
            {
                lblDataAposta.Text = aposta.DataAposta.ToString("dd/MM/yyyy HH:mm:ss");
            }


            if (CurrentBolao.ApostasApenasAntes && CurrentBolao.IsIniciado)
            {
                lblPontos.Text      = aposta.Pontos.ToString();
                lblNomeTime.Visible = true;
                cboNomeTime.Visible = false;

                imgTime.ImageUrl = @"~\Images\Database\Times\" + lblNomeTime.Text + ".gif";
            }
            else
            {
                lblPontos.Text      = "-";
                lblNomeTime.Visible = false;
                cboNomeTime.Visible = true;



                imgTime.ImageUrl = @"~\Images\Database\Times\" + cboNomeTime.Text + ".gif";
            }


            //if (!aposta.IsValido)
            //{
            //    lblPontos.Text = "-";
            //    lblNomeTime.Visible = false;
            //    cboNomeTime.Visible = true;



            //    imgTime.ImageUrl = @"~\Images\Database\Times\" + cboNomeTime.Text + ".gif";
            //}
            //else
            //{
            //    lblPontos.Text = aposta.Pontos.ToString();
            //    lblNomeTime.Visible = true;
            //    cboNomeTime.Visible = false;

            //    imgTime.ImageUrl = @"~\Images\Database\Times\" + lblNomeTime.Text + ".gif";
            //}
        }
Esempio n. 7
0
        private void ApplyLine(int line, int gols1, int gols2, int desempate, int posTime1, int posTime2, ref IList <BolaoNet.Model.Boloes.BolaoMembros> membros,
                               IList <Framework.DataServices.Model.EntityBaseData> jogosUsuarios, IList <Framework.DataServices.Model.EntityBaseData> apostasExtras, bool somaJogo)
        {
            int[] pt = new int[membros.Count];



            for (int c = 0; c < membros.Count; c++)
            {
                int    totalPontos  = 0;
                int    pontosExtras = 0;
                int    multiplo     = 1;
                string nomeTime1    = "";
                string nomeTime2    = "";
                int    total        = membros[c].TotalPontos;

                Model.Boloes.JogoUsuario        jogo    = SearchJogoUsuario(jogosUsuarios, membros[c].UserName);
                Model.Boloes.ApostaExtraUsuario aposta1 = SearchApostaExtra(apostasExtras, membros[c].UserName, posTime1);
                Model.Boloes.ApostaExtraUsuario aposta2 = SearchApostaExtra(apostasExtras, membros[c].UserName, posTime2);


                if (string.Compare(jogo.Time1Classificado.Nome, "Brasil", true) == 0 || string.Compare(jogo.Time2Classificado.Nome, "Brasil", true) == 0)
                {
                    multiplo = 2;
                }

                //Verificando o vencedor válido
                if (gols1 == gols2)
                {
                    if (desempate == 1)
                    {
                        nomeTime1 = jogo.Time1Classificado.Nome;
                        nomeTime2 = jogo.Time2Classificado.Nome;
                    }
                    else
                    {
                        nomeTime1 = jogo.Time2Classificado.Nome;
                        nomeTime2 = jogo.Time1Classificado.Nome;
                    }
                }
                else if (gols1 > gols2)
                {
                    nomeTime1 = jogo.Time1Classificado.Nome;
                    nomeTime2 = jogo.Time2Classificado.Nome;
                }
                else if (gols1 < gols2)
                {
                    nomeTime1 = jogo.Time2Classificado.Nome;
                    nomeTime2 = jogo.Time1Classificado.Nome;
                }

                //Verificando o vencedor da aposta do usuário
                if (string.Compare(aposta1.NomeTime, nomeTime1, true) == 0)
                {
                    pontosExtras += 10;
                }
                if (string.Compare(aposta2.NomeTime, nomeTime2, true) == 0)
                {
                    pontosExtras += 10;
                }



                if (jogo.ApostaTime1 == gols1 && jogo.ApostaTime2 == gols2)
                {
                    totalPontos += 10;
                }
                else
                {
                    if (gols1 == jogo.ApostaTime1 || gols2 == jogo.ApostaTime2)
                    {
                        totalPontos += 1;
                    }


                    if (gols1 > gols2 && jogo.ApostaTime1 > jogo.ApostaTime2)
                    {
                        totalPontos += 3;
                    }
                    else if (gols1 < gols2 && jogo.ApostaTime1 < jogo.ApostaTime2)
                    {
                        totalPontos += 3;
                    }
                    else if (gols1 == gols2 && jogo.ApostaTime1 == jogo.ApostaTime2)
                    {
                        totalPontos += 5;
                    }
                }

                if (somaJogo)
                {
                    total += (totalPontos * multiplo) + pontosExtras;
                }
                else
                {
                    total += pontosExtras;
                }

                if (pontosExtras > 0 && !somaJogo)
                {
                    membros[c].TotalPontos += pontosExtras;
                }

                excel.SetNumber(line, PosGols1, gols1);
                excel.SetNumber(line, PosGols2, gols2);
                excel.SetNumber(line, PosDesempate, desempate);


                excel.SetNumber(line, PosStartName + 1 + (c * 4), total);

                //if (somaJogo)
                //    excel.SetNumber(line, PosStartName + 2 + (c * 4), (totalPontos * multiplo) + pontosExtras);
                //else
                //    excel.SetNumber(line, PosStartName + 2 + (c * 4), pontosExtras);

                excel.SetNumber(line, PosStartName + 2 + (c * 4), (totalPontos * multiplo));
                excel.SetNumber(line, PosStartName + 3 + (c * 4), pontosExtras);



                pt[c] = total;
            }

            int currentMax;
            int posMax          = -1;
            int currentPosition = 1;
            int countPosition   = 1;

            do
            {
                posMax     = -1;
                currentMax = 0;

                currentPosition = countPosition;

                for (int c = 0; c < pt.Length; c++)
                {
                    if (pt[c] > currentMax)
                    {
                        currentMax = pt[c];
                        posMax     = c;
                    }
                }
                if (posMax != -1)
                {
                    for (int c = 0; c < pt.Length; c++)
                    {
                        if (currentMax == pt[c])
                        {
                            excel.SetNumber(line, PosStartName + (c * 4), currentPosition);
                            countPosition++;

                            pt[c] = 0;
                        }
                    }
                }
            } while (posMax != -1);
        }