private void ConcorrenteAdd(ConcorrenteInfo a, Cnx cnz) { if (a != null) { cnz.AddMySqlParameterCollection("@id", a.concorrenteid); cnz.AddMySqlParameterCollection("@cpf", a.concorrentecpf); cnz.AddMySqlParameterCollection("@nome", a.concorrentenome); cnz.AddMySqlParameterCollection("@email", a.concorrenteemail); cnz.AddMySqlParameterCollection("@tel", a.concorrentetelefone); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 2) { infoConc = (ConcorrenteInfo)dataGridView1.SelectedRows[0].DataBoundItem; if (this.Modal) { DialogResult = DialogResult.Yes; } } }
private void buttonVendBuscar_Click(object sender, EventArgs e) { using (FormVendedor formVendedor = new FormVendedor(true)) { if (formVendedor.ShowDialog(this) == DialogResult.Yes) { infoVend = formVendedor.infoConc; textBoxVendCod.Text = string.Format("{0:0000}", infoVend.concorrenteid); textBoxVendNome.Text = infoVend.concorrentenome; } } }
static public ConcorrenteInfo PreencherConcorrenteInfo(DataRow row) { ConcorrenteInfo info = new ConcorrenteInfo { concorrentecpf = Convert.ToString(row["concorrentecpf"]), concorrenteemail = Convert.ToString(row["concorrenteemail"]), concorrenteid = Convert.ToInt32(row["concorrenteid"]), concorrentenome = Convert.ToString(row["concorrentenome"]), concorrentetelefone = Convert.ToString(row["concorrentetelefone"]), concorrentevendedor = Convert.ToBoolean(row["concorrentevendedor"]), }; return(info); }
private void button1_Click(object sender, EventArgs e) { using (FormVendedor formVendedor = new FormVendedor(false)) { if (formVendedor.ShowDialog(this) == DialogResult.Yes) { infoConc = formVendedor.infoConc; maskedTextBoxCpf.Text = infoConc.concorrentecpf; textBoxNome.Text = infoConc.concorrentenome; textBoxEmail.Text = infoConc.concorrenteemail; maskedTextBoxTel.Text = infoConc.concorrentetelefone; buttonSort.Enabled = true; if (!string.IsNullOrEmpty(textBoxIdSort.Text)) { controlBilhete = Aleatorio.NumSorteio(); ListaBilhete(); } } } }
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(); } } } }
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; } } }
public object ExecutarConcorrente(enumCRUD en, ConcorrenteInfo info = null, bool vendedor = false) { if (cnx.Conectar()) { int n = 0; ConcorrenteAdd(info, cnx); switch (en) { case enumCRUD.select: DataTable dataTable; if (info == null) { if (vendedor) { dataTable = (DataTable)cnx.ExecutarComandoMySql("spConsultarVendedor", enumExecutar.DataTable); } else { dataTable = (DataTable)cnx.ExecutarComandoMySql("spConsultarTodosConcorrente", enumExecutar.DataTable); } //else // dataTable = (DataTable)cnx.ExecutarComandoMySql("spConsultarConcorrente", enumExecutar.DataTable); } else { dataTable = (DataTable)cnx.ExecutarComandoMySql("spConsultarConcorrenteCpf", enumExecutar.DataTable); } if (dataTable != null) { return(PreencherConcorrenteColecao(dataTable)); } else { return(null); } case enumCRUD.insert: if (vendedor) { n = Convert.ToInt32(cnx.ExecutarComandoMySql("spInsertVendedor", enumExecutar.Scalar)); } else { n = Convert.ToInt32(cnx.ExecutarComandoMySql("spInsertConcorrente", enumExecutar.Scalar)); } break; case enumCRUD.update: break; case enumCRUD.delete: break; default: break; } return(n); } else { return(0); } }