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 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!"); } }
private void buttonRemover_Click(object sender, EventArgs e) { int n = 0; List <UserControlProd> l = new List <UserControlProd>(); foreach (var item in flowLayoutPanelProd.Controls) { UserControlProd prod = (UserControlProd)item; if (prod.BackColor == Color.Gray) { l.Add(prod); ++n; } } if (n == 0) { FormMessage.ShowMessegeWarning("Selecione um produto para que seja removido!"); } else { for (int i = 0; i < l.Count; i++) { flowLayoutPanelProd.Controls.Remove(l[i]); listProdRem.Add(l[i]); } } 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 static void FormatTextBox_AoPerderFoco(object sender, EventArgs e) { TextBox box = sender as TextBox; if (!FormTextoFormat.ValidaEmail(box.Text)) { FormMessage.ShowMessegeWarning("E-mail inválido, campo será definico como \" [email protected]\""); box.Text = "*****@*****.**"; } }
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 Selecionar() { if (dataGridViewConsultar.SelectedRows.Count > 0) { Selecionado = (Form_Consultar)dataGridViewConsultar.SelectedRows[0].DataBoundItem; DialogResult = DialogResult.Yes; } else { FormMessage.ShowMessegeWarning("Selecione um item da lista!"); } }
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(); } }
public static bool ValidaEmail(string texto) { string padrao = @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" + @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-0-9a-z]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$"; //@"(@\w+\.\w+)(\.\w+)*$"; string novoTexto = FormatarEmail(texto).Trim(); Regex er = new Regex(padrao, RegexOptions.IgnoreCase); if (er.IsMatch(novoTexto)) { return(true); } else { FormMessage.ShowMessegeWarning(texto + " EMAIL INVÁLIDO!"); return(false); } }
private void buttonOK_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(textBox1.Text)) { if (Txt != enumTexto.texto) { if (Convert.ToInt32(textBox1.Text) == 0) { FormMessage.ShowMessegeWarning("Insira valores diferente de zero!"); textBox1.Clear(); textBox1.Select(); return; } } Descricao = textBox1.Text; this.DialogResult = DialogResult.Yes; } else { FormMessage.ShowMessegeWarning("Preencha o campo!"); } }
private void PreencherProd() { using (OpenFileDialog open = new OpenFileDialog()) { open.Title = "Selecionar uma foto..."; open.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); open.Filter = "Arquivos(*.jpg, *.jpeg, *.png)|*.jpg;*.jpeg;*.png"; //open.RestoreDirectory = true; if (open.ShowDialog() == DialogResult.OK) { FileInfo file = new FileInfo(open.FileName); if (file.Length < 50000) { try { img = Image.FromStream(open.OpenFile()); pictureBox1.Image = img; } catch (Exception) { FormMessage.ShowMessegeWarning("A imagem apresentou algum tipo de incompatibilidade, selecione outra!"); PreencherProd(); } } else { MessageBox.Show("Este arquivo possue mais de 50KB, a foto deve ser menor!"); PreencherProd(); } } } textBoxDescricaoProd.Select(); }
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(); } }
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!"); } } }