コード例 #1
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);
        }
コード例 #2
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");
        }
コード例 #3
0
 private void FormVendedor_Load(object sender, EventArgs e)
 {
     negCon  = new ConcorrenteNegocio();
     colecao = (ConcorrenteColecao)negCon.ExecutarConcorrente(enumCRUD.select, null, vendedor);
     dataGridView1.DataSource = colecao;
     if (colecao == null)
     {
         buttonSave.Visible = true;
     }
 }
コード例 #4
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (!(string.IsNullOrEmpty(textBoxNome.Text) && string.IsNullOrEmpty(textBoxEmail.Text) && string.IsNullOrEmpty(maskedTextBoxTel.Text)))
            {
                negCon = new ConcorrenteNegocio();
                if (id == 0)
                {
                    ConcorrenteInfo con = new ConcorrenteInfo
                    {
                        concorrentecpf      = maskedTextBoxCpf.Text,
                        concorrenteemail    = textBoxEmail.Text,
                        concorrentenome     = textBoxNome.Text,
                        concorrentetelefone = maskedTextBoxTel.Text
                    };

                    id = (int)negCon.ExecutarConcorrente(enumCRUD.insert, con, vendedor);
                    con.concorrenteid = id;
                    infoConc          = con;

                    if (this.Modal)
                    {
                        DialogResult = DialogResult.Yes;
                    }
                    else
                    {
                        negCon  = new ConcorrenteNegocio();
                        colecao = (ConcorrenteColecao)negCon.ExecutarConcorrente(enumCRUD.select, null, vendedor);

                        dataGridView1.DataSource = colecao;
                        buttonSave.Visible       = false;
                        maskedTextBoxCpf.Text    = string.Empty;
                        maskedTextBoxTel.Text    = string.Empty;
                        textBoxNome.Clear();
                        textBoxEmail.Clear();
                        maskedTextBoxCpf.Select();
                    }
                }
            }
        }
コード例 #5
0
 private void maskedTextBoxCpf_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(maskedTextBoxCpf.Text))
     {
         if (maskedTextBoxCpf.Text.Length == 11)
         {
             ValidarCpfCnpj cpf = new ValidarCpfCnpj(maskedTextBoxCpf.Text);
             if (cpf.CpfCpnjValido())
             {
                 negCon = new ConcorrenteNegocio();
                 ConcorrenteInfo c = new ConcorrenteInfo {
                     concorrentecpf = maskedTextBoxCpf.Text
                 };
                 infoConc = (ConcorrenteInfo)negCon.ExecutarConcorrente(enumCRUD.select, c);
                 if (infoConc != null)
                 {
                     textBoxNome.Text         = infoConc.concorrentenome;
                     textBoxEmail.Text        = infoConc.concorrenteemail;
                     maskedTextBoxTel.Text    = infoConc.concorrentetelefone;
                     groupBoxVendedor.Enabled = true;
                     groupBoxSorteio.Enabled  = true;
                     groupBoxNum.Enabled      = true;
                     groupBoxNome.Enabled     = false;
                 }
             }
             else
             {
                 maskedTextBoxCpf.Text = string.Empty;
             }
         }
         else
         {
             maskedTextBoxCpf.Text = string.Empty;
         }
     }
 }
コード例 #6
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");
            }
        }
コード例 #7
0
ファイル: SorteioAdd.cs プロジェクト: nandolevit/Sorteio
        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();
                }
            }
        }