(eBook PDF) Fundamentals of C# Programming for Information Systems 2nd Edition - The ebook in PDF/DOCX format is ready for download now
(eBook PDF) Fundamentals of C# Programming for Information Systems 2nd Edition - The ebook in PDF/DOCX format is ready for download now
com
https://ebookluna.com/product/ebook-pdf-fundamentals-of-c-
programming-for-information-systems-2nd-edition/
OR CLICK HERE
DOWLOAD EBOOK
https://ebookluna.com/product/ebook-pdf-fundamentals-of-c-programming-
for-information-systems-2nd-edition-2/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-fundamentals-of-information-
systems-9th-edition/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-fundamentals-of-information-
systems-8th-edition/
ebookluna.com
https://ebookluna.com/download/fundamentals-of-information-systems-
ebook-pdf/
ebookluna.com
Essentials of MIS (Management Information Systems), 15th
Global Edition Kenneth C. Laudon - eBook PDF
https://ebookluna.com/download/essentials-of-mis-management-
information-systems-15th-global-edition-ebook-pdf/
ebookluna.com
https://ebookluna.com/download/essentials-of-mis-management-
information-systems-15th-global-edition-ebook-pdf-2/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-management-information-
systems-for-the-information-9th/
ebookluna.com
https://ebookluna.com/download/fundamentals-of-ecosystem-science-
ebook-pdf/
ebookluna.com
https://ebookluna.com/product/ebook-pdf-fundamentals-of-communication-
systems-global-edition-2nd-edition/
ebookluna.com
6.5 Getting User Input from Controls ................................................................................................... 183
6.6 Working with ComboBoxes............................................................................................................ 186
6.7 Working with ListBoxes ................................................................................................................. 196
6.8 Windows Presentation Foundation (WPF) ..................................................................................... 201
Exercises ............................................................................................................................................... 203
Chapter 7: Arrays ................................................................................................205
7.1 Introduction to One-Dimensional Arrays ....................................................................................... 205
Tutorial 1: Working with 1-D Arrays: Test Scores Application ........................................................... 208
7.2 Assigning a Value to an Element of an Array................................................................................. 211
7.3 Accessing Elements of an Array Using the Index .......................................................................... 212
7.4 Accessing Elements of an Array Using the foreach Loop .............................................................. 215
7.5 Copying an Array............................................................................................................................ 217
7.6 Looking Up Values in an Array ...................................................................................................... 221
Tutorial 2: Lookup Units Sold Using 1-D Arrays................................................................................. 222
Exercises ............................................................................................................................................... 224
Chapter 8: Sequential Files and Arrays.............................................................226
8.1 Introduction to Text Files................................................................................................................ 226
Tutorial 1: Reading Text Files .............................................................................................................. 229
8.2 Splitting a Row: Split Method ........................................................................................................ 231
8.3 Reading Data from Files into Arrays .............................................................................................. 234
8.4 Additional Methods of Arrays ........................................................................................................ 241
Tutorial 2: Looking Up Phone Numbers Using Arrays ........................................................................ 242
Tutorial 3: Using a ComboBox to Select the Search Name .................................................................. 246
8.5 Writing to Text Files ....................................................................................................................... 248
Tutorial 4: Writing Scores to Text File ................................................................................................. 248
8.6 SaveFileDialog Control .................................................................................................................. 255
8.7 Passing Arrays to Methods ............................................................................................................. 259
Tutorial 5: Passing Arrays to Compute Average .................................................................................. 259
8.8 Two-Dimensional (2-D) Arrays ...................................................................................................... 263
Tutorial 6: 2-D Array to Find the Sales for a Product........................................................................... 267
Exercises ............................................................................................................................................... 271
Rentals Assignment 2 ........................................................................................................................... 272
Help Desk Assignment 2 ...................................................................................................................... 274
Chapter 9: Collections .........................................................................................276
9.1 Introduction to Collections.............................................................................................................. 276
9.2 List<T> Collection .......................................................................................................................... 278
Tutorial 1: Looking Up Sales Data Using a List ................................................................................... 279
9.3 Dictionary<TKey, TValue> Collection .......................................................................................... 285
Tutorial 2: Dictionary with Product# as Key and Price as Value ......................................................... 287
Tutorial 3: Dictionary with Product# as Key and Sales Array as Value ............................................... 293
Exercises ............................................................................................................................................... 297
Chapter 10: Graphical User Interface: Additional Controls...........................298
10.1 ListView: Features ........................................................................................................................ 298
10.2 Adding Items to ListView ............................................................................................................. 299
Tutorial 1: Selecting a Show from a ListView ..................................................................................... 302
10.3 Accessing Data from a ListView .................................................................................................. 302
10.4 Forms with Tab Pages ................................................................................................................... 308
Tutorial 2: Multipage Form with TabControl ....................................................................................... 308
Exercises ............................................................................................................................................... 310
Chapter 11: Multi-form Applications and Menus ............................................312
11.1 Introduction ................................................................................................................................... 312
11.2 Accessing an Existing Form from Another................................................................................... 313
Tutorial 1: Multi-form Financial Planning Application ........................................................................ 315
11.3 Sharing a Method between Multiple Forms .................................................................................. 318
Tutorial 2: Sharing the LoadDictionary Method between Forms ......................................................... 319
11.4 Closing a Parent Form .................................................................................................................. 325
11.5 Menus............................................................................................................................................ 328
11.6 ToolStrips...................................................................................................................................... 332
Exercises ............................................................................................................................................... 334
Chapter 12: Databases .........................................................................................335
12.1 Introduction ................................................................................................................................... 336
12.2 Creating Database Objects ............................................................................................................ 336
Tutorial 1: Display Employee Records Using the Wizard .................................................................... 337
12.3 Displaying Data in a DataGridView ............................................................................................. 340
12.4 Accessing Data Items from a DataGridView ................................................................................ 346
12.5 Displaying Data in Details View .................................................................................................. 349
12.6 Finding the Record for a Selected Key ......................................................................................... 351
Tutorial 2: Find Employee Records Using the Wizard ......................................................................... 352
12.7 Selecting a Group of Records Using the Binding Source ............................................................. 356
12.8 Selecting Records Using the Table Adapter ................................................................................. 362
Tutorial 3: Parameter Query to Select Records..................................................................................... 363
12.9 Untyped Datasets: Displaying Records......................................................................................... 365
Tutorial 4: Display Records Using Untyped Datasets .......................................................................... 366
12.10 Untyped Datasets: Selecting Records ......................................................................................... 375
Tutorial 5: Select Records Using Untyped Datasets ............................................................................. 377
12.11 Untyped Datasets: Add/Edit/Delete Records .............................................................................. 384
Tutorial 6: Add/Edit/Delete Using Untyped Datasets........................................................................... 385
12.12 Command Object and DataReader .............................................................................................. 394
Tutorial 7: SqlCommand and SqlDataReader to Work with Tables ..................................................... 396
Exercises ............................................................................................................................................... 405
Rentals Assignment 3 ........................................................................................................................... 407
Help Desk Assignment 3 ...................................................................................................................... 407
Chapter 13: Object-Oriented Programming .....................................................414
13.1 Introduction to Objects and Classes .............................................................................................. 415
13.2 Classes versus Objects .................................................................................................................. 415
13.3 Information Hiding (Encapsulation) ............................................................................................. 417
Tutorial 1: Create an Employee Class................................................................................................... 419
13.4 Properties ...................................................................................................................................... 423
Tutorial 2: User Interface and Properties .............................................................................................. 426
13.5 Calling Methods (Sending Messages to Objects) ......................................................................... 434
Tutorial 3: Calling Methods and Passing Data between Forms ............................................................ 435
Exercises ............................................................................................................................................... 448
Chapter 14: Inheritance ......................................................................................450
14.1 Introduction to Inheritance ............................................................................................................ 451
14.2 Implementing Inheritance ............................................................................................................. 452
Tutorial 1: Creating Subclasses ............................................................................................................ 454
14.3 Using Subclasses and Super Classes............................................................................................. 458
14.4 Overriding Methods ...................................................................................................................... 459
Tutorial 2: Implementing the GrossPay Method................................................................................... 462
14.5 Polymorphism ............................................................................................................................... 467
Tutorial 3: Dynamic Dispatch and the ToString Method...................................................................... 468
14.6 Abstract Classes and Interfaces..................................................................................................... 472
Tutorial 4: Interfaces ............................................................................................................................. 473
14.7 Using Interfaces to Sort Collections ............................................................................................. 480
Tutorial 5: Sorting Employees .............................................................................................................. 483
14.8 Access Modifiers in C# ................................................................................................................. 486
Exercises ............................................................................................................................................... 488
Chapter 15: Introduction to Web Applications Development .........................491
15.1 Introduction to Web Applications ................................................................................................. 491
15.2 Creating a Single-Page ASP.NET Website................................................................................... 496
Tutorial 1: Developing a Simple Web Page: Ice Cream Cost ............................................................... 496
15.3 Introduction to HTML .................................................................................................................. 502
15.4 Working with Web Server Controls.............................................................................................. 506
15.5 Validating Data Using Validation Controls .................................................................................. 517
Exercises ............................................................................................................................................... 522
Chapter 16: Web Development: Multipage and Database Applications.......523
16.1 Accessing Databases from Web Forms ........................................................................................ 523
Tutorial 1: Accessing a Database: Theater Tickets Application ........................................................... 524
16.2 Preserving Data during Postbacks Using View State ................................................................... 538
16.3: Multipage Websites and Session State ........................................................................................ 543
16.4 Setting a Page to Its Previous State ............................................................................................... 551
Exercises ............................................................................................................................................... 557
Appendix A: Binary Files ....................................................................................559
A.1 Writing to Binary Files .................................................................................................................. 559
Tutorial: Working with Binary Files ..................................................................................................... 559
A.2 Reading Binary Files ...................................................................................................................... 560
Appendix B: Creating a Database ......................................................................562
Tutorial: Creating HR Database............................................................................................................ 562
Appendix C: Answers to Review Questions ......................................................564
Appendix D: HTML Elements ............................................................................584
Index ......................................................................................................................586
Preface
Mission of the Text
Welcome to Fundamentals of C# Programming for Information Systems. This book teaches the
fundamentals of programming in C# to provide a solid foundation to build business and other real-world
applications. Programming concepts are discussed in the context of familiar practical applications that use
graphical interfaces.
Target Audience
This book is designed for introductory programming courses in IS/MIS, CIS and IT. This book also
would fit into a computer science curriculum with an introductory course that uses a GUI-based
application-oriented approach to teach programming concepts. The breadth and depth of coverage makes
this book suitable for a two-course sequence, particularly when students come to the first course with no
programming background and a slower pace is desired. An approach in a two-course sequence would be
to do in-depth coverage of topics like collections, databases, object-oriented programming, web
development, and others presented in later chapters only in the second course.
Key Features
A key feature of the book is that programming concepts are introduced in small chunks through examples
and illustrations accompanied by hands-on tutorials. The tutorials, which are interspersed with the
concepts, help students apply and explore what they learn immediately. Additionally, review questions
and exercises within the chapters enhance student interest and learning.
Although the book is written for beginners, it is thorough and concise. Graphical illustrations and
screenshots are used throughout the book to enhance learning for both beginners and experienced
students.
Windows forms are used from the beginning to provide GUI-based as opposed to console-based interface.
This book builds graphical user interfaces and code in the .Net environment using Visual Studio. You are
encouraged to use the current free version, Visual Studio Community 2017. Earlier versions, including
Visual Studio 2015, Visual Studio Express and Visual Studio 2013, generally work well, except that you
won’t be able to run a few programs that use certain features available only in C# version 7.1 or greater.
ii
Supplements
For Students: Tutorial_Starts.zip file that contains
o Partially completed projects for tutorials
o Data files/databases used in projects
To install Visual Studio, open the downloaded .exe file and run it.
between collections and arrays, collections are presented in this book immediately following Chapter 8 on
arrays.
Chapter 10 discusses the application of ListView and TabControl. The dependency of this chapter on
Chapter 9 (“Collections”) is very low. The prerequisite for this chapter includes Chapters 6 and 8.
Chapter 11 presents multiform applications, Menus and ToolStrips. This chapter has some dependency on
previous chapters, except Chapter 10.
Chapter 12 provides in-depth coverage of accessing databases from C# programs. Chapter 6 is a
prerequisite for this chapter. In addition, the ListView control presented in Chapter 10 is used in an
example in the last part of this chapter, and it is required in the third comprehensive assignment
(Assignment 3) at the end of this chapter. Assignment 3 also requires the use of MainMenu control
discussed in Chapter 11. Other than that, the dependence of Chapter 12 on Chapters 7–11 is relatively
low.
Chapter 13 provides an introduction to object-oriented programming (OOP) principles and techniques.
The initial part of this chapter may be used for an introduction to OOP early in the semester.
Chapter 14 describes the concept of inheritance, implementation of inheritance, subclasses and super
classes, overriding methods and polymorphism. Chapter 13 is a prerequisite for this chapter, and it also
relies on collections from Chapter 9.
Chapter 15 presents the concepts of web applications development, and develops simple web applications
using the ASP.Net platform in the Visual Studio environment. Only the basic programming knowledge
presented in Chapters 1–3 is required for this chapter.
Chaper 16 describes how to access SQL Server databases and develop multipage web projects. Basic
programming concepts presented in Chapters 1–6, the concept of collections from Chapter 9, and basic
database concepts including binding controls to a database and filtering records (Chapter 12) are used in
building the application.
iv
Acknowledgments
I am thankful for the valuable assistance provided by many people in the preparation of this book. I wish
to thank Dr. Jakob Iversen, The University of Wisconsin–Oshkosh, for authoring Chapters 13 and 14 on
Object-Oriented Programming.
I was fortunate to work with Beth Lang Golub, editor and president of Prospect Press, who was flexible
and supportive of my goal to offer a good quality programming textbook at a reasonable price. Special
thanks go to Susan Hegedus, Kathy Bond Borie and Rachel Paul for their painstaking attention to detail in
editing this book, and to Annie Clark for the cover design.
I wish to acknowledge the contributions of the following reviewers for their valuable guidance in
improving the presentation and contents of this book:
Janet Bailey, University of Arkansas at Little Rock
Wei Kian Chen, Champlain College
Clinton Daniel, University of South Florida
Silvana Faja, University of Central Missouri
Joni L. Jones, University of South Florida
David Pumphrey, Colorado Mesa University
Manonita M. Ratwatte, University of Oklahoma (Retired)
Theadora Ross, University of Arkansas at Little Rock
David M. Weber, Northern Arizona University
Thanks are also due to the instructors who provided valuable feedback on the first edition of this book
through user surveys:
Janet Bailey, University of Arkansas, Little Rock
Jeff Dickson, Oregon Institute of Technology
Ruth Lamprecht, Virginia Union University
Panos Linos, Butler University
Ziping Liu, Southeast Missouri State University
Robert Pilgrim, Murray State University
Kris Rosenberg, Oregon Institute of Technology
Doug Titus, University of North Florida
Welcome to programming in C# language. In this chapter, you will learn to develop simple programs in
the Visual Studio development environment, and to work with different types of data.
Learning Objectives
After studying this chapter, you should be able to:
Identify the inputs, processes and outputs of a software system.
Describe the steps involved in developing a computer program.
Describe the terms: syntax, logic and runtime errors, machine language, low-level language, high-
level language, compiler and interpreter.
Develop a simple form in Visual Studio to accept user input, do calculations and display
formatted output.
Work with Label, TextBox, Button, ListBox and MessageBox.
Develop simple programs that use constants, variables and expressions.
Use try-catch method to catch errors.
Topics
Typically, a program uses one or more data items to produce some results. For example, a program that
processes an order might use the item number and order quantity to compute the subtotal, sales tax and
total cost, as represented in Figure 1-1.
Subtotal
Item# Process
Sales tax
Quantity Order
Total cost
The program, represented by the block “Process Order,” may include multiple subtasks like look up the
unit price, check inventory and compute results.
The data that are used by a program are called the input to the program, and the results produced are
called the output of the program. In addition to processing input data to produce the output, a program
might write data to and read data from storage devices like a flash drive or a hard drive, as represented in
Figure 1-2.
Here is an example of a simplified statement of the purpose of the order processing program:
Purpose: Compute and display the subtotal, sales tax and total cost for an order
The output of the program often follows from the purpose. For this example, the output would be
Output: subtotal, sales tax, total cost
The process specifies not only what the program should do (e.g., compute total cost) but also how it
should be done (e.g., how to compute total cost), as follows:
Process: (What?) Look up unit price, look up sales tax rate,
compute subtotal, sales tax and total cost
(How?) subtotal: unit price * order quantity
sales tax: subtotal * sales tax rate
total cost: subtotal + sales tax
Specifying the process also would include identifying the sources of data, like the product file to get the
unit price and sales tax file to get the sales tax rate.
The input specifies the data items that are needed to carry out the process to produce the output. The
input for this order-processing system would be
Input: item number, order quantity
Note that unit price and sales tax rate are not included in the input because the program looks them up. A
real-world system would be a lot more complex. Typically, the process would include additional subtasks
like handling orders when inventory is insufficient, and output may include various reports. In such
systems, graphical methods like Data Flow Diagrams and UML diagrams are used to represent the
processes and the data accessed by them.
Again, a real-world program may have to do additional subtasks, like checking the inventory to make sure
there is sufficient quantity on stock.
For relatively simpler programs, after identifying the subtasks, you may go directly to writing the
program for each subtask. However, for tasks involving more complex logic, it might help to develop an
outline of the logic of performing the subtasks. The representation of the logic of a program in plain
English is called pseudo code. You also may represent the logic graphically using a flowchart, as
discussed in Chapter 3.
source code, to another language before running a program, as described in the next section. So, your
first task is to make sure that there are no syntax errors. The good news is that Visual Studio provides a
lot of help in identifying syntax errors.
After the syntax errors are eliminated, the program may run. But, it’s still too early to celebrate because
the results could be incorrect due to errors in the program logic, just like you can write a grammatically
correct sentence that doesn’t convey the intended message. Errors that cause a program to produce
incorrect or unintended results are called logic errors. A tax-filing software using the wrong tax rate and
a billing software overcharging a customer are examples of logic errors.
There are errors other than logic errors that can occur at runtime. These are called runtime errors.
Runtime errors cause the program to crash (unless the program catches and handles such errors) because
the program asks the computer to do something it is unable to do, like accessing a file with an invalid path
or dividing a number by zero.
The process of identifying errors (bugs) is called debugging. Testing programs to identify and eliminate
errors is an extremely important part of developing software.
Review Questions
1.1 Consider Google as a software system. What would be the input, process and output for Google?
1.2 Consider a software system that enrolls students into classes. Identify some key inputs that the
system needs every time a student enrolls in a class, and the subtasks (process) that need to be
performed. What are some outputs the system should produce for students and instructors?
1.3 List the major steps in developing a program.
1.4 Incorrect punctuation in a program is an example of what type of error?
1.5 A payroll program uses the wrong formula to compute overtime pay. What type of error is it?
1.6 True or false: A program that doesn’t have any syntax errors should produce the correct results.
The products that support developing and running programs within the Visual Studio family include the
following:
1. An Integrated Development Environment (IDE)
An IDE provides an environment to develop programs, which includes code editors for Visual
C#, Visual Basic, Visual J#, Visual C++, HTML and XML, and designers for Windows forms
and web forms.
In Visual Studio, a software application typically is organized into Projects that may contain one
or more forms.
Forms provide the user interface that allows users to input data for the program, to interact with
the program and to display results.
2. A compiler that translates the source code into Microsoft Intermediate Language (MSIL)
FISTULI´NA Bull.
Fistula, a pipe.
5. Dædalea quercina.
6. Fomes igniarius. Reduced in size.
7. Trametes gibbosa.
POLY´PORUS Fr.
ANALYSIS OF TRIBES.
The pores being placed directly upon the wood or on the mycelium,
the pileus proper is absent.
I.—Me´sopus.
II.—Pleuropus.
P. squamo´sus Fr.—squama, a scale. (Plate CXXX, p. 480.) Pileus
3 in.-1½ ft. broad, somewhat ochraceous, variegated with a broad,
adpressed, spot-like, centrifugal, darker scales, fleshy-pliant, fan-
shaped, flattened. Stem excentric and lateral, obese, reticulated at
the apex, blackish at the base. Pores thin, variable (at first minute),
then large, angular and torn, pallid. Fries.
Handsome, commonly very large, somewhat central and umbilicate
when young, at length lateral, very variable in shape.
On trunks and stumps, chiefly ash. Common. May to November.
Stevenson.
Spores oval, white, 14×6µ W.G.S.; elliptical, colorless, 12×5µ
Massee.
Massachusetts, Sprague; Iowa, Macbride; New York. Trunk of elm.
May. Peck, 27th Rep.; West Virginia, New Jersey, Pennsylvania. On
fallen trunks and on stumps. May to November. McIlvaine.
This species does not seem to be common in America, but is found
throughout Europe. It varies in size from 3 in. to over 3 feet. It has
been known to attain the circumference of 7 ft. 5 in., and the weight
of 40 lbs. Dr. Badham says that it can not be masticated and that its
expressed juice is very disagreeable. The fact, however, remains that
it is eaten, and is recorded as edible by most authors. It is
undoubtedly tough, but cut fine and stewed slowly for half an hour it
is quite as tender as the muscle of an oyster and has a pleasant
flavor.
III.—Merisma.
Caldesiella.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookluna.com