/**Saca todos los clientes de la tabla correspondiente cuyo nombre contenga el input y los agrega a nuestra collection de clientes **/ private void cargarClientes(String input, ObservableCollection<Cliente> queryCol) { queryCol.Clear(); if (string.IsNullOrEmpty(input) || string.IsNullOrWhiteSpace(input)) { return; } MySqlCommand instruccion = connection.CreateCommand(); if(cl_nameSearch.IsChecked.Value) instruccion.CommandText = "call BUSCA_CLIENTE(\'" + input + "\')"; else instruccion.CommandText = "call BUSCA_CLIENTE_RUC(\'" + input + "\')"; MySqlDataReader reader = instruccion.ExecuteReader(); while (reader.Read()) { Cliente cl = new Cliente(); cl.cl_ruc = reader["RUC"].ToString(); cl.cl_nombre = reader["CNOMBRE"].ToString(); cl.cl_direccion = reader["DIRECCION"].ToString(); cl.cl_ruta = reader["NRUTA"].ToString(); cl.cl_key = reader["IDCLIENTE"].ToString(); queryCol.Add(cl); } reader.Close(); }
/**Saca todos los clientes de la tabla correspondiente y los agrega a nuestra collection de clientes **/ private void cargarClientes() { MySqlCommand instruccion = connection.CreateCommand(); instruccion.CommandText = "call GET_CLIENTES()"; MySqlDataReader reader = instruccion.ExecuteReader(); while (reader.Read()) { Cliente cl = new Cliente(); cl.cl_ruc = reader["RUC"].ToString(); cl.cl_nombre = reader["CNOMBRE"].ToString(); cl.cl_direccion = reader["DIRECCION"].ToString(); cl.cl_ruta = reader["NRUTA"].ToString(); cl.cl_key = reader["IDCLIENTE"].ToString(); ClientesCollection.Add(cl); } reader.Close(); cargarTelefonosClientes(); }