Ejemplo 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);
            }
        }
Ejemplo n.º 2
0
        private BilheteColecao PreencherBilheteColecao(DataTable table)
        {
            var colecao = new BilheteColecao();

            foreach (DataRow row in table.Rows)
            {
                BilheteInfo info = new BilheteInfo
                {
                    bilheteid            = Convert.ToInt32(row["bilheteid"]),
                    bilhetenum           = Convert.ToInt32(row["bilhetenum"]),
                    bilheteidconcorrente = ConcorrenteNegocio.PreencherConcorrenteInfo(row),
                    bilheteidsorteio     = PreencherSorteioInfo(row),
                    bilheteidvendedor    = new ConcorrenteInfo
                    {
                        concorrentecpf      = Convert.ToString(row["concorrentecpfv"]),
                        concorrenteemail    = Convert.ToString(row["concorrenteemailv"]),
                        concorrenteid       = Convert.ToInt32(row["concorrenteidv"]),
                        concorrentenome     = Convert.ToString(row["concorrentenomev"]),
                        concorrentetelefone = Convert.ToString(row["concorrentetelefonev"]),
                        concorrentevendedor = Convert.ToBoolean(row["concorrentevendedorv"]),
                    },
                };

                //info.bilheteidvendedor = new ConcorrenteInfo { concorrenteid = Convert.ToInt32(row["bilheteidVendedor"]) };

                colecao.Add(info);
            }

            return(colecao);
        }
Ejemplo n.º 3
0
 private void BilheteAdd(BilheteInfo a, Cnx cnz)
 {
     if (a != null)
     {
         cnz.AddMySqlParameterCollection("@id", a.bilheteid);
         cnz.AddMySqlParameterCollection("@conc", a.bilheteidconcorrente.concorrenteid);
         cnz.AddMySqlParameterCollection("@vend", a.bilheteidvendedor.concorrenteid);
         cnz.AddMySqlParameterCollection("@sort", a.bilheteidsorteio.sorteioid);
         cnz.AddMySqlParameterCollection("@num", a.bilhetenum);
     }
 }
Ejemplo n.º 4
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();
            }
        }
Ejemplo n.º 5
0
        static public void BilheteAleatorio()
        {
            SorteioNegocio negSort = new SorteioNegocio();
            BilheteColecao colB    = (BilheteColecao)negSort.ExecutarBilhete(enumCRUD.select, new BilheteInfo {
                bilheteidsorteio = new SorteioInfo {
                    sorteioid = 1
                }, bilheteidconcorrente = new ConcorrenteInfo(), bilheteidvendedor = new ConcorrenteInfo()
            });
            StringBuilder txt = new StringBuilder();
            List <int>    l   = Gerar(colB.Count + 1, colB.Count);

            for (int i = 0; i < l.Count; i++)
            {
                BilheteInfo b = colB[i];
                b.bilhetenum = l[i];

                negSort.ExecutarBilhete(enumCRUD.update, b);
            }

            FormMessage.ShowMessageSave();
        }
Ejemplo n.º 6
0
        public object ExecutarBilhete(enumCRUD en, BilheteInfo b = null)
        {
            if (cnx.Conectar())
            {
                BilheteAdd(b, cnx);

                switch (en)
                {
                case enumCRUD.select:

                    DataTable table = (DataTable)cnx.ExecutarComandoMySql("spConsultarBilheteIdSorteio", enumExecutar.DataTable);
                    if (table != null)
                    {
                        return(PreencherBilheteColecao(table));
                    }
                    else
                    {
                        return(null);
                    }

                case enumCRUD.insert:
                    return(Convert.ToInt32(cnx.ExecutarComandoMySql("spInsertBilhete", enumExecutar.Scalar)));

                case enumCRUD.update:
                    return(Convert.ToInt32(cnx.ExecutarComandoMySql("spUpdateBilhete", enumExecutar.Scalar)));

                case enumCRUD.delete:
                    return(Convert.ToInt32(cnx.ExecutarComandoMySql("spDeleteBilheteIdConcorrente", enumExecutar.Scalar)));

                default:
                    return(0);
                }
            }
            else
            {
                return(0);
            }
        }
Ejemplo n.º 7
0
        private void PreencherTree()
        {
            ConcorrenteNegocio neg     = new ConcorrenteNegocio();
            ConcorrenteColecao colecao = (ConcorrenteColecao)neg.ExecutarConcorrente(enumCRUD.select, null, true);
            BilheteInfo        b       = new BilheteInfo {
                bilheteidconcorrente = new ConcorrenteInfo(), bilheteidsorteio = infoSort, bilheteidvendedor = new ConcorrenteInfo()
            };

            colB = (BilheteColecao)negSort.ExecutarBilhete(enumCRUD.select, b);

            if (colB != null)
            {
                colConcorrente = new ConcorrenteColecao();
                foreach (var item in colB)
                {
                    var cc = colConcorrente.Where(c => c.concorrenteid == item.bilheteidconcorrente.concorrenteid).FirstOrDefault();

                    if (cc == null)
                    {
                        colConcorrente.Add(item.bilheteidconcorrente);
                    }
                }
            }

            treeView1.Nodes.Clear();
            int num = 0;

            if (colecao != null)
            {
                foreach (var item in colecao.OrderBy(o => o.concorrentenome))
                {
                    num++;
                    int num1         = 0;
                    int totalBilhete = colB.Where(w => w.bilheteidvendedor.concorrenteid == item.concorrenteid).Count();

                    //adiciona os nomes dos vendedores
                    treeView1.Nodes.Add(item.concorrentenome);
                    if (totalBilhete > 0)
                    {
                        //adiciona 2 nós com soma total de bilhete vendidos e o valor total
                        treeView1.Nodes[num - 1].Nodes.Add(" - Total de Bilhetes Vendidos: " + string.Format("{0:000}", totalBilhete));
                        treeView1.Nodes[num - 1].Nodes[0].Nodes.Add(" - Valor Total Vendidos: " + string.Format("{0:C2}", totalBilhete * infoSort.sorteiobilhetevalor));
                    }

                    BilheteColecao bc = new BilheteColecao();
                    foreach (var item1 in colB.Where(w => w.bilheteidvendedor.concorrenteid == item.concorrenteid).OrderBy(o => o.bilheteidconcorrente.concorrentenome))
                    {
                        if (bc.Where(w => w.bilheteidconcorrente.concorrenteid == item1.bilheteidconcorrente.concorrenteid).FirstOrDefault() == null)
                        {
                            num1++;
                            bc.Add(item1);
                            int totalBilhete2 = colB.Where(w => w.bilheteidconcorrente.concorrenteid == item1.bilheteidconcorrente.concorrenteid && w.bilheteidvendedor.concorrenteid == item.concorrenteid).Count();

                            //adiciona os nomes dos compradores
                            treeView1.Nodes[num - 1].Nodes[0].Nodes[0].Nodes.Add(item1.bilheteidconcorrente.concorrentenome);
                            if (totalBilhete2 > 0)
                            {
                                treeView1.Nodes[num - 1].Nodes[0].Nodes[0].Nodes[num1 - 1].Nodes.Add(" - Total de Bilhetes Comprados: " + string.Format("{0:000}", totalBilhete2));
                                treeView1.Nodes[num - 1].Nodes[0].Nodes[0].Nodes[num1 - 1].Nodes[0].Nodes.Add(" - Valor Total Comprados: " + string.Format("{0:C2}", totalBilhete2 * infoSort.sorteiobilhetevalor));
                            }
                        }
                    }
                }

                int total = colB.Count();
                if (total > 0)
                {
                    //adiciona os valores gerais
                    treeView1.Nodes.Add("TOTAL GERAL**").NodeFont = new Font(treeView1.Font, FontStyle.Bold);
                    treeView1.Nodes[num].ForeColor = Color.Maroon;
                    //adiciona 2 nós com soma total de bilhete vendidos e o valor total
                    treeView1.Nodes[num].Nodes.Add(" - Total de Bilhetes Vendidos: " + string.Format("{0:000}", total)).ForeColor = Color.Maroon;
                    treeView1.Nodes[num].Nodes[0].Nodes.Add(" - Valor Total Vendidos: " + string.Format("{0:C2}", total * infoSort.sorteiobilhetevalor)).ForeColor = Color.Maroon;
                    treeView1.Nodes[num].Expand();
                    treeView1.Nodes[num].Nodes[0].Expand();
                    treeView1.Nodes[num].Nodes[0].Nodes[0].Expand();
                }
            }
        }
Ejemplo n.º 8
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!");
                }
            }
        }