public List<ClienteVO> consultarClientesVentas() { List<ClienteVO> clientes = new List<ClienteVO>(); try { string sqlQuery = "Select v.Nit, v.Cliente From EstacionDB.VO.VentaVO v Group By v.Nit, v.Cliente Order By v.Cliente"; IQuery query = ConnectionHelper.getCurrentSession(Utilidades.Utilidades.configExpo).CreateQuery(sqlQuery); IList tmp = query.List(); foreach (object[] venta in tmp) { ClienteVO c = new ClienteVO(); c.Identificacion = venta[0].ToString(); c.Nombre = venta[1].ToString(); clientes.Add(c); } ConnectionHelper.CloseSession(); return clientes; } catch (System.Exception ex) { ConnectionHelper.CloseSession(); throw new EstacionDBException("Error al leer la información de la vista Ventas.", ex); } }
private void cmdCancelar_Click(object sender, EventArgs e) { currentClient = null; cboTipoId.SelectedIndex = 0; txtId.Text = ""; txtNombre.Text = ""; txtDireccion.Text = ""; txtTelefono.Text = ""; txtContacto.Text = ""; txtCorreo.Text = ""; txtCodigo.Text = ""; txtConsecutivo.Text = ""; cboTipoId.Focus(); }
public int guardarCliente(ClienteVO cliente) { int rows = 0; ITransaction tx = null; try { ISession session = ConnectionHelper.getCurrentSession(Utilidades.Utilidades.configExpo); tx = session.BeginTransaction(); if (cliente.IdCliente == 0) { session.Save(cliente); } else { session.Update(cliente); } rows++; tx.Commit(); ConnectionHelper.CloseSession(); return rows; } catch (System.Exception ex) { if (tx != null) { tx.Rollback(); } ConnectionHelper.CloseSession(); throw new EstacionDBException("Error al leer la información de la tabla clientes.", ex); } }
public bool guardarCliente(ClienteVO cliente) { bool result = false; try { int rows = getClientesDAO().guardarCliente(cliente); if (rows > 0) { result = true; } return result; } catch (EstacionDBException ex) { throw new PersistenciaException("Error en la actualizacion de cliente en DB app.", ex); } }
private void cmdGuardar_Click(object sender, EventArgs e) { if (txtId.Text.Equals("") || txtNombre.Text.Equals("") || txtDireccion.Text.Equals("")) { MessageBox.Show("Debe ingresar el Tipo de indentificación, el número de identificación, el nombre y la dirección del cliente", "", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { ClienteVO cli = new ClienteVO(); if (currentClient != null) { cli.IdCliente = currentClient.IdCliente; } else { cli.IdCliente = 0; } cli.TipoId = (long)cboTipoId.SelectedValue; cli.Identificacion = txtId.Text; cli.Nombre = txtNombre.Text; cli.Direccion = txtDireccion.Text; cli.Telefono = txtTelefono.Text; cli.Contacto = txtContacto.Text; cli.Email = txtCorreo.Text; cli.Codigo = txtCodigo.Text; cli.Consecutivo = txtConsecutivo.Text; if (cp.guardarCliente(cli)) { MessageBox.Show("Datos del cliente han sido guardados", "", MessageBoxButtons.OK, MessageBoxIcon.Information); clienteVOBindingSource.DataSource = cp.consultarClientes(); } else { MessageBox.Show("No se pudo guardar los datos del cliente", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private void dataGridView1_SelectionChanged(object sender, EventArgs e) { if (clienteVOBindingSource.Current != null) { currentClient = (ClienteVO)clienteVOBindingSource.Current; cboTipoId.SelectedValue = currentClient.TipoId; txtId.Text = currentClient.Identificacion; txtCodigo.Text = currentClient.Codigo; txtNombre.Text = currentClient.Nombre; txtDireccion.Text = currentClient.Direccion; txtTelefono.Text = currentClient.Telefono; txtContacto.Text = currentClient.Contacto; txtCorreo.Text = currentClient.Email; txtConsecutivo.Text = currentClient.Consecutivo; } cboTipoId.Focus(); }