C# -Windows Programming Database Programming Using ADO.
Net Assignments
Assignment 1:-
Title:-Create an application to manage Employee details and Department details and also perform search
operations based on Employee and department.
Description:-
Steps:
1. Create a database named EmpSearchDB and create the table as follows:-
Table Name: Department
Column Name DataType Constraints
PKDeptId int Yes
DeptName varchar(50) No
IsActive bit No
Table Name: EmpDetails
Column Name DataType Constraints
PKEmpId int Yes
FKDeptId Int Yes
EmpName varchar(50) No
EmpSalary varchar(50) No
IsActive bit No
2. Create a new form in Windows Application named [Link]
3. Drag and drop one DataGridView control to the form.
4. Add fields to the Datagridview.
5. To add fields right click on the datagridview ->Edit column->Add->Give Name, Heading and
DataPropertyName. DataPropertyName should be same as the database column.
Add all the fields required to display in datagridview-> click on ok
6. Design the form as follows
1
C# -Windows Programming Database Programming Using [Link] Assignments
Control Text Name Additional Properties
DataGridView dgDept
Button1 Edit btnEdit
Button2 Delete btnDelete
Label1 Dept Name lblDeptName
TextBox1 txtDeptName
Label2 IsActive lblIsActive
CheckBox ChkIsActive
Button3 Save btnSave
Button4 Update btnUpdate
Handle the click event of save button which is used to save the record in Department table.
Handle the click event of Edit, Update and Delete buttons.
Add a new form to the project named [Link].
Drag and drop one DataGridView control to the form.
2
C# -Windows Programming Database Programming Using [Link] Assignments
Add fields to the Datagridview.
To add fields right click on the datagridview ->Edit column->Add->Give Name, Heading and
DataPropertyName. DataPropertyName should be same as the database column.
Add all the fields required to display in datagridview-> click on ok
Design the form as follows
Handle the click event of the Save button, Edit, Update and Delete buttons
The click event of the search button to perform search operations
Add the new form to the project named [Link].
Handle the click event of manageEmployeeToolStripMenuItem.
Add the EmpDetails() constructor in that write code to opens the connection of select command
of DataAdapter referenced by 'da'.
Write a Bind() method to Datagridview with EmpDetails table.
In the btn_save_click() button write code to save the record.
Handle click event of Edit button and add the code for to get the row index of the selected row in
the data gridview and display the values.
Handle the click event btnupdate_click() and delete buttons and write code and use the
command parameters to update and delete form data grid view.
3
C# -Windows Programming Database Programming Using [Link] Assignments
In the page_Load() event write code to bind the department search combobox.
Bind the datatable to combobox.
And also code to get intellisence to textbox based on the letter typed.
Select the form Properties
IsMdiContainer: True
Text : EmpMDIParent
WindowState : Maximized
Name : EmpMDIParent
Drag and drop MenuStrip on to the form.
ToolStripMenu1 Properties
Name : manageEmployeeToolStripMenuItem
Text : Manage Employee ToolStripMenu2 Properties
Name : manageDepartmentToolStripMenuItem
Text : Manage Department
ToolStripMenu2 Properties
Name : manageDepartmentToolStripMenuItem
Text : Manage Department
Handle the event of manageEmployeeToolStripMenuItem_Click() event to allow only one form to
be opened even though the toolstrip is clicked many times.
And also raise the event of frmMngEmp_FormClosed() to close the form when the user closes
the form
To allow only one form to be opened even though the toolstrip is clicked many times.
To close the form when the user closes the form.
Now run the application.
Sample I/O:-
4
C# -Windows Programming Database Programming Using [Link] Assignments
5
C# -Windows Programming Database Programming Using [Link] Assignments
6
C# -Windows Programming Database Programming Using [Link] Assignments
7
C# -Windows Programming Database Programming Using [Link] Assignments