Exemplo n.º 1
0
        private void BilheteSelecionado()
        {
            negSort = new SorteioNegocio();
            BilheteInfo b3 = new BilheteInfo {
                bilheteidconcorrente = new ConcorrenteInfo(), bilheteidsorteio = infoSort, bilheteidvendedor = new ConcorrenteInfo()
            };

            if (Form1.Online)
            {
                colBilhete = (BilheteColecao)negSort.ExecutarBilhete(enumCRUD.select, b3);
            }
            else
            {
                colBilhete = Form1.colB;
            }

            if (colBilhete != null)
            {
                foreach (var bi in colBilhete)
                {
                    UserControlBilhete b = (UserControlBilhete)flowLayoutPanelBilhete.Controls[bi.bilhetenum - 1];
                    b.Botao.BackColor = Color.GreenYellow;
                }

                labelBilheteContar.Text = "Total de bilhetes vendidos: " + string.Format("{0:000}", colBilhete.Count) + "/" + "Arrecadado: " + string.Format("{0:C2}", colBilhete.Count * infoSort.sorteiobilhetevalor);
            }
        }
Exemplo n.º 2
0
        public void RevelarNum()
        {
            int n = 0;

            foreach (var item in flowLayoutPanelBilhete.Controls)
            {
                UserControlBilhete b = (UserControlBilhete)item;

                if (b.Botao.BackColor == Color.Blue)
                {
                    ++n;
                }
            }

            if (n == 0)
            {
                foreach (var item in flowLayoutPanelBilhete.Controls)
                {
                    UserControlBilhete b = (UserControlBilhete)item; if (b.Botao.BackColor == Color.White)
                    {
                        b.Botao.ForeColor = Color.Black;
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void buttonSelecionar_Click(object sender, EventArgs e)
        {
            if (numericUpDown1.Value == 0)
            {
                return;
            }

            //lista de bilhetes livres para seleção
            List <UserControlBilhete> numBilhetes = new List <UserControlBilhete>();

            //preencher a lista de bilhestes livres
            foreach (Control item in flowLayoutPanel1.Controls)
            {
                UserControlBilhete b = (UserControlBilhete)item;
                if (b.Botao.Enabled && b.Botao.BackColor != Color.GreenYellow)
                {
                    numBilhetes.Add(b);
                }
            }

            if (numBilhetes.Count < (int)numericUpDown1.Value)
            {
                if (numBilhetes.Count == 0)
                {
                    FormMessage.ShowMessegeWarning("Todos os bilhetes já foram vendidos!");
                }
                else
                {
                    if (FormMessage.ShowMessegeQuestion("Há somente " + numBilhetes.Count + " bilhetes para serem vendidos, deseja selecionar todos?") == DialogResult.Yes)
                    {
                        foreach (var item in numBilhetes)
                        {
                            Button b = item.Botao;
                            BotaoSelcionado(b);
                        }
                    }
                }

                return;
            }

            //lista dos numeros aleatórios
            List <int> numA = Aleatorio.Gerar(numBilhetes.Count, (int)numericUpDown1.Value);

            //seleciona da lista com bilhetes sorteado
            foreach (var item in numA)
            {
                Button b = numBilhetes[item].Botao;
                BotaoSelcionado(b);
            }
            numericUpDown1.Value = 0;


            ContarVerde();
        }
Exemplo n.º 4
0
 private void NumSorteio()
 {
     listBilhete = new Control[1000];
     for (int i = 0; i < 1000; i++)
     {
         UserControlBilhete b = new UserControlBilhete();
         b.Texto        = (i + 1).ToString();
         b.Nome         = "_" + (i + 1).ToString();
         b.Enabled      = false;
         listBilhete[i] = b;
     }
 }
Exemplo n.º 5
0
 private void NumSorteio(int n)
 {
     flowLayoutPanelBilhete.Controls.Clear();
     for (int i = 0; i < n; i++)
     {
         UserControlBilhete b = new UserControlBilhete();
         b.Texto   = (i + 1).ToString();
         b.Nome    = "_" + (i + 1).ToString();
         b.Enabled = false;
         flowLayoutPanelBilhete.Controls.Add(b);
     }
 }
Exemplo n.º 6
0
        public void ContarVerde()
        {
            int num = 0;

            foreach (var item in flowLayoutPanel1.Controls)
            {
                UserControlBilhete b = (UserControlBilhete)item;

                if (b.Botao.BackColor == Color.GreenYellow)
                {
                    ++num;
                }
            }

            labelTotal.Text = "Total de bilhetes: " + string.Format("{0:000}", num);
        }
Exemplo n.º 7
0
        private void BilheteSelecionado()
        {
            negSort = new SorteioNegocio();
            BilheteInfo b3 = new BilheteInfo {
                bilheteidconcorrente = new ConcorrenteInfo(), bilheteidsorteio = infoSort, bilheteidvendedor = new ConcorrenteInfo()
            };
            BilheteColecao colecao = (BilheteColecao)negSort.ExecutarBilhete(enumCRUD.select, b3);

            if (colecao != null)
            {
                foreach (var bi in colecao)
                {
                    UserControlBilhete b = (UserControlBilhete)flowLayoutPanel1.Controls[bi.bilhetenum - 1];
                    if (bi.bilheteidconcorrente.concorrenteid == infoConc.concorrenteid)
                    {
                        BotaoSelcionado(b.Botao);
                    }
                    else
                    {
                        b.Enabled = false;
                    }

                    //foreach (var bu in flowLayoutPanel1.Controls)
                    //{
                    //    UserControlBilhete b = (UserControlBilhete)bu;

                    //    BilheteInfo info = colecao.Where(b1 => b1.bilheteidconcorrente.concorrenteid == infoConc.concorrenteid)
                    //        .Where(b2 => b2.bilhetenum == Convert.ToInt32(b.Texto)).FirstOrDefault();

                    //    if (info != null)
                    //        BotaoSelcionado(b.Botao);

                    //    if (bi.bilhetenum == Convert.ToInt32(b.Texto))
                    //    {
                    //        if (b.Botao.BackColor != Color.GreenYellow)
                    //        {
                    //            b.Enabled = false;
                    //            break;
                    //        }
                    //    }
                    //}
                }
                ContarVerde();
            }
        }
Exemplo n.º 8
0
        private void NumSorteio(int n, bool limp = false)
        {
            flowLayoutPanelBilhete.Controls.Clear();
            for (int i = 0; i < n; i++)
            {
                SorteadoInfo       bi = new SorteadoInfo();
                UserControlBilhete b  = new UserControlBilhete(bi);
                b.Texto = (i + 1).ToString();
                b.Nome  = "_" + (i + 1).ToString();

                if (limp)
                {
                    b.MudarCorBotao(Color.White, Color.White);
                }

                flowLayoutPanelBilhete.Controls.Add(b);
            }
        }
Exemplo n.º 9
0
        private void buttonSortear_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            flowLayoutPanelBilhete.Controls.Clear();
            NumSorteio(infoSort.sorteiobilhetequant, true);

            //gera uma lista de numeros sorteados baseado na quantidade de prêmios
            List <int> num = Aleatorio.Gerar(colBilhete.Count + 1, colItens.Sum(i => i.Quant));

            //gera uma lista de número não repetido baseado na quantidade produto
            List <int>         num2  = Aleatorio.Gerar(colItens.Sum(i => i.Quant) + 1, colItens.Sum(i => i.Quant));
            List <ProdutoInfo> lProd = new List <ProdutoInfo>();

            //adiciona os prêmios retidas vezes baseado na quantidade do mesmo
            foreach (var item in colItens)
            {
                for (int i = 0; i < item.Quant; i++)
                {
                    lProd.Add(item.Prod);
                }
            }

            int cont = 0;

            colSorteado = new SorteadoColecao();
            for (int i = 0; i < num.Count; i++)
            {
                UserControlBilhete b = (UserControlBilhete)flowLayoutPanelBilhete.Controls[num[i] - 1];

                SorteadoInfo s = new SorteadoInfo
                {
                    Prod    = lProd[num2[cont++] - 1], //seleciona o prêmio de forma aleatória e vincula a um sorteado
                    Bilhete = colBilhete.Where(w => w.bilhetenum == colBilhete[num[i] - 1].bilhetenum).FirstOrDefault(),
                };

                colSorteado.Add(s);
                b.Sorteado(s);
                b.Botao.BackColor = Color.Blue;
                b.Botao.ForeColor = Color.Blue;
            }

            SalvarTxt();
            this.Cursor = Cursors.Default;
        }
Exemplo n.º 10
0
        private void buttonSalvar_Click(object sender, EventArgs e)
        {
            //negCon = new ConcorrenteNegocio();
            //negSort = new SorteioNegocio();
            //ConcorrenteColecao col = negCon.CadTest();
            //ConcorrenteColecao col2 = (ConcorrenteColecao)negCon.ExecutarConcorrente(enumCRUD.select);
            //ConcorrenteColecao col3 = (ConcorrenteColecao)negCon.ExecutarConcorrente(enumCRUD.select, null, true);

            //foreach (var item in col)
            //{
            //    BilheteInfo b = new BilheteInfo
            //    {
            //        bilheteidconcorrente = col2.Where(w => w.concorrentenome == item.concorrentenome).FirstOrDefault(),
            //        bilheteidvendedor = col3.Where(w => w.concorrentenome == item.concorrenteemail.ToUpper()).FirstOrDefault(),
            //        bilheteidsorteio = new SorteioInfo { sorteioid = 1},
            //        bilhetenum = Convert.ToInt32(item.concorrentecpf)
            //    };

            //    negSort.ExecutarBilhete(enumCRUD.insert, b);
            //}

            //FormMessage.ShowMessageSave();
            //return;

            if (string.IsNullOrEmpty(textBoxNome.Text) || string.IsNullOrEmpty(textBoxIdSort.Text) || string.IsNullOrEmpty(textBoxVendCod.Text))
            {
                if (string.IsNullOrEmpty(textBoxNome.Text))
                {
                    FormMessage.ShowMessegeWarning("Selecione o concorrente!");
                    button1.Select();
                    return;
                }

                if (string.IsNullOrEmpty(textBoxIdSort.Text))
                {
                    FormMessage.ShowMessegeWarning("Selecione um sorteio!");
                    buttonSort.Select();
                    return;
                }

                if (string.IsNullOrEmpty(textBoxVendCod.Text))
                {
                    FormMessage.ShowMessegeWarning("Selecione o vendedor!");
                    buttonVendBuscar.Select();
                    return;
                }
            }

            if (FormMessage.ShowMessegeQuestion("Salvar?") == DialogResult.Yes)
            {
                this.Cursor = Cursors.WaitCursor;
                int         id = 0;
                BilheteInfo b1 = new BilheteInfo {
                    bilheteidconcorrente = infoConc, bilheteidsorteio = infoSort, bilheteidvendedor = infoVend
                };
                negSort.ExecutarBilhete(enumCRUD.delete, b1);
                foreach (var item in flowLayoutPanel1.Controls)
                {
                    UserControlBilhete bi = (UserControlBilhete)item;

                    if (bi.Botao.BackColor == Color.GreenYellow)
                    {
                        BilheteInfo b = new BilheteInfo
                        {
                            bilheteidconcorrente = infoConc,
                            bilheteidsorteio     = infoSort,
                            bilheteidvendedor    = infoVend,
                            bilhetenum           = Convert.ToInt32(bi.Botao.Text)
                        };
                        id = (int)negSort.ExecutarBilhete(enumCRUD.insert, b);
                    }
                }

                this.Cursor = Cursors.Default;

                if (id > 0)
                {
                    FormMessage.ShowMessageSave();
                    Limpar();
                }
                else
                {
                    FormMessage.ShowMessegeWarning("Nenhum bilhete selecionado!");
                }
            }
        }