private void button1_Click(object sender, EventArgs e) { ClientesBl busqueda = new ClientesBl(); if (rbNombre.Checked == true) { dgvClientes.DataSource = busqueda.BusquedaClientes(txtBusqueda.Text, "Nombre"); } else if (rbDocumento.Checked == true) { dgvClientes.DataSource = busqueda.BusquedaClientes(txtBusqueda.Text, "Documento"); } if (txtBusqueda.Text == "") { dgvClientes.DataSource = null; } }
//public void LimpiarLbl(params Label[] text) //{ // for (int i = 0; i < text.Length; i++) // { // text[i].Hide(); // } //} private void Toolstborrar_Click(object sender, EventArgs e) { ClientesBl Cambiar = new ClientesBl(); Clientes entidades = new Clientes(); try { if (MessageBox.Show("Esta Seguro de que quiere Borrar este registro?", "Borrando", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { entidades.ID_Cliente = ID; entidades.Estado = "N"; Cambiar.EliminarClientes(entidades); ToolstNuevo.PerformClick(); MessageBox.Show("Registro Borrado.", "Eliminado", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception) { throw; } }
private void toolStripButton2_Click(object sender, EventArgs e) { try { if (Validar()) { if (UP == true) { Clientes entidad = new Clientes(); ClientesBl actualizar = new ClientesBl(); if (ID < 1) { MessageBox.Show("Debe seleccionar un registro valido antes de actualizar." + " Por favor seleccione un registro en la pestaña de busqueda que desea actualizar " + "y vuelva a intentarlo.", "Error de eliminación", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { entidad.ID_Cliente = ID; entidad.Nombre = TxtNombre.Text; entidad.Apellido = TxtApellido.Text; entidad.Direccion = TxtDireccion.Text; entidad.Documento = TxtDocumento.Text; entidad.Telefono = TxtTelefono.Text; actualizar.ActualizarClientes(entidad); MessageBox.Show("Registro Actualizado.", "Actualización", MessageBoxButtons.OK, MessageBoxIcon.Information); UP = false; return; } } if (UP == false) { ClientesBl Pro = new ClientesBl(); Clientes entidad = new Clientes(); if (TxtApellido.Text == string.Empty) { TxtApellido.Text = null; } if (TxtDireccion.Text == string.Empty) { TxtDireccion.Text = null; } if (TxtTelefono.Text == string.Empty) { TxtTelefono.Text = null; } //if (TxtApellido.Text == string.Empty) // TxtApellido.Text = null; //if (txtSaldoActual.Text == string.Empty) // txtSaldoActual.Text = "0.0"; //float SaldoIn = float.Parse(txtSaldoInicial.Text); //float SaldoAct = float.Parse(txtSaldoActual.Text); // entidad.ID_Producto = ID; entidad.Nombre = TxtNombre.Text; entidad.Apellido = TxtApellido.Text; entidad.Direccion = TxtDireccion.Text; entidad.Documento = TxtDocumento.Text; entidad.Telefono = TxtTelefono.Text; entidad.Estado = "Y"; Pro.RegClientes(entidad); // dgvClientes.Update(); // LlenarGrid(); MessageBox.Show("Registro agregado con exito.", "Agregado", MessageBoxButtons.OK, MessageBoxIcon.Information); ToolstNuevo.PerformClick(); } } else { MessageBox.Show("Hay campos que son obligatorios que se encuentran vacios.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Error); if (string.IsNullOrWhiteSpace(TxtNombre.Text)) { errorProvider1.SetError(TxtNombre, "Este Campo es requerido"); } if (string.IsNullOrWhiteSpace(TxtDocumento.Text)) { errorProvider1.SetError(TxtDocumento, "Este Campo es requerido"); } } } catch (Exception) { throw; } }