The objective of the Project Planner application is to facilitate project and employee management in an organization. It is a form-based Windows application that uses the TabControl for segregating the project management and employee management activities. The main form of the Project Planner application has two tabs: Employee and Project. Form1.cs [Design] The following figures show the Employee and Project tabs in the Design view: The Employee Tab in Design View A Minor Project 1: Project Planner Appendix
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
The objective of the Project Planner application is to facilitate project and employee management in an organization. It is a form-based Windows application that uses the TabControl for segregating the project management and employee management activities. The main form of the Project Planner application has two tabs: Employee and Project.
Form1.cs [Design]The following fi gures show the Employee and Project tabs in the Design view:
The Employee Tab in Design View
AMinor Project 1: Project Planner
Appendix
440 Programming in C#
The project tab in design view
Backend DatabaseAs shown in the above fi gures, the Project Planner application uses a number of fi elds for recording employee and project related information. Thus, a backend database must be created for recording this information. The Project Planner application uses Microsoft Access as the backend database. The following fi gures show a snapshot of tables, Table 1 and Table 2, created in MS Access for storing Employee and Project related information:
Linking Data SourcesAs we can see in the Design view, both Employee and Project tabs use the DataGridView control for displaying the records submitted by the user. To populate the DataGridView from a backend data source, it must be linked with the corresponding data source. The following are the steps for linking DataGridView control with a data source: 1. Select the DataGridView control and open the DataGridView Tasks pane, as shown below: 2. Select the Add Project Data Source option from Choose Data Source list to initiate the Data
Source Confi guration Wizard, as shown below: 3. Select the Database option and click Next to display the Choose Your Data Connection
screen, as shown below: 4. Click the New Connection button to display the Add Connection dialog box, as shown
below:
Appendix A: Minor Project 1: Project Planner 441
MS access tables
DataGridView tasks pane
442 Programming in C#
The Data source confi guration wizard
The choose Your Data connection screen
Appendix A: Minor Project 1: Project Planner 443
The add Connection Dialog Box
5. Select the Microsoft Access Database File (OLE DB) option in the Data Source fi eld, enter the location of the backend MS Access fi le in the Database fi le name text box and click OK. A message box appears confi rming the successful data source connection, as shown below:
Microsoft Visual Studio Message Box
6. Click Next to display the Save the Connection String to the Application Confi guration fi le screen, as shown below:
444 Programming in C#
The Save the Connection String to the Application Confi guration fi le screen
7. Click Next to display the Choose Your Database Objects screen, as shown below:
The Choose Your Database Objects Screen
Appendix A: Minor Project 1: Project Planner 445
8. Select the table and the corresponding columns that you want to display in the DataGridView and click Finish to link the selected data source with the DataGridView control.
Form1.cs Code FileThe following is the source code contained in the Form1.cs fi le:
OleDbDataAdapter DA = new OleDbDataAdapter(query, connection); OleDbCommandBuilder CMD = new OleDbCommandBuilder(DA); DA.Update(dBDataSet.Table1); this.dBDataSet.Table1.Clear();
Adding INSERT QueryThe above code uses the Update method for posting records into the database. Thus, an appropriate SQL Insert query is required to be created, as shown in the following steps: 1. Open the DBDataSet.xsd fi le and select Data → Add → Query to initiate the TableAdapter
Query Confi guration Wizard, as shown below: 2. Click Next to display the Choose a Command Type screen, as shown below: 3. Click Next to display the Choose a Query Type screen, as shown below: 4. Select the INSERT option and click Next. The SQL INSERT query will automatically get
created. Click Finish to close the TableAdapter Query Confi guration Wizard.This completes the development of the Project Planner application.
Running the Project Planner ApplicationThe following fi gures show the output of the Project Planner application and how it is used for employee and project management: