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!"); } } }