public void PreencherProd(UserControlProd p) { bool b = true; UserControlProd p1 = new UserControlProd(); foreach (var item in this.flowLayoutPanelProd.Controls) { p1 = (UserControlProd)item; if (p1.Produto.produtoid == p.Produto.produtoid) { b = false; if (FormMessage.ShowMessegeQuestion("Este Prêmio já foi adicionado a lista! Deseja " + (p.Quant > 0 ? "acrescentar mais " : "REMOVER ") + Environment.NewLine + string.Format("{0:00}", Math.Abs(p.Quant)) + (Math.Abs(p.Quant) > 1 ? " UNIDADES" : " UNIDADE") + "?") == DialogResult.Yes) { p1.AlterarQuant(p.Quant); listProdAlt.Add(p1); } break; } } if (b) { this.flowLayoutPanelProd.Controls.Add(p); this.listProdAdd.Add(p); this.buttonSalvar.Enabled = true; this.buttonRemover.Enabled = true; } ContarItens(); }
private static void Form_Fechando(object sender, FormClosingEventArgs e) { if (ButtonSalvar.Enabled) { if (FormMessage.ShowMessegeQuestion("Deseja descartar as alterações?") == DialogResult.No) { e.Cancel = true; } } }
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(); }
private void bancoSortearToolStripMenuItem_Click(object sender, EventArgs e) { if (FormMessage.ShowMessegeQuestion("Deseja embaralhar os bilhetes?") == DialogResult.Yes) { Aleatorio.BilheteAleatorio(); Aleatorio.Serial(); } Aleatorio.ListaVendedor(1); Aleatorio.ListaTxt(); }
private void buttonSalvar_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(textBoxDescricaoSort.Text) && flowLayoutPanelProd.Controls.Count > 0) { if (FormMessage.ShowMessegeQuestion("Deseja salvar?") == DialogResult.Yes) { Salvar(); } } else { FormMessage.ShowMessegeWarning("Insira uma descrição para o sorteio e adicione no mínimo um produto para salvar!"); textBoxDescricaoSort.Select(); } }
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!"); } } }