Ejemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Online = TestarConexao();

            if (Online)
            {
                SorteioNegocio neg = new SorteioNegocio();

                if (neg.ModoOffline())
                {
                    Online = false;

                    if (!Aleatorio.TodosArquivosExiste())
                    {
                        Aleatorio.Serial();
                    }
                }
                else if (neg.Active())
                {
                    bancoSortearToolStripMenuItem.Visible = true;
                }
            }

            if (!Online)
            {
                sorteioToolStripMenuItem.Enabled = false;
                Aleatorio.desSerial();
                FormMessage.ShowMessegeWarning("O sistema funcionará no MODO OFFLINE!");
            }
        }
Ejemplo n.º 2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (img != null)
            {
                if (string.IsNullOrEmpty(textBoxDescricaoProd.Text))
                {
                    FormMessage.ShowMessegeWarning("Informe uma descrição para este prêmio!");
                    textBoxDescricaoProd.Select();
                    return;
                }

                infoProd = new ProdutoInfo
                {
                    produtodescricao = textBoxDescricaoProd.Text,
                    produtofoto      = ConvertImagem(img),
                    produtovalor     = Convert.ToDecimal(textBoxValor.Text)
                };

                negSort = new SorteioNegocio();
                negSort.ExecutarProduto(enumCRUD.insert, infoProd);
                FormMessage.ShowMessegeInfo("Prêmio lançado com sucesso!");

                pictureBox1.Image = Properties.Resources.portateis;
                textBoxDescricaoProd.Clear();
                textBoxDescricaoProd.Select();
                textBoxValor.Text = "1,00";

                FormProduto formProduto = (FormProduto)Application.OpenForms["FormProduto"];
                formProduto.PreencherLista();
            }
            else
            {
                FormMessage.ShowMessegeWarning("Selecione uma imagem para este prêmio!");
            }
        }
Ejemplo n.º 3
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.º 4
0
        static public void Serial()
        {
            SerializarNegocios sn       = new SerializarNegocios(path);
            SorteioNegocio     negSort  = new SorteioNegocio();
            ConcorrenteNegocio negoConc = new ConcorrenteNegocio();
            ConcorrenteColecao colC     = (ConcorrenteColecao)negoConc.ExecutarConcorrente(enumCRUD.select);

            sn.SerializarObjeto(colC, "colC.lvt", true);
            ConcorrenteColecao colV = (ConcorrenteColecao)negoConc.ExecutarConcorrente(enumCRUD.select, null, true);

            sn.SerializarObjeto(colV, "colV.lvt", true);
            BilheteColecao colB = (BilheteColecao)negSort.ExecutarBilhete(enumCRUD.select, new BilheteInfo {
                bilheteidsorteio = new SorteioInfo {
                    sorteioid = 1
                }, bilheteidconcorrente = new ConcorrenteInfo(), bilheteidvendedor = new ConcorrenteInfo()
            });

            sn.SerializarObjeto(colB, "colB.lvt", true);
            ProdutoColecao colP = (ProdutoColecao)negSort.ExecutarProduto(enumCRUD.select);

            sn.SerializarObjeto(colP, "colP.lvt", true);
            SorteioItemColecao colI = (SorteioItemColecao)negSort.ExecutarSorteioItem(enumCRUD.select, new SorteioItemInfo {
                Sort = new SorteioInfo {
                    sorteioid = 1
                }, Prod = new ProdutoInfo()
            });

            sn.SerializarObjeto(colI, "colI.lvt", true);
        }
Ejemplo n.º 5
0
        static public void ListaTxt()
        {
            SerializarNegocios sn = new SerializarNegocios(path);

            sn.CriarPasta();
            SorteioNegocio     negSort  = new SorteioNegocio();
            ConcorrenteNegocio negoConc = new ConcorrenteNegocio();
            ConcorrenteColecao colC     = (ConcorrenteColecao)negoConc.ExecutarConcorrente(enumCRUD.select, null, true);
            BilheteColecao     colB     = (BilheteColecao)negSort.ExecutarBilhete(enumCRUD.select, new BilheteInfo {
                bilheteidsorteio = new SorteioInfo {
                    sorteioid = 1
                }, bilheteidconcorrente = new ConcorrenteInfo(), bilheteidvendedor = new ConcorrenteInfo()
            });
            StringBuilder txt = new StringBuilder();

            txt.Append("LISTA DOS CONCORRENTES DO " + colB.First().bilheteidsorteio.sorteiodescricao);
            txt.AppendLine();

            txt.AppendLine("TOTAL DE BILHETES VENDIDOS: " + string.Format("{0:000}", colB.Count) + "\t\tTOTAL EM VENDAS: " + string.Format("{0:C2}", colB.FirstOrDefault().bilheteidsorteio.sorteiobilhetevalor *colB.Count));

            txt.AppendLine();
            txt.AppendLine();

            foreach (var b in colB.OrderBy(o => o.bilhetenum))
            {
                txt.Append("Bilhete: " + string.Format("{0:000}", b.bilhetenum) + "; " + "Concorrente: " + b.bilheteidconcorrente.concorrentenome + "; Vendedor: " + colC.Where(w => w.concorrenteid == b.bilheteidvendedor.concorrenteid).FirstOrDefault().concorrentenome);
                txt.AppendLine();
            }

            GravarTxt(txt.ToString(), "listaconcorrente.txt");
        }
Ejemplo n.º 6
0
        private void buttonSort_Click(object sender, EventArgs e)
        {
            negSort = new SorteioNegocio();
            SorteioColecao colSort = (SorteioColecao)negSort.ExecutarSorteio(enumCRUD.select);

            var colecao = new Form_ConsultarColecao();

            foreach (var item in colSort)
            {
                Form_Consultar form = new Form_Consultar
                {
                    Cod       = string.Format("{0:00000}", item.sorteioid),
                    Descricao = item.sorteiodescricao,
                    Objeto    = item,
                };

                colecao.Add(form);
            }

            using (FormConsultar_Cod_Descricao consult = new FormConsultar_Cod_Descricao(colecao, "SORTEIO"))
            {
                if (consult.ShowDialog(this) == DialogResult.Yes)
                {
                    textBoxIdSort.Text        = consult.Selecionado.Cod;
                    textBoxDescricaoSort.Text = consult.Selecionado.Descricao;
                    infoSort = (SorteioInfo)consult.Selecionado.Objeto;
                    ListaBilhete();
                }
            }
        }
Ejemplo n.º 7
0
        private void buttonSort_Click(object sender, EventArgs e)
        {
            negSort = new SorteioNegocio();
            SorteioColecao colSort;

            if (Form1.Online)
            {
                colSort = (SorteioColecao)negSort.ExecutarSorteio(enumCRUD.select);
            }
            else
            {
                if (Form1.colB != null)
                {
                    colSort = new SorteioColecao
                    {
                        Form1.colB[0].bilheteidsorteio
                    };
                }
                else
                {
                    colSort = null;
                }
            }

            if (colSort != null)
            {
                var colecao = new Form_ConsultarColecao();
                foreach (var item in colSort)
                {
                    Form_Consultar form = new Form_Consultar
                    {
                        Cod       = string.Format("{0:00000}", item.sorteioid),
                        Descricao = item.sorteiodescricao,
                        Objeto    = item,
                    };

                    colecao.Add(form);
                }

                using (FormConsultar_Cod_Descricao consult = new FormConsultar_Cod_Descricao(colecao, "SORTEIO"))
                {
                    if (consult.ShowDialog(this) == DialogResult.Yes)
                    {
                        this.Cursor = Cursors.WaitCursor;
                        flowLayoutPanelBilhete.Controls.Clear();
                        flowLayoutPanelProd.Controls.Clear();
                        infoSort = (SorteioInfo)consult.Selecionado.Objeto;
                        textBoxDescricaoSort.Text = consult.Selecionado.Descricao;
                        dateTimePicker1.Value     = infoSort.sorteiodata;
                        numericUpDown1.Value      = infoSort.sorteiobilhetequant;
                        textBoxValor.Text         = Convert.ToString(infoSort.sorteiobilhetevalor);

                        ContarItens();
                        buttonSortear.Enabled = true;
                        this.Cursor           = Cursors.Default;
                    }
                }
            }
        }
Ejemplo n.º 8
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.º 9
0
        public void PreencherLista()
        {
            negSort = new SorteioNegocio();
            ProdutoColecao colProd = (ProdutoColecao)negSort.ExecutarProduto(enumCRUD.select);

            flowLayoutPanel1.Controls.Clear();

            if (colProd != null)
            {
                foreach (var item in colProd)
                {
                    UserControlProdDescricao prod = new UserControlProdDescricao
                    {
                        Prod = item
                    };

                    flowLayoutPanel1.Controls.Add(prod);
                }
            }
        }
Ejemplo n.º 10
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.º 11
0
        public static void ListaVendedor(int idsort)
        {
            ConcorrenteNegocio neg      = new ConcorrenteNegocio();
            ConcorrenteColecao colecao  = (ConcorrenteColecao)neg.ExecutarConcorrente(enumCRUD.select, null, true);
            SorteioNegocio     negSort  = new SorteioNegocio();
            SorteioColecao     colSort  = (SorteioColecao)negSort.ExecutarSorteio(enumCRUD.select);
            SorteioInfo        infoSort = colSort.Where(w => w.sorteioid == idsort).FirstOrDefault();
            BilheteColecao     colB     = (BilheteColecao)negSort.ExecutarBilhete(enumCRUD.select, new BilheteInfo {
                bilheteidconcorrente = new ConcorrenteInfo(), bilheteidsorteio = infoSort, bilheteidvendedor = new ConcorrenteInfo()
            });

            if (colecao != null)
            {
                StringBuilder sb = new StringBuilder();

                int total = colB.Count();
                if (total > 0)
                {
                    //adiciona os valores gerais
                    //adiciona 2 nós com soma total de bilhete vendidos e o valor total
                    sb.AppendLine("**TOTAL GERAL**");
                    sb.AppendLine("\t - Total de vendedores: " + string.Format("{0:000}", colB.GroupBy(gp => gp.bilheteidvendedor.concorrenteid).ToList().Count - 1));
                    sb.AppendLine("\t - Total de concorrentes: " + string.Format("{0:000}", colB.GroupBy(gp => gp.bilheteidconcorrente.concorrenteid).ToList().Count - 1));
                    sb.AppendLine("\t - Total de Bilhetes Vendidos: " + string.Format("{0:000}", total));
                    sb.AppendLine("\t\t - Valor Total Vendidos: " + string.Format("{0:C2}", total * infoSort.sorteiobilhetevalor));
                    sb.AppendLine();
                }

                foreach (var item in colecao.OrderBy(o => o.concorrentenome))
                {
                    int totalBilhete = colB.Where(w => w.bilheteidvendedor.concorrenteid == item.concorrenteid).Count();

                    //adiciona os nomes dos vendedores
                    sb.AppendLine(item.concorrentenome);
                    if (totalBilhete > 0)
                    {
                        //adiciona 2 nós com soma total de bilhete vendidos e o valor total
                        sb.AppendLine("\t - Total de Bilhetes Vendidos: " + string.Format("{0:000}", totalBilhete));
                        sb.AppendLine("\t\t - 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)
                        {
                            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
                            sb.AppendLine("\t\t\t" + item1.bilheteidconcorrente.concorrentenome);
                            if (totalBilhete2 > 0)
                            {
                                sb.AppendLine("\t\t\t\t - Total de Bilhetes Comprados: " + string.Format("{0:000}", totalBilhete2));
                                sb.AppendLine("\t\t\t\t\t - Valor Total Comprados: " + string.Format("{0:C2}", totalBilhete2 * infoSort.sorteiobilhetevalor));
                            }
                        }
                    }
                }

                GravarTxt(sb.ToString(), "vendedores.txt");
            }
        }
Ejemplo n.º 12
0
        private void Salvar()
        {
            this.Cursor = Cursors.WaitCursor;
            if (string.IsNullOrEmpty(textBoxDescricaoSort.Text))
            {
                MessageBox.Show("Defina uma descrição para o sorteio!");
                textBoxDescricaoSort.Select();
                return;
            }

            int id;

            negSort = new SorteioNegocio();

            if (infoSort == null)
            {
                infoSort = new SorteioInfo
                {
                    sorteiodata         = dateTimePicker1.Value,
                    sorteiodescricao    = textBoxDescricaoSort.Text,
                    sorteiobilhetequant = Convert.ToInt32(numericUpDown1.Value),
                    sorteiobilhetevalor = Convert.ToDecimal(textBoxValor.Text)
                };

                id = (int)negSort.ExecutarSorteio(enumCRUD.insert, infoSort);

                if (id > 0)
                {
                    infoSort.sorteioid = id;
                    if (flowLayoutPanelProd.Controls.Count > 0)
                    {
                        foreach (Control item in flowLayoutPanelProd.Controls)
                        {
                            UserControlProd uProd = (UserControlProd)item;
                            SorteioItemInfo it    = new SorteioItemInfo
                            {
                                Prod  = uProd.Produto,
                                Quant = uProd.Quant,
                                Sort  = infoSort
                            };
                            negSort.ExecutarSorteioItem(enumCRUD.insert, it);
                        }

                        FormMessage.ShowMessageSave();

                        if (this.Modal)
                        {
                            this.DialogResult = DialogResult.Yes;
                        }
                        else
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Nenhum produto foi lançado!");
                    }
                }
                else
                {
                    FormMessage.ShowMessageFalha();
                }
            }
            else
            {
                id = infoSort.sorteioid;

                infoSort = new SorteioInfo
                {
                    sorteiodata         = dateTimePicker1.Value,
                    sorteiodescricao    = textBoxDescricaoSort.Text,
                    sorteiobilhetequant = Convert.ToInt32(numericUpDown1.Value),
                    sorteiobilhetevalor = Convert.ToDecimal(textBoxValor.Text),
                    sorteioid           = id
                };

                negSort.ExecutarSorteio(enumCRUD.update, infoSort);

                ExProd(listProdRem, enumCRUD.delete);
                ExProd(listProdAdd, enumCRUD.insert);
                ExProd(listProdAlt, enumCRUD.update);


                this.Cursor = Cursors.Default;
                FormMessage.ShowMessageSave();
            }
        }
Ejemplo n.º 13
0
        private void buttonSort_Click(object sender, EventArgs e)
        {
            negSort = new SorteioNegocio();
            SorteioColecao colSort = (SorteioColecao)negSort.ExecutarSorteio(enumCRUD.select);

            if (colSort != null)
            {
                var colecao = new Form_ConsultarColecao();
                foreach (var item in colSort)
                {
                    Form_Consultar form = new Form_Consultar
                    {
                        Cod       = string.Format("{0:00000}", item.sorteioid),
                        Descricao = item.sorteiodescricao,
                        Objeto    = item,
                    };

                    colecao.Add(form);
                }

                using (FormConsultar_Cod_Descricao consult = new FormConsultar_Cod_Descricao(colecao, "SORTEIO"))
                {
                    if (consult.ShowDialog(this) == DialogResult.Yes)
                    {
                        this.Cursor = Cursors.WaitCursor;
                        infoSort    = (SorteioInfo)consult.Selecionado.Objeto;
                        textBoxDescricaoSort.Text = consult.Selecionado.Descricao;
                        dateTimePicker1.Value     = infoSort.sorteiodata;
                        numericUpDown1.Value      = infoSort.sorteiobilhetequant;
                        textBoxValor.Text         = Convert.ToString(infoSort.sorteiobilhetevalor);

                        flowLayoutPanelProd.Controls.Clear();
                        SorteioItemInfo i = new SorteioItemInfo {
                            Sort = infoSort, Prod = new ProdutoInfo()
                        };
                        SorteioItemColecao colItem = (SorteioItemColecao)negSort.ExecutarSorteioItem(enumCRUD.select, i);

                        if (colItem != null)
                        {
                            foreach (var item in colItem)
                            {
                                UserControlProd prod = new UserControlProd
                                {
                                    Produto = item.Prod,
                                    Quant   = item.Quant
                                };

                                flowLayoutPanelProd.Controls.Add(prod);
                            }

                            ContarItens();
                        }


                        PreencherTree();
                        buttonSalvar.Enabled  = true;
                        buttonRemover.Enabled = true;
                        this.Cursor           = Cursors.Default;
                    }
                }
            }
        }