private void Busqueda() { try { clsSQL Consulta = new clsSQL(); DataSet ds; String strSQL = "select id_key_cliente,Nombre,id_key_Provincia_fiscal, Direccion_fiscal, CP_fiscal from Clientes where"; String txtWhere = String.Empty; this.grdClientes.DataSource = null; if (this.txtCIF.Text.Trim() != String.Empty) { txtWhere = " CIF like '%" + txtCIF.Text + "%' and"; } if (this.txtNombre.Text.Trim() != String.Empty) { txtWhere = txtWhere + " Nombre like '%" + txtNombre.Text + "%' and"; } if (this.txtProvincia.Text.Trim() != String.Empty) { txtWhere = txtWhere + " Provincia like '%" + txtProvincia.Text + "%' and"; } if (txtWhere.Trim() == String.Empty) { strSQL = "select id_key_cliente,Nombre,id_key_Provincia_fiscal, Direccion_fiscal, CP_fiscal from Clientes"; } if (txtWhere.Trim().EndsWith("and")) { txtWhere = txtWhere.Substring(0, txtWhere.Length - 3); } strSQL = strSQL + txtWhere + " order by Nombre"; ds = Consulta.devolverDataSetSelect(strSQL); this.grdClientes.DataSource = ds.Tables[0]; this.grdClientes.Columns[0].Visible = false; //this.grdVehiculos.Columns[0].Visible = false; ds.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), mdPrincipal.Nombre_App, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Buscar() { try { clsSQL Consulta = new clsSQL(); DataSet ds; String strSQL = "select id_key_vehiculo,(marca + ' ' + modelo) as Marca,Matricula,num_bastidor as Numero_bastidor from Vehiculos where"; String txtWhere = String.Empty; this.grdVehiculos.DataSource = null; if (this.txtMatricula.Text.Trim() != String.Empty) { txtWhere = " matricula like '%" + txtMatricula.Text + "%' and"; } if (this.txtNumBastidor.Text.Trim() != String.Empty) { txtWhere = txtWhere + " num_bastidor like '%" + txtNumBastidor.Text + "%' and"; } if (this.txtMarca.Text.Trim() != String.Empty) { txtWhere = txtWhere + " marca like '%" + txtMarca.Text + "%' and"; } if (txtWhere.Trim() == String.Empty) { strSQL = "select id_key_vehiculo,(marca + ' ' + modelo) as Marca,matricula,num_bastidor as Numero_bastidor from Vehiculos"; } if (txtWhere.Trim().EndsWith("and")) { txtWhere = txtWhere.Substring(0, txtWhere.Length - 3); } strSQL = strSQL + txtWhere + " order by matricula"; ds = Consulta.devolverDataSetSelect(strSQL); this.grdVehiculos.DataSource = ds.Tables[0]; this.grdVehiculos.Columns[0].Visible = false; //this.grdVehiculos.Columns[0].Visible = false; ds.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), mdPrincipal.Nombre_App, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Buscar() { try { clsSQL Consulta = new clsSQL(); DataSet ds; String strSQL = "select id_key_ruta,Descripcion,origen,destino,km,precio,peajes from Rutas where"; String txtWhere = String.Empty; this.grdRutas.DataSource = null; if (this.txtDescripcion.Text.Trim() != String.Empty) { txtWhere = " descripcion like '%" + txtDescripcion.Text + "%' and"; } if (this.txtOrigen.Text.Trim() != String.Empty) { txtWhere = txtWhere + " origen like '%" + txtOrigen.Text + "%' and"; } if (this.txtDestino.Text.Trim() != String.Empty) { txtWhere = txtWhere + " destino like '%" + txtDestino.Text + "%' and"; } if (txtWhere.Trim() == String.Empty) { strSQL = "select id_key_ruta,origen,destino,km,precio,peajes from Rutas"; } if (txtWhere.Trim().EndsWith("and")) { txtWhere = txtWhere.Substring(0, txtWhere.Length - 3); } strSQL = strSQL + txtWhere + " order by descripcion"; ds = Consulta.devolverDataSetSelect(strSQL); this.grdRutas.DataSource = ds.Tables[0]; this.grdRutas.Columns[0].Visible = false; //this.grdVehiculos.Columns[0].Visible = false; ds.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), mdPrincipal.Nombre_App, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Buscar() { try { clsSQL Consulta = new clsSQL(); DataSet ds; String strSQL = "select * from v_facturas_compra where"; String txtWhere = String.Empty; this.grdFacturasCompra.DataSource = null; if (this.txtNumFactura.Text.Trim() != String.Empty) { txtWhere = " num_factura like '%" + txtNumFactura.Text + "%' and"; } if (this.txtProveedor.Text.Trim() != String.Empty) { txtWhere = " nombre_proveedor like '%" + txtProveedor.Text + "%' and"; } if (txtWhere.Trim() == String.Empty) { strSQL = "select * from v_facturas_compra"; } if (txtWhere.Trim().EndsWith("and")) { txtWhere = txtWhere.Substring(0, txtWhere.Length - 3); } strSQL = strSQL + txtWhere; ds = Consulta.devolverDataSetSelect(strSQL); this.grdFacturasCompra.DataSource = ds.Tables[0]; this.grdFacturasCompra.Columns[0].Visible = false; //this.grdVehiculos.Columns[0].Visible = false; ds.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), mdPrincipal.Nombre_App, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Buscar() { try { clsSQL Consulta = new clsSQL(); DataSet ds; String strSQL = "select * from Ruedas"; String txtWhere = String.Empty; this.grdRuedas.DataSource = null; ds = Consulta.devolverDataSetSelect(strSQL); this.grdRuedas.DataSource = ds.Tables[0]; this.grdRuedas.Columns[0].Visible = false; //this.grdVehiculos.Columns[0].Visible = false; ds.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), mdPrincipal.Nombre_App, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cargaServicios(DateTime _fecha_desde, DateTime _fecha_hasta) { try { clsSQL Consulta = new clsSQL(); DataSet ds; String strSQL = "select id_key_servicio,fecha,hora,cliente,desde,hasta,conductor,vehiculo,menus,km,estado from v_Servicios where convert(date,fecha) between (convert(date,'" + _fecha_desde.ToShortDateString() + "')) and (convert(date,'" + _fecha_hasta.ToShortDateString() + "'))"; String txtWhere = String.Empty; this.grdAgenda.DataSource = null; strSQL = strSQL + txtWhere + " order by hora"; ds = Consulta.devolverDataSetSelect(strSQL); this.grdAgenda.DataSource = ds.Tables[0]; this.grdAgenda.Columns[0].Visible = false; ds.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), mdPrincipal.Nombre_App, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Buscar() { try { clsSQL Consulta = new clsSQL(); DataSet ds; String strSQL = "select id_key_empleado,NIF,Nombre,Apellido1,Apellido2,Departamento,Puesto from v_Empleados where"; String txtWhere = String.Empty; this.grdEmpleados.DataSource = null; if (this.txtNombre.Text.Trim() != String.Empty) { txtWhere = " nombre like '%" + txtNombre.Text + "%' and"; } if (this.txtApellido1.Text.Trim() != String.Empty) { txtWhere = txtWhere + " apellido1 like '%" + txtApellido1.Text + "%' and"; } if (this.txtApellido2.Text.Trim() != String.Empty) { txtWhere = txtWhere + " apellido2 like '%" + txtApellido2.Text + "%' and"; } if (this.txtNIF.Text.Trim() != String.Empty) { txtWhere = txtWhere + " NIF like '%" + txtNIF.Text + "%' and"; } if (this.cmbPuesto.Text.Trim() != String.Empty) { txtWhere = txtWhere + " id_key_puesto like '%" + cmbPuesto.SelectedValue.ToString() + "%' and"; } if (this.cmbDepartamento.Text.Trim() != String.Empty) { txtWhere = txtWhere + " id_key_departamento like '%" + cmbDepartamento.SelectedValue.ToString() + "%' and"; } if (txtWhere.Trim() == String.Empty) { strSQL = "select id_key_empleado,NIF,Nombre,Apellido1,Apellido2,Departamento,Puesto from v_Empleados"; } if (txtWhere.Trim().EndsWith("and")) { txtWhere = txtWhere.Substring(0, txtWhere.Length - 3); } strSQL = strSQL + txtWhere + " order by NIF"; ds = Consulta.devolverDataSetSelect(strSQL); this.grdEmpleados.DataSource = ds.Tables[0]; this.grdEmpleados.Columns[0].Visible = false; //this.grdVehiculos.Columns[0].Visible = false; ds.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), mdPrincipal.Nombre_App, MessageBoxButtons.OK, MessageBoxIcon.Error); } }