private void bindingSource1_CurrentChanged(object sender, EventArgs e) { // The desired page has changed, so fetch the page of records using the "Current" offset int offset = (int)bindingSource1.Current; var records = new List <ClienteHistorial>(); for (int i = offset; i < offset + pageSize && i < totalRecords; i++) { ClienteHistorial test = new ClienteHistorial(); records.Add(DBHelper.clieGetHistorial(DBHelper.clienteGetId(VariablesGlobales.usuario.id))[i]); } dgvHistorial.DataSource = records; }
public static List <ClienteHistorial> clieGetHistorial(int id) { SqlConnection conn = new SqlConnection(Connection.getStringConnection()); conn.Open(); string SQL = "SELECT DISTINCT c.compra_id, c.compra_fecha, i.item_monto, f.fact_pago_desc " + "FROM EL_REJUNTE.Compra c, EL_REJUNTE.Ubicacion_compra uc, EL_REJUNTE.Ubicacion u, EL_REJUNTE.Item_Factura i, EL_REJUNTE.Factura f " + "WHERE c.compra_id = uc.compra_id AND " + "uc.ubica_id = u.ubica_id AND " + "i.item_ubicacion_id = u.ubica_id AND " + "f.fact_id = i.item_factura_id AND " + "c.compra_cliente_id = " + id + " AND " + "f.fact_cliente_id = " + id + " " + "ORDER BY c.compra_id"; SqlCommand command = new SqlCommand(SQL, conn); command.Connection = conn; command.CommandType = CommandType.Text; SqlDataReader reader = command.ExecuteReader() as SqlDataReader; List <ClienteHistorial> clientes = new List <ClienteHistorial>(); if (reader.HasRows) { while (reader.Read()) { ClienteHistorial cliente = new ClienteHistorial(); cliente.id_Compra = Int32.Parse(reader["compra_id"].ToString()); cliente.Descripcion_Del_Pago = reader["fact_pago_desc"].ToString(); cliente.Fecha_De_Compra = Convert.ToDateTime(reader["compra_fecha"]); cliente.Monto_De_Item = float.Parse(reader["item_monto"].ToString()); clientes.Add(cliente); } } conn.Close(); return(clientes); }