0% found this document useful (0 votes)
7 views11 pages

Ailene

This document outlines the requirements for a group project creating a database application using C# and MS Access. It provides the code to connect the C# application to an Access database, perform CRUD operations, and includes code for buttons to create, delete, update and refresh database records. It also provides context that it is for a course at Cagayan State University in the Philippines.

Uploaded by

Ailene Recheta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views11 pages

Ailene

This document outlines the requirements for a group project creating a database application using C# and MS Access. It provides the code to connect the C# application to an Access database, perform CRUD operations, and includes code for buttons to create, delete, update and refresh database records. It also provides context that it is for a course at Cagayan State University in the Philippines.

Uploaded by

Ailene Recheta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Republic of the Philippines

CAGAYAN STATE UNIVERSITY


Maura, Aparri, Cagayan 3515
Aparri Campus

FINAL REQUIREMENTS
Bachelor of Science in Information Technology
2nd Semester, 2022-2023

Course Code : IT 121


Course Title : COMPUTER PROGRAMMING 2
Date :
Topic : C#.NET (VS) and DATABASE (MS ACCESS) CONNECTION
Student Name : GROUP MEMBERS

SYSTEM DESIGN

(07 8 ) 8 88 0 78 6
CSU is a university with global stature in the arts, culture, agriculture and fisheries, the CORE VALUES c su a p a rri@g m a il.c o m
sciences as well as technological and professional fields. a p a rri,c su .e d u .p h
Competence
Cagayan State University shall produce globally competent graduates through excellent Social Responsibility
instruction, innovative and creative research, responsive public service and productive Unifying Presence
industry and community engagement.
Republic of the Philippines
CAGAYAN STATE UNIVERSITY
Maura, Aparri, Cagayan 3515
Aparri Campus

SYSTEM DATABASE

SYSTEM CODE
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.OleDb;
using System.Windows.Forms;

namespace CRUD_REQUIREMENTS
{
public partial class Form1 : Form
{
private OleDbConnection connection = new OleDbConnection();
private OleDbDataAdapter adapter;
private DataTable dataTable;
public Form1()

(07 8 ) 8 88 0 78 6
CSU is a university with global stature in the arts, culture, agriculture and fisheries, the CORE VALUES c su a p a rri@g m a il.c o m
sciences as well as technological and professional fields. a p a rri,c su .e d u .p h
Competence
Cagayan State University shall produce globally competent graduates through excellent Social Responsibility
instruction, innovative and creative research, responsive public service and productive Unifying Presence
industry and community engagement.
Republic of the Philippines
CAGAYAN STATE UNIVERSITY
Maura, Aparri, Cagayan 3515
Aparri Campus

{
InitializeComponent();
connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=""C:\Users\Public\Ailene
Recheta\Recheta.accdb""";
Table();
}
private void Table()
{
connection.Open();
adapter = new OleDbDataAdapter("Select * From recordData", connection);
dataTable = new DataTable();
adapter.Fill(dataTable);
recordTable.DataSource = dataTable;
connection.Close();
}

private void btCreate_Click(object sender, EventArgs e)


{
connection.Open();
string add = "Insert Into recordData (Name1,Birthday,Gender,Address) Values (@name,@bday,@sex,@add)";
using(OleDbCommand comm = new OleDbCommand(add,connection))
{
comm.Parameters.AddWithValue("@name", tbName.Text);
comm.Parameters.AddWithValue("@bday", tbBirthday.Text);
comm.Parameters.AddWithValue("@sex", tbGender.Text);
comm.Parameters.AddWithValue("@add", tbAddress.Text);
comm.ExecuteNonQuery();
tbName.Text = "";
tbBirthday.Text = "";
tbGender.Text = "";
tbAddress.Text = "";
MessageBox.Show("Successfully Added", "System", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
connection.Close(); Table();
}

private void btDelete_Click(object sender, EventArgs e)


{
if (recordTable.SelectedRows.Count > 0)
{
int Select = recordTable.SelectedRows[0].Index;
DataRow add = dataTable.Rows[Select];
add.Delete();

OleDbCommandBuilder build = new OleDbCommandBuilder(adapter);


adapter.DeleteCommand = build.GetDeleteCommand();
adapter.Update(dataTable);
tbName.Text = "";
tbBirthday.Text = "";
tbGender.Text = "";
tbAddress.Text = "";
MessageBox.Show("Successfully Deleted", "System", MessageBoxButtons.OK, MessageBoxIcon.Information);

}
else
{
MessageBox.Show("Select a row to Delete", "System", MessageBoxButtons.OK, MessageBoxIcon.Stop);

}
}

private void btUpdate_Click(object sender, EventArgs e)


{
if (recordTable.SelectedRows.Count > 0)
{
int Select = recordTable.SelectedRows[0].Index;

(07 8 ) 8 88 0 78 6
CSU is a university with global stature in the arts, culture, agriculture and fisheries, the CORE VALUES c su a p a rri@g m a il.c o m
sciences as well as technological and professional fields. a p a rri,c su .e d u .p h
Competence
Cagayan State University shall produce globally competent graduates through excellent Social Responsibility
instruction, innovative and creative research, responsive public service and productive Unifying Presence
industry and community engagement.
Republic of the Philippines
CAGAYAN STATE UNIVERSITY
Maura, Aparri, Cagayan 3515
Aparri Campus

DataRow add = dataTable.Rows[Select];


add["Name1"] = tbName.Text;
add["Birthday"] = tbBirthday.Text;
add["Gender"] = tbGender.Text;
add["Address"] = tbAddress.Text;

OleDbCommandBuilder build = new OleDbCommandBuilder(adapter);


adapter.UpdateCommand = build.GetUpdateCommand();
adapter.Update(dataTable);
tbName.Text = "";
tbBirthday.Text = "";
tbGender.Text = "";
tbAddress.Text = "";
MessageBox.Show("Successfully Updated", "System", MessageBoxButtons.OK,
MessageBoxIcon.Information);

}
else
{
MessageBox.Show("Select a row to Update", "System", MessageBoxButtons.OK, MessageBoxIcon.Stop);

}
}

private void recordTable_Click(object sender, EventArgs e)


{
tbName.Text = recordTable.CurrentRow.Cells[1].Value.ToString();
tbBirthday.Text = recordTable.CurrentRow.Cells[2].Value.ToString();
tbGender.Text = recordTable.CurrentRow.Cells[3].Value.ToString();
tbAddress.Text = recordTable.CurrentRow.Cells[4].Value.ToString();
}

private void btRefresh_Click(object sender, EventArgs e)


{
Table();
tbName.Text = "";
tbBirthday.Text = "";
tbGender.Text = "";
tbAddress.Text = "";
}
}
}

(07 8 ) 8 88 0 78 6
CSU is a university with global stature in the arts, culture, agriculture and fisheries, the CORE VALUES c su a p a rri@g m a il.c o m
sciences as well as technological and professional fields. a p a rri,c su .e d u .p h
Competence
Cagayan State University shall produce globally competent graduates through excellent Social Responsibility
instruction, innovative and creative research, responsive public service and productive Unifying Presence
industry and community engagement.
Republic of the Philippines
CAGAYAN STATE UNIVERSITY
Maura, Aparri, Cagayan 3515
Aparri Campus

Codes of all Button

private void btRefresh_Click(object sender, EventArgs e)


{
Table();
tbName.Text = "";
tbBirthday.Text = "";
tbGender.Text = "";
tbAddress.Text = "";
}

(07 8 ) 8 88 0 78 6
CSU is a university with global stature in the arts, culture, agriculture and fisheries, the CORE VALUES c su a p a rri@g m a il.c o m
sciences as well as technological and professional fields. a p a rri,c su .e d u .p h
Competence
Cagayan State University shall produce globally competent graduates through excellent Social Responsibility
instruction, innovative and creative research, responsive public service and productive Unifying Presence
industry and community engagement.
Republic of the Philippines
CAGAYAN STATE UNIVERSITY
Maura, Aparri, Cagayan 3515
Aparri Campus

private void btCreate_Click(object sender, EventArgs e)


{
connection.Open();
string add = "Insert Into recordData (Name1,Birthday,Gender,Address) Values
(@name,@bday,@sex,@add)";
using(OleDbCommand comm = new OleDbCommand(add,connection))
{
comm.Parameters.AddWithValue("@name", tbName.Text);
comm.Parameters.AddWithValue("@bday", tbBirthday.Text);
comm.Parameters.AddWithValue("@sex", tbGender.Text);
comm.Parameters.AddWithValue("@add", tbAddress.Text);
comm.ExecuteNonQuery();
tbName.Text = "";
tbBirthday.Text = "";
tbGender.Text = "";
tbAddress.Text = "";
MessageBox.Show("Successfully Added", "System", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
connection.Close(); Table();
}

(07 8 ) 8 88 0 78 6
CSU is a university with global stature in the arts, culture, agriculture and fisheries, the CORE VALUES c su a p a rri@g m a il.c o m
sciences as well as technological and professional fields. a p a rri,c su .e d u .p h
Competence
Cagayan State University shall produce globally competent graduates through excellent Social Responsibility
instruction, innovative and creative research, responsive public service and productive Unifying Presence
industry and community engagement.
Republic of the Philippines
CAGAYAN STATE UNIVERSITY
Maura, Aparri, Cagayan 3515
Aparri Campus

private void btUpdate_Click(object sender, EventArgs e)


{
if (recordTable.SelectedRows.Count > 0)
{
int Select = recordTable.SelectedRows[0].Index;
DataRow add = dataTable.Rows[Select];
add["Name1"] = tbName.Text;
add["Birthday"] = tbBirthday.Text;
add["Gender"] = tbGender.Text;
add["Address"] = tbAddress.Text;

OleDbCommandBuilder build = new OleDbCommandBuilder(adapter);


adapter.UpdateCommand = build.GetUpdateCommand();
adapter.Update(dataTable);
tbName.Text = "";
tbBirthday.Text = "";
tbGender.Text = "";
tbAddress.Text = "";
MessageBox.Show("Successfully Updated", "System", MessageBoxButtons.OK,
MessageBoxIcon.Information);

}
else
{
MessageBox.Show("Select a row to Update", "System", MessageBoxButtons.OK,
MessageBoxIcon.Stop);

}
}

(07 8 ) 8 88 0 78 6
CSU is a university with global stature in the arts, culture, agriculture and fisheries, the CORE VALUES c su a p a rri@g m a il.c o m
sciences as well as technological and professional fields. a p a rri,c su .e d u .p h
Competence
Cagayan State University shall produce globally competent graduates through excellent Social Responsibility
instruction, innovative and creative research, responsive public service and productive Unifying Presence
industry and community engagement.
Republic of the Philippines
CAGAYAN STATE UNIVERSITY
Maura, Aparri, Cagayan 3515
Aparri Campus

private void btDelete_Click(object sender, EventArgs e)


{
if (recordTable.SelectedRows.Count > 0)
{
int Select = recordTable.SelectedRows[0].Index;
DataRow add = dataTable.Rows[Select];
add.Delete();

OleDbCommandBuilder build = new OleDbCommandBuilder(adapter);


adapter.DeleteCommand = build.GetDeleteCommand();
adapter.Update(dataTable);
tbName.Text = "";
tbBirthday.Text = "";
tbGender.Text = "";
tbAddress.Text = "";
MessageBox.Show("Successfully Deleted", "System", MessageBoxButtons.OK,
MessageBoxIcon.Information);

}
else
{
MessageBox.Show("Select a row to Delete", "System", MessageBoxButtons.OK,
MessageBoxIcon.Stop);

}
}

(07 8 ) 8 88 0 78 6
CSU is a university with global stature in the arts, culture, agriculture and fisheries, the CORE VALUES c su a p a rri@g m a il.c o m
sciences as well as technological and professional fields. a p a rri,c su .e d u .p h
Competence
Cagayan State University shall produce globally competent graduates through excellent Social Responsibility
instruction, innovative and creative research, responsive public service and productive Unifying Presence
industry and community engagement.
Republic of the Philippines
CAGAYAN STATE UNIVERSITY
Maura, Aparri, Cagayan 3515
Aparri Campus

private void recordTable_Click(object sender, EventArgs e)


{
tbName.Text = recordTable.CurrentRow.Cells[1].Value.ToString();
tbBirthday.Text = recordTable.CurrentRow.Cells[2].Value.ToString();
tbGender.Text = recordTable.CurrentRow.Cells[3].Value.ToString();
tbAddress.Text = recordTable.CurrentRow.Cells[4].Value.ToString();
}

(07 8 ) 8 88 0 78 6
CSU is a university with global stature in the arts, culture, agriculture and fisheries, the CORE VALUES c su a p a rri@g m a il.c o m
sciences as well as technological and professional fields. a p a rri,c su .e d u .p h
Competence
Cagayan State University shall produce globally competent graduates through excellent Social Responsibility
instruction, innovative and creative research, responsive public service and productive Unifying Presence
industry and community engagement.
Republic of the Philippines
CAGAYAN STATE UNIVERSITY
Maura, Aparri, Cagayan 3515
Aparri Campus

Description of the CRUD


System
In our system we create a simple CRUD Operation with a simple design where you
can ADD, DELETE, UPDATE, and tha Data you added will display in
DataGridView.

The “Delete” Button allows users to remove specific entries from the database.
Upon clicking the button, a confirmation Dialogbox appears to tell that the record
is deleted.

The “Update” button enables users to modify existing records within the database.
Once Clicked, it dialogBox show that tell you to select a row to update. A form
with pre-populated data appears, allowing users to make necessary changes before
saving the updated information

The”Create” Button allows users to add new entries to the database. Upon clicking
the button, a form with empty fields will not add, so you need to fill all the field.

(07 8 ) 8 88 0 78 6
CSU is a university with global stature in the arts, culture, agriculture and fisheries, the CORE VALUES c su a p a rri@g m a il.c o m
sciences as well as technological and professional fields. a p a rri,c su .e d u .p h
Competence
Cagayan State University shall produce globally competent graduates through excellent Social Responsibility
instruction, innovative and creative research, responsive public service and productive Unifying Presence
industry and community engagement.
Republic of the Philippines
CAGAYAN STATE UNIVERSITY
Maura, Aparri, Cagayan 3515
Aparri Campus

Submitted by:

AILENE RECHETA
Student, Bachelor of Science in Information Technology

NESLYN MECATE
Student, Bachelor of Science in Information Technology

ROBELYN VALENCIA
Student, Bachelor of Science in Information Technology

(07 8 ) 8 88 0 78 6
CSU is a university with global stature in the arts, culture, agriculture and fisheries, the CORE VALUES c su a p a rri@g m a il.c o m
sciences as well as technological and professional fields. a p a rri,c su .e d u .p h
Competence
Cagayan State University shall produce globally competent graduates through excellent Social Responsibility
instruction, innovative and creative research, responsive public service and productive Unifying Presence
industry and community engagement.

You might also like