Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Client Side Reporting with Visual Studio in S Sharp
PREMIUM
Số trang
494
Kích thước
13.6 MB
Định dạng
PDF
Lượt xem
853

Client Side Reporting with Visual Studio in S Sharp

Nội dung xem thử

Mô tả chi tiết

this print for content only—size & color not accurate spine = 0.939" 496 page count

Books for professionals by professionals®

Client-Side Reporting

with Visual Studio in C#

Dear Reader,

Thank you for buying this book. I wrote it as a reference to developing stunning

client-side reports step-by-step using Visual Studio. I sincerely hope that you

will enjoy each featured reporting project. I further hope that this book will be

your tool to master the craft of professional report development.

This book covers the 2005 and 2008 releases of Visual Studio. I wanted to

give you a single point of reference to create reports with all clients that are

available for development using the Visual Studio IDE.

All examples in this book are based on real-world experience. Whether you

need to create a travel itinerary or a complex chart of accounts, you’ll see all

sorts of interesting reporting patterns in action.

There are many books available on the server-side aspects of reporting services

(RS). However, there are no references available that address client-side features

of RS, and the overwhelming response I received for some of my articles on that

topic compelled me to take on this book project.

I tried my best to address common challenges faced by all of us, whether

beginner or seasoned report developers. If you consider yourself in the professional

category, you can jump to any chapter of your interest. However, if you are a

newbie, please go through all the chapters sequentially.

I’m a big fan of listening to my readers’ comments. Therefore, please let me

know your thoughts; I’m always eager to hear them. Finally, I hope you’ll find all

the answers to your queries in the contents of this book. Happy reporting!

Asif Sayed

US $49.99

Shelve in

.NET

User level:

Intermediate–Advanced

Sayed Client-Side Reporting with Visual Studio in C#

The EXPERT’s VOIce® in Reporting Services

Client-Side

Reporting with

Visual Studio in C#

 CYAN

MAGENTA

 YELLOW

BLACK

 PANTONE 123 C

Asif Sayed

Companion

eBook Available

www.apress.com

SOURCE CODE ONLINE

Companion eBook

See last page for details

on $10 eBook version

ISBN-13: 978-1-59059-854-2

ISBN-10: 1-59059-854-7

9 781590 598542

5 4 9 9 9

Prepare for tomorrow by learning real-world

practical reporting projects today!

Related Titles

Covering Versions

2005 and 2008

Using C#

Covering Versions

2005 and 2008

Using C#

Asif Sayed

Client-Side Reporting

with Visual Studio in C#

8547FMfinal.qxd 8/30/07 3:34 PM Page i

Client-Side Reporting with Visual Studio in C#

Copyright © 2007 by Asif Sayed

All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,

electronic or mechanical, including photocopying, recording, or by any information storage or retrieval

system, without the prior written permission of the copyright owner and the publisher.

ISBN-13 (pbk): 978-1-59059-854-2

ISBN-10 (pbk): 1-59059-854-7

Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1

Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence

of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark

owner, with no intention of infringement of the trademark.

Java™ and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc., in the

US and other countries. Apress, Inc., is not affiliated with Sun Microsystems, Inc., and this book was writ￾ten without endorsement from Sun Microsystems, Inc.

Lead Editors: Jim Huddleston, Jeff Pepper

Technical Reviewer: Ty Anderson

Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jason Gilmore,

Jonathan Hassell, Chris Mills, Matthew Moodie, Jeffrey Pepper, Ben Renow-Clarke,

Dominic Shakeshaft, Matt Wade, Tom Welsh

Project Manager: Kylie Johnston

Copy Edit Manager: Nicole Flores

Copy Editor: Heather Lang

Assistant Production Director: Kari Brooks-Copony

Production Editor: Ellie Fountain

Compositors: Dina Quan and Linda Weidemann

Proofreader: Nancy Riddiough

Indexer: Carol Burbo

Artist: Kinetic Publishing Services, LLC

Cover Designer: Kurt Krames

Manufacturing Director: Tom Debolski

Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,

New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected],

or visit http://www.springeronline.com.

For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600,

Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit

http://www.apress.com.

The information in this book is distributed on an “as is” basis, without warranty. Although every

precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have

any liability to any person or entity with respect to any loss or damage caused or alleged to be caused

directly or indirectly by the information contained in this work.

The source code for this book is available to readers at http://www.apress.com in the Source Code/

Download section.

8547FMfinal.qxd 8/30/07 3:34 PM Page ii

This book is dedicated to the late James Huddleston (the initial editor

of this book) and to my loving family and friends who provided the

support, love, and encouragement that made this endeavor possible.

8547FMfinal.qxd 8/30/07 3:34 PM Page iii

8547FMfinal.qxd 8/30/07 3:34 PM Page iv

Contents at a Glance

About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii

About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii

■CHAPTER 1 What Is Client-Side Reporting? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

■CHAPTER 2 Client-Side Reporting Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

■CHAPTER 3 Data Models, Datasets, and the ADO.NET Interface . . . . . . . . . . . . . 51

■CHAPTER 4 Reporting with Windows Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

■CHAPTER 5 Reporting with ASP.NET Web Forms. . . . . . . . . . . . . . . . . . . . . . . . . . . 147

■CHAPTER 6 Reporting with Web Services and Mobile Devices. . . . . . . . . . . . . . 227

■CHAPTER 7 Reporting with a Console Application. . . . . . . . . . . . . . . . . . . . . . . . . . 253

■CHAPTER 8 Reporting with a Windows Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285

■CHAPTER 9 Reporting with Web Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309

■CHAPTER 10 Reporting on Other Data Sources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329

■CHAPTER 11 Integrating Server-Side Reports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

■CHAPTER 12 Moving from Crystal Reports to Reporting Services . . . . . . . . . . . . 369

■CHAPTER 13 Using Third-Party Tools and Having Fun with RS. . . . . . . . . . . . . . . 385

■CHAPTER 14 Reporting with Visual Studio 2008 Windows Forms . . . . . . . . . . . . 407

■CHAPTER 15 Reporting with Visual Studio 2008 Web Forms. . . . . . . . . . . . . . . . . 431

■APPENDIX The Visual Studio 2005 IDE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443

■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455

v

8547FMfinal.qxd 8/30/07 3:34 PM Page v

8547FMfinal.qxd 8/30/07 3:34 PM Page vi

Contents

About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii

About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii

■CHAPTER 1 What Is Client-Side Reporting? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Reporting Dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Client-Side Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Client-Side Architecture Characteristics . . . . . . . . . . . . . . . . . . . . . . . . 2

Server-Side Reporting Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Customers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Vendors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Executives and Managers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Line Managers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Everyone Else . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

What Applications Are Supported?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Windows Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Web Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Windows Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

The Report Creation Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Connecting to the Data Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Binding the Data to the Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

A Real-World Report in Action! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

A Hands-On Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Challenge: Defining the Reporting Project. . . . . . . . . . . . . . . . . . . . . . 11

Process: Applying the Three Steps in Developing a Report . . . . . . . 12

Practice: Enhancing Your Understanding with Exercises. . . . . . . . . . 13

vii

8547FMfinal.qxd 8/30/07 3:34 PM Page vii

Report Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Body . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Footer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Creating Better Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Report Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

The Form/Page Pattern. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

The Tabular Details Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

The Multicolumn Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

The Grouped Data Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

The Matrix/Pivot Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

The Chart/Graph Pattern. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

The Drill-Through Pattern. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

The “As You Like It” Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

■CHAPTER 2 Client-Side Reporting Components . . . . . . . . . . . . . . . . . . . . . . . . 23

Report Designer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

Report Design Surface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

Adding Headers and Footers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

Report Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

Report Parameters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Report Items. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Textbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

Rectangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Image. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

Subreport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

Formatting Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

Format Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

What Are the Most Common Formats? . . . . . . . . . . . . . . . . . . . . . . . . 40

Beautification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Colors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

Text Alignment and Decoration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

viii ■CONTENTS

8547FMfinal.qxd 8/30/07 3:34 PM Page viii

Expression Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

Conditional Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

Report Data Source. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

ReportViewer Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

Why Do We Need ReportViewer? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

Zoom Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

Report Export Choices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

■CHAPTER 3 Data Models, Datasets, and the ADO.NET Interface . . . . . . 51

Working with a Real-World Sample Database . . . . . . . . . . . . . . . . . . . . . . . 51

Understanding the Data Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

Attaching the RealWorld Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

Gathering Data into a Dataset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

What Is a Dataset?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

Creating a Typed Dataset Manually . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

Creating a Typed Dataset Using the Wizard . . . . . . . . . . . . . . . . . . . . 61

Creating the ADO.NET C# Interface Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

What Is ADO.NET? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

Getting to Know the Data Provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

Writing the C# Interface Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

■CHAPTER 4 Reporting with Windows Forms. . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

Windows Forms 101. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

Creating a Windows Forms Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

Adding the ReportViewer to the Form . . . . . . . . . . . . . . . . . . . . . . . . . 78

Adding a Dataset to the Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

Using This Project As a Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

Your First Reporting Project Is on Its Way . . .. . . . . . . . . . . . . . . . . . . 83

Product List Reorder Point Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

Business Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

Selecting the Primary Report Items . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

Creating a Windows Forms Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

Step 1: Creating a Data Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . . 89

Designing the Page Header and Footer . . . . . . . . . . . . . . . . . . . . . . . 93

Designing the Body Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

■CONTENTS ix

8547FMfinal.qxd 8/30/07 3:34 PM Page ix

Beautification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

Step 3: Writing C# Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

Let the Show Begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

Moving On to the Next Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

Customer Address List Report. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

Business Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

Using the Multicolumn Capabilities of RS . . . . . . . . . . . . . . . . . . . . . 107

Creating a Windows Forms Project. . . . . . . . . . . . . . . . . . . . . . . . . . . 108

Step 1: Creating a Data Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 109

Step 3: Writing the C# Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

Stock Inventory Transfer Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

Business Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

Using the Subreport Feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

Creating the Windows Forms Project . . . . . . . . . . . . . . . . . . . . . . . . . 117

Step 1: Creating the Data Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 120

Step 3: Writing the C# Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

Divisionwise Five Years’ Sales Performance . . . . . . . . . . . . . . . . . . . . . . . 130

Business Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

Using the Matrix Feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

Creating a Windows Forms Project. . . . . . . . . . . . . . . . . . . . . . . . . . . 132

Step 1: Creating a Data Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 133

Step 3: Writing the C# Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

Error: The Source of the Report Definition Has Not Been Specified . . . 140

Error: The Report Definition of Report

‘rptProductReorder.rdlc’ Has Not Been Specified . . . . . . . . . . . . . 140

Error: A Data Source Instance Has Not Been Supplied for

the Data Source ‘dsProductReorder_dtProductReorder’. . . . . . . . 141

There’s No Compile Error, But the Report Runs With

No Output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

x ■CONTENTS

8547FMfinal.qxd 8/30/07 3:34 PM Page x

■CHAPTER 5 Reporting with ASP.NET Web Forms. . . . . . . . . . . . . . . . . . . . . . 147

ASP.NET Web Sites 101 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

Creating a Web Site Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

Adding ReportViewer to Default.aspx. . . . . . . . . . . . . . . . . . . . . . . . . 150

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

Aged Accounts Receivables Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

Business Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

Getting the Web Site Ready . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

Step 1: Creating a Data Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 156

Step 3: Writing C# Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

Sales Profit Analysis Report. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

Business Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168

Getting the Web Site Ready . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

Step 1: Creating a Data Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 170

Step 3: Writing the C# Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176

Net Income Comparison Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

Business Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178

Getting the Web Site Ready . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178

Step 1: Creating Business Object Collections . . . . . . . . . . . . . . . . . . 179

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 181

Step 3: Writing C# Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

Product Information and Inventory Status Report . . . . . . . . . . . . . . . . . . . 188

Using the Drill-through Feature. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

Getting the Web Site Ready . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

Step 1: Creating the Data Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 193

Step 3: Writing the C# Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

Chart of Accounts Report in English. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206

Business Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

Getting the Web Site Ready . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

Step 1: Creating the Data Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 209

Step 3: Writing the C# Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

■CONTENTS xi

8547FMfinal.qxd 8/30/07 3:34 PM Page xi

Chart of Accounts Report in Arabic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

Getting the Web Site Ready . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217

Step 1: Creating the Data Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 220

Step 3: Writing the C# Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226

Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226

■CHAPTER 6 Reporting with Web Services and Mobile Devices. . . . . . . 227

What Is a Web Service? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

Web Services 101 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228

Creating a Web Service Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228

Adding a Web Method to Service.cs . . . . . . . . . . . . . . . . . . . . . . . . . 230

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

How Does the Web Service Work? . . . . . . . . . . . . . . . . . . . . . . . . . . . 233

Creating a Travel Itinerary Report. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234

Business Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

Getting the Web Service Ready . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

Step 1: Creating a Data Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 238

Step 3: Writing the C# Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241

Building the Itinerary Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . 243

Consuming the Web Service with a Windows Forms Client. . . . . . 244

Building the WinFormClient Project . . . . . . . . . . . . . . . . . . . . . . . . . . 248

Reporting with Mobile Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248

Mobile Devices Supported by VS 2005 . . . . . . . . . . . . . . . . . . . . . . . 249

Report Design Considerations for Mobile Devices . . . . . . . . . . . . . . 250

Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251

■CHAPTER 7 Reporting with a Console Application . . . . . . . . . . . . . . . . . . . . 253

Console Applications 101. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

Creating a Console Application Project . . . . . . . . . . . . . . . . . . . . . . . 254

User Interaction with a Console Application . . . . . . . . . . . . . . . . . . . 255

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256

Customer E-mail List by Country Report . . . . . . . . . . . . . . . . . . . . . . . . . . . 257

Business Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258

Getting the Host Client Ready . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258

xii ■CONTENTS

8547FMfinal.qxd 8/30/07 3:34 PM Page xii

Step 1: Creating a Data Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 260

Step 3: Writing the C# Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

Daily Vendor Purchase Order Summary Report . . . . . . . . . . . . . . . . . . . . . 270

Business Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271

Getting the Host Client Ready . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272

Step 1: Creating a DataTable. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273

Step 2: Designing a Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . 273

Step 3: Write the C# Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

Building and Scheduling the Project . . . . . . . . . . . . . . . . . . . . . . . . . 282

Troubleshooting Console Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284

■CHAPTER 8 Reporting with a Windows Service . . . . . . . . . . . . . . . . . . . . . . . 285

Windows Services 101 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285

Creating a Windows Service Project. . . . . . . . . . . . . . . . . . . . . . . . . . 286

Adding an Installer to the Windows Service Project . . . . . . . . . . . . 287

User Interaction with a Windows Service . . . . . . . . . . . . . . . . . . . . . 289

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291

Installing the Windows Service Application. . . . . . . . . . . . . . . . . . . . 292

Uninstalling a Windows Service Application . . . . . . . . . . . . . . . . . . . 292

Creating the New Complaints Report. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293

Business Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294

Getting the Windows Service Ready. . . . . . . . . . . . . . . . . . . . . . . . . . 294

Step 1: Creating a Data Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 296

Step 3: Writing C# Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307

Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307

■CHAPTER 9 Reporting with Web Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309

Web Parts 101 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309

Creating a Web Site Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

Adding Web Parts to the default.aspx Page . . . . . . . . . . . . . . . . . . . 311

Add the ReportViewer Control to the WebPartZone . . . . . . . . . . . . . 312

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315

■CONTENTS xiii

8547FMfinal.qxd 8/30/07 3:34 PM Page xiii

Creating the Branch Sales Performance Chart. . . . . . . . . . . . . . . . . . . . . . 316

Business Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317

Getting the Web Site Ready . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317

Step 1: Creating a Data Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 319

Step 3: Writing the C# Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327

Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327

■CHAPTER 10 Reporting on Other Data Sources . . . . . . . . . . . . . . . . . . . . . . . . . 329

Exploring Other Data Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329

Reporting with MS Access Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330

Creating a Windows Forms Project. . . . . . . . . . . . . . . . . . . . . . . . . . . 331

Step 1: Creating a Data Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 334

Step 3: Writing the C# Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340

Reporting with XML Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341

Creating a Windows Forms Project. . . . . . . . . . . . . . . . . . . . . . . . . . . 343

Step 1: Creating a Data Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 345

Step 3: Writing the C# Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349

Reporting with Oracle Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349

Creating the Windows Forms Project . . . . . . . . . . . . . . . . . . . . . . . . . 351

Step 1: Creating a Data Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352

Step 2: Designing the Report Layout . . . . . . . . . . . . . . . . . . . . . . . . . 352

Step 3: Writing the C# Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354

Building the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357

Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357

■CHAPTER 11 Integrating Server-Side Reports . . . . . . . . . . . . . . . . . . . . . . . . . . 359

Remote Processing Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

How Server-Side Reporting Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360

Server-Side Reports with the Windows Forms Client . . . . . . . . . . . . . . . . 362

Creating a Windows Forms Project. . . . . . . . . . . . . . . . . . . . . . . . . . . 363

Adding the ReportViewer Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364

Setting Up the ReportViewer Properties. . . . . . . . . . . . . . . . . . . . . . . 365

Server-Side Reports, At Your Service. . . . . . . . . . . . . . . . . . . . . . . . . 367

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367

xiv ■CONTENTS

8547FMfinal.qxd 8/30/07 3:34 PM Page xiv

Tải ngay đi em, còn do dự, trời tối mất!