Laboratory Manual
Course: Object-Oriented Programming (C#)
Topic: CRUD Operations with MySQL and C# WinForms
Week: [Insert Week Number]
Instructor: Martzel P. Baste
Preface
In this laboratory, students will create
...
Laboratory Manual
Course: Object-Oriented Programming (C#)
Topic: CRUD Operations with MySQL and C# WinForms
Week: [Insert Week Number]
Instructor: Martzel P. Baste
Preface
In this laboratory, students will create a Pet Management System in C# WinForms
integrated with MySQL. The project applies the CRUD model (Create, Read, Update, Delete),
which forms the foundation of database-driven applications.
Throughout this exercise, you will reinforce Object-Oriented Programming principles by
encapsulating database logic inside classes, abstracting complex operations into reusable
methods, and designing a separation between user interface and data logic.
Introduction / Background
Modern software applications often require interaction with databases to store and
manage information. In this laboratory, we will build a Pet Management System using
C# WinForms connected to a MySQL database.
This exercise demonstrates the CRUD paradigm—Create, Read, Update, Delete—
which is the foundation of database-driven applications.
Beyond coding, this lab reinforces Object-Oriented Programming principles such as:
• Encapsulation: Grouping database methods (dbConnection, displayRecords,
SQLManager) inside a Pet class to hide implementation details from the user
interface.
• Abstraction: Using simple method calls (p.displayRecords(...)) instead of
rewriting raw database logic in the form.
• Reusability: Methods in Pet.cs can be reused across multiple forms or projects.
• Separation of Concerns: Keeping the data access layer (Pet.cs) separate from
the presentation layer (Form UI).
Pre-Lab Setup
XAMPP – MYSQL Setup and Installation
1. Install MySQL https://www.apachefriends.org/download.html if you haven’t done it
yet. Choose whichever you want.
2. Once done, launch the XAMPP control panel and click Start (Apache and MySQL) in
the Actions column to activate the server.
3. You will notice that it changed both to “Stop” and it turned green.
CREATING DATABASE in PYHPMYADMIN
1. Click the “Admin” button either in Apache or MySQL.
a. If you choose “Admin” on Apache, you will be redirected to this. Then choose
“phpMyAdmin” to proceed to localhost (see item b)
[Show More]