I would like to know:
How to validate from a textBox the existence of a record stored in the database?
That is, write in the textBox the name of the record and when you press the "Search" button, I get a message that tells me that the record exists.
This is what I have done.
And it's in my "Search" button:
using (ProductosEF _bdVentas = new ProductosEF())
{
Producto _Producto = new Producto();
var BuscarProducto = _bdVentas.BusquedaProductos(textBox8.Text.Trim()).ToList();
txtcodei.Text = BuscarProducto.FirstOrDefault().codigo_interno;
txtcodebar.Text = BuscarProducto.FirstOrDefault().codigo_barra;
txtdescripcion.Text = BuscarProducto.FirstOrDefault().descripcion;
txtmarca.Text = BuscarProducto.FirstOrDefault().marca;
txttamaño.Text = BuscarProducto.FirstOrDefault().tamaño;
txtcosto.Text = BuscarProducto.FirstOrDefault().costo.ToString();
txtprecio.Text = BuscarProducto.FirstOrDefault().precio.ToString();
It works like this:
I write the code in the textBox, I press the button, and then it brings me the records associated with the code. What I want to know is:
As: Valid that, if the code exists, show me a message of existence, otherwise I enable my corresponding fields to create the new product.