private void cboCliente_SelectedIndexChanged(object sender, EventArgs e) { if (cboCliente.SelectedValue != null) { if (edit == false) { using (IConnection Conexion = new Connection()) { //Para nuevo nro de Orçamento IDAO <OrcCab> dao = new DAOOrcCab(Conexion); codnew = dao.CurremRegVal(); if (codnew == "") { txtCodigo.Text = "1"; } else { int newcod = int.Parse(codnew) + 1; txtCodigo.Text = newcod.ToString(); } } } using (IConnection Conexion = new Connection()) { IDAO <Cliente> dao = new DAOCliente(Conexion); Cliente entity = dao.FindOrDefault(cboCliente.SelectedValue);//Objeto tipo Modulos(tabela) if (entity != null) { txtNome.Text = entity.Nome; txtTelefone.Text = entity.Telefone; } } } }
private void btnBuscar_Click(object sender, EventArgs e) { frm_Pesquisa.nomeFormulario = nomeFormulario; frm_Pesquisa fp = new frm_Pesquisa(); fp.ShowDialog(); if (fp.Codigo != null) { using (IConnection Conexion = new Connection()) { IDAO<Cliente> daoCli = new DAOCliente(Conexion); Cliente cli = daoCli.FindOrDefault(fp.Codigo); txtCodigo.Text = cli.Id.ToString(); txtNome.Text = cli.Nome; txtTelefone.Text = cli.Telefone; dgvCliente.Rows.Clear(); int renglon = dgvCliente.Rows.Add(); dgvCliente.Rows[renglon].Cells["Id"].Value = cli.Id.ToString(); dgvCliente.Rows[renglon].Cells["Nome"].Value = cultureinfo.TextInfo.ToTitleCase(cli.Nome.ToString().ToLower().Trim()); dgvCliente.Rows[renglon].Cells["Telefone"].Value = cultureinfo.TextInfo.ToTitleCase(cli.Telefone.ToString().ToLower().Trim()); btnAdd.Visible = false; //btnBuscar.Visible = false; btnSalvar.Visible = true; btnDelete.Visible = true; btnCancelar.Visible = true; } } }
private void btnDelete_Click(object sender, EventArgs e) { using (IConnection Conexion = new Connection()) { IDAO<Cliente> daoCli = new DAOCliente(Conexion); Cliente cli = daoCli.FindOrDefault(txtCodigo.Text); daoCli.Delete(cli); } DefaultObjetos(); }
private void dgvCliente_Click(object sender, EventArgs e) { btnAdd.Visible = false; //btnBuscar.Visible = false; btnSalvar.Visible = true; btnDelete.Visible = true; btnCancelar.Visible = true; string xcod = dgvCliente.CurrentRow.Cells["Id"].Value.ToString(); using (IConnection conexion = new Connection()) { IDAO<Cliente> daoCli = new DAOCliente(conexion); Cliente cli = daoCli.FindOrDefault(xcod); txtCodigo.Text = cli.Id.ToString(); txtNome.Text = cli.Nome; txtTelefone.Text = cli.Telefone; } }
private void btnSearch_Click(object sender, EventArgs e) { if (txtCodigo.Text == "") { mensagemInfoExibir("Informe o código para pesquisar!", "Pesquisa"); txtCodigo.Focus(); return; } if (nomeFormulario == "frmCliente") { using (IConnection Conexion = new Connection()) { IDAO <Cliente> daoCli = new DAOCliente(Conexion); Cliente cli = daoCli.FindOrDefault(txtCodigo.Text); if (cli != null) { dgvSearch.Rows.Clear(); int renglon = dgvSearch.Rows.Add(); dgvSearch.Rows[renglon].Cells["Id"].Value = cli.Id.ToString(); dgvSearch.Rows[renglon].Cells["Nome"].Value = cli.Nome.ToString(); } else { mensagemInfoExibir("Codigo não existe!", "Pesquisa"); txtCodigo.Focus(); } } } if (nomeFormulario == "frmProduto") { using (IConnection Conexion = new Connection()) { IDAO <Produto> daoProd = new DAOProduto(Conexion); Produto prod = daoProd.FindOrDefault(txtCodigo.Text); if (prod != null) { dgvSearch.Rows.Clear(); int renglon = dgvSearch.Rows.Add(); dgvSearch.Rows[renglon].Cells["Id"].Value = prod.Id.ToString(); dgvSearch.Rows[renglon].Cells["Nome"].Value = prod.Nome.ToString(); } else { mensagemInfoExibir("Codigo não existe!", "Pesquisa"); txtCodigo.Focus(); } } } if (nomeFormulario == "frmOrcamento") { using (IConnection Conexion = new Connection()) { IDAO <OrcCab> dao = new DAOOrcCab(Conexion); OrcCab oc = dao.FindOrDefault(txtCodigo.Text); if (oc != null) { dgvSearch.Rows.Clear(); int renglon = dgvSearch.Rows.Add(); dgvSearch.Rows[renglon].Cells["Id"].Value = oc.Nro.ToString(); dgvSearch.Rows[renglon].Cells["Data"].Value = oc.Data.ToString(); } else { mensagemInfoExibir("Codigo não existe!", "Pesquisa"); txtCodigo.Focus(); } } } }