0% found this document useful (0 votes)
60 views24 pages

Practical Prelim Examination

The document describes a form called frmEmployeeInfo that contains controls for entering employee personal data. It includes labels, textboxes, combo boxes, buttons, a picture box, and tab control for inputting an employee's name, address, contact details, date of birth, marital status, employment history, and photo. The form is connected to a MySQL database table called tblpersonaldata to save, retrieve, and update employee records.
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)
60 views24 pages

Practical Prelim Examination

The document describes a form called frmEmployeeInfo that contains controls for entering employee personal data. It includes labels, textboxes, combo boxes, buttons, a picture box, and tab control for inputting an employee's name, address, contact details, date of birth, marital status, employment history, and photo. The form is connected to a MySQL database table called tblpersonaldata to save, retrieve, and update employee records.
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/ 24

PRACTICAL PRELIM EXAMINATION

Prelim Examination in:


o ITPT 314 – IT Elective – Desktop Application Development
o ITPC 311 – Advanced Database Management System

NAME: Jenny Rose J. Bautista


YEAR & COURSE: 3rd Year Bachelor of Science in Information Technology

DESIGNER REPORT
frmEmployeeInfo: Personal Data Tab

FORM SPECIFICATIONS
Control Type Control Name Control Text or Output Remarks
Label  label1  Employee No.
 label2  Employee Name
 label3  Last Name
 label4  First Name
 label5  Middle Name
 label6  Present Address
 label7  Permanent Address
 label8  Contact No.
 label9  Date of Birth
 label10  Age
 label11  Sex
 label12  Civil Status
 label13  If Married
 label14  Name of Spouse
 label15  No. of Children
 label16  Blood Type
 label17  Height
 label18  Weight
 label19  Religion
 label20  Citizenship
 label21  Date Hired
 label22  Position
 label23  Salary Grade
TextBox  textBox1  Employee No. Required
 textBox2  Last Name
 textBox3  First Name
 textBox4  Middle Name
 textBox5  Present Address
 textBox6  Permanent Address
 textBox7  Contact No.
 textBox8  Date of Birth
 textBox9  Age
 textBox10  Name of Spouse
 textBox11  No. of Children
 textBox12  Height
 textBox13  Weight
 textBox14  Religion
 textBox15  Citizenship
 textBox16  Date Hired
 textBox17  Position
 textBox18  Salary Grade
ComboBox  comboBox1  Sex Required
 comboBox2  Civil Status
 comboBox3  Blood Type
Button  button1  Browse Photo Required
 button2  New
 button3  Save
 button4  Update
 button5  Search
 button15  Exit
 button18  Delete
PictureBox  pictureBox1  Employee Image Required
TabControl  tabControl1 Required
TabPage  tabPage1  Personal Data Required
 tabPage2  Educational
 tabPage3 Background
 Document
Requirements
DataGrid  dataGridView1  Data from MySQL Required
tblpersonaldata

PROGRAMMERS’ REPORT
frmEmployeeInfo: Personal Data Tab

Codes for frmEmployeeInfo_Load:


private void frmEmployeeInfo_Load(object sender, EventArgs e)
{
comboBox1.Items.Add("Female");
comboBox1.Items.Add("Male");
comboBox2.Items.Add("Single");
comboBox2.Items.Add("Married");
comboBox2.Items.Add("Engaged");
comboBox2.Items.Add("Widowed");
comboBox2.Items.Add("Divorced");
comboBox2.Items.Add("Annulled");
comboBox3.Items.Add("O-");
comboBox3.Items.Add("O+");
comboBox3.Items.Add("A-");
comboBox3.Items.Add("A+");
comboBox3.Items.Add("B-");
comboBox3.Items.Add("B+");
comboBox3.Items.Add("AB-");
comboBox3.Items.Add("AB+");
comboBox4.Items.Add("Elementary or Primary School");
comboBox4.Items.Add("Junior High School");
comboBox4.Items.Add("Senior High School");
comboBox4.Items.Add("College");
comboBox4.Items.Add("Graduate School");

DisplayRecord1();
DisplayRecord2();
DisplayRecord3();
}

Codes for button1 (Browse Photo):


private void button1_Click(object sender, EventArgs e)
{
try
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "Choose Image(*.JPG;*.PNG;*.GIF)|*.jpg;*.png;*.gif";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

Codes for button2 (New):


private void button2_Click_1(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
textBox6.Clear();
textBox7.Clear();
textBox8.Clear();
textBox9.Clear();
textBox10.Clear();
textBox11.Clear();
textBox12.Clear();
textBox13.Clear();
textBox14.Clear();
textBox15.Clear();
textBox16.Clear();
textBox17.Clear();
textBox18.Clear();
comboBox1.Text = "";
comboBox2.Text = "";
comboBox3.Text = "";

pictureBox1.Image = System.Drawing.Image.FromFile(Application.StartupPath + "\\profile.png");


}

Codes for button3 (Save):


private void button3_Click(object sender, EventArgs e)
{
try
{
MemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat);
byte[] ImageData = ms.ToArray();

MySqlCommand command = new MySqlCommand("INSERT INTO tblpersonaldata(EmpNo, LastName,


FirstName, MiddleName, PresentAddress, PermanentAddress, ContactNo, DOB, Age, Sex, CivilStatus,
SpouseName, NoOfChildren, BloodType, Height, Weight, Religion, Citizenship, DateHired, Position,
SalaryGrade, EmployeeImage)" +
"VALUES (@EmpNo, @LName, @FName, @MName, @PresAdd, @PermAdd, @Contact,
@Bday, @Age, @Sex, @CStatus, @SName, @NumChildren, @BType, @Height, @Weight, @Religion,
@Citizenship, @DateHired, @Position, @SGrade, @EmpImage)", conn);

command.Parameters.Add("@EmpNo", MySqlDbType.VarChar).Value = textBox1.Text;


command.Parameters.Add("@LName", MySqlDbType.VarChar).Value = textBox2.Text;
command.Parameters.Add("@FName", MySqlDbType.VarChar).Value = textBox3.Text;
command.Parameters.Add("@MName", MySqlDbType.VarChar).Value = textBox4.Text;
command.Parameters.Add("@PresAdd", MySqlDbType.VarChar).Value = textBox5.Text;
command.Parameters.Add("@PermAdd", MySqlDbType.VarChar).Value = textBox6.Text;
command.Parameters.Add("@Contact", MySqlDbType.VarChar).Value = textBox7.Text;
command.Parameters.Add("@Bday", MySqlDbType.VarChar).Value = textBox8.Text;
command.Parameters.Add("@Age", MySqlDbType.VarChar).Value = textBox9.Text;
command.Parameters.Add("@Sex", MySqlDbType.VarChar).Value = comboBox1.Text;
command.Parameters.Add("@CStatus", MySqlDbType.VarChar).Value = comboBox2.Text;
command.Parameters.Add("@SName", MySqlDbType.VarChar).Value = textBox10.Text;
command.Parameters.Add("@NumChildren", MySqlDbType.VarChar).Value = textBox11.Text;
command.Parameters.Add("@BType", MySqlDbType.VarChar).Value = comboBox3.Text;
command.Parameters.Add("@Height", MySqlDbType.VarChar).Value = textBox12.Text;
command.Parameters.Add("@Weight", MySqlDbType.VarChar).Value = textBox13.Text;
command.Parameters.Add("@Religion", MySqlDbType.VarChar).Value = textBox14.Text;
command.Parameters.Add("@Citizenship", MySqlDbType.VarChar).Value = textBox15.Text;
command.Parameters.Add("@DateHired", MySqlDbType.VarChar).Value = textBox16.Text;
command.Parameters.Add("@Position", MySqlDbType.VarChar).Value = textBox17.Text;
command.Parameters.Add("@SGrade", MySqlDbType.VarChar).Value = textBox18.Text;
command.Parameters.Add("@EmpImage", MySqlDbType.LongBlob).Value = ImageData;
conn.Open();
int RowData = command.ExecuteNonQuery();
if (RowData > 0)
{
MessageBox.Show("Record Saved Sucessfully!");
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
textBox6.Clear();
textBox7.Clear();
textBox8.Clear();
textBox9.Clear();
textBox10.Clear();
textBox11.Clear();
textBox12.Clear();
textBox13.Clear();
textBox14.Clear();
textBox15.Clear();
textBox16.Clear();
textBox17.Clear();
textBox18.Clear();
comboBox1.Text = "";
comboBox2.Text = "";
comboBox3.Text = "";

pictureBox1.Image = System.Drawing.Image.FromFile(Application.StartupPath + "\\profile.png");


}
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
}

Codes for button4 (Update):


private void button4_Click(object sender, EventArgs e)
{
try
{
MemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat);
byte[] ImageData = ms.ToArray();

MySqlCommand command = new MySqlCommand("UPDATE tblpersonaldata SET


LastName=@LName," +
" FirstName=@FName, " +
" MiddleName=@MName, " +
" PresentAddress=@PresAdd, " +
" PermanentAddress=@PermAdd, " +
" ContactNo=@Contact, " +
" DOB=@Bday, " +
" Age=@Age, " +
" Sex=@Sex, " +
" CivilStatus=@CStatus, " +
" SpouseName=@SName, " +
" NoOfChildren=@NumChildren, " +
" BloodType=@BType, " +
" Height=@Height, " +
" Weight=@Weight, " +
" Religion=@Religion, " +
" Citizenship=@citizenship, " +
" DateHired=@DateHired, " +
" Position=@Position, " +
" SalaryGrade=@SGrade, " +
" EmployeeImage=@EmpImage WHERE EmpNo = '" + textBox1.Text
+ "'", conn);

command.Parameters.Add("@LName", MySqlDbType.VarChar).Value = textBox2.Text;


command.Parameters.Add("@FName", MySqlDbType.VarChar).Value = textBox3.Text;
command.Parameters.Add("@MName", MySqlDbType.VarChar).Value = textBox4.Text;
command.Parameters.Add("@PresAdd", MySqlDbType.VarChar).Value = textBox5.Text;
command.Parameters.Add("@PermAdd", MySqlDbType.VarChar).Value = textBox6.Text;
command.Parameters.Add("@Contact", MySqlDbType.VarChar).Value = textBox7.Text;
command.Parameters.Add("@Bday", MySqlDbType.VarChar).Value = textBox8.Text;
command.Parameters.Add("@Age", MySqlDbType.VarChar).Value = textBox9.Text;
command.Parameters.Add("@Sex", MySqlDbType.VarChar).Value = comboBox1.Text;
command.Parameters.Add("@CStatus", MySqlDbType.VarChar).Value = comboBox2.Text;
command.Parameters.Add("@SName", MySqlDbType.VarChar).Value = textBox10.Text;
command.Parameters.Add("@NumChildren", MySqlDbType.VarChar).Value = textBox11.Text;
command.Parameters.Add("@BType", MySqlDbType.VarChar).Value = comboBox3.Text;
command.Parameters.Add("@Height", MySqlDbType.VarChar).Value = textBox12.Text;
command.Parameters.Add("@Weight", MySqlDbType.VarChar).Value = textBox13.Text;
command.Parameters.Add("@Religion", MySqlDbType.VarChar).Value = textBox14.Text;
command.Parameters.Add("@Citizenship", MySqlDbType.VarChar).Value = textBox15.Text;
command.Parameters.Add("@DateHired", MySqlDbType.VarChar).Value = textBox16.Text;
command.Parameters.Add("@Position", MySqlDbType.VarChar).Value = textBox17.Text;
command.Parameters.Add("@SGrade", MySqlDbType.VarChar).Value = textBox18.Text;
command.Parameters.Add("@EmpImage", MySqlDbType.LongBlob).Value = ImageData;
conn.Open();
int RowData = command.ExecuteNonQuery();
if (RowData > 0)
{
MessageBox.Show("Record Updated Sucessfully!");
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
textBox6.Clear();
textBox7.Clear();
textBox8.Clear();
textBox9.Clear();
textBox10.Clear();
textBox11.Clear();
textBox12.Clear();
textBox13.Clear();
textBox14.Clear();
textBox15.Clear();
textBox16.Clear();
textBox17.Clear();
textBox18.Clear();
comboBox1.Text = "";
comboBox2.Text = "";
comboBox3.Text = "";

pictureBox1.Image = System.Drawing.Image.FromFile(Application.StartupPath + "\\profile.png");


}
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
}

Codes for button5 (Search):


private void button5_Click(object sender, EventArgs e)
{
string qrySearch = "SELECT *FROM tblpersonaldata WHERE EmpNo = '" + this.textBox1.Text + "'";
MySqlCommand MySearch = new MySqlCommand(qrySearch, conn);
MySqlDataReader MyReadRecord;
conn.Open();
MyReadRecord = MySearch.ExecuteReader();

if (MyReadRecord.Read())
{
this.textBox1.Text = MyReadRecord["EmpNo"].ToString();
this.textBox2.Text = MyReadRecord["LastName"].ToString();
this.textBox3.Text = MyReadRecord["FirstName"].ToString();
this.textBox4.Text = MyReadRecord["MiddleName"].ToString();
this.textBox5.Text = MyReadRecord["PresentAddress"].ToString();
this.textBox6.Text = MyReadRecord["PermanentAddress"].ToString();
this.textBox7.Text = MyReadRecord["ContactNo"].ToString();
this.textBox8.Text = MyReadRecord["DOB"].ToString();
this.textBox9.Text = MyReadRecord["Age"].ToString();
this.textBox10.Text = MyReadRecord["SpouseName"].ToString();
this.textBox11.Text = MyReadRecord["NoOfChildren"].ToString();
this.textBox12.Text = MyReadRecord["Height"].ToString();
this.textBox13.Text = MyReadRecord["Weight"].ToString();
this.textBox14.Text = MyReadRecord["Religion"].ToString();
this.textBox15.Text = MyReadRecord["Citizenship"].ToString();
this.textBox16.Text = MyReadRecord["DateHired"].ToString();
this.textBox17.Text = MyReadRecord["Position"].ToString();
this.textBox18.Text = MyReadRecord["SalaryGrade"].ToString();
this.comboBox1.Text = MyReadRecord["Sex"].ToString();
this.comboBox2.Text = MyReadRecord["CivilStatus"].ToString();
this.comboBox3.Text = MyReadRecord["BloodType"].ToString();

byte[] arrImage = ((byte[])MyReadRecord["EmployeeImage"]);


if (arrImage == null)
{
pictureBox1.Image = null;
}
else
{
MemoryStream ms = new MemoryStream(arrImage);
ms.Seek(0, SeekOrigin.Begin);
pictureBox1.Image = Image.FromStream(ms);
}
}
else
{
pictureBox1.Image = null;
}
conn.Close();
}

Codes for button15 (Exit):


private void button15_Click(object sender, EventArgs e)
{
Close();
}

Codes for button18 (Delete [record]):


private void button18_Click(object sender, EventArgs e)
{
try
{
MySqlCommand command = new MySqlCommand("DELETE FROM tblpersonaldata WHERE EmpNo =
@EmpNo", conn);
command.Parameters.Add("@EmpNo", MySqlDbType.VarChar).Value = textBox1.Text;
conn.Open();
int RowData = command.ExecuteNonQuery();
if (RowData > 0)
{
MessageBox.Show("Record Deleted Successfully!");
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
textBox6.Clear();
textBox7.Clear();
textBox8.Clear();
textBox9.Clear();
textBox10.Clear();
textBox11.Clear();
textBox12.Clear();
textBox13.Clear();
textBox14.Clear();
textBox15.Clear();
textBox16.Clear();
textBox17.Clear();
textBox18.Clear();
comboBox1.Text = "";
comboBox2.Text = "";
comboBox3.Text = "";

pictureBox1.Image = System.Drawing.Image.FromFile(Application.StartupPath + "\\profile.png");

DisplayRecord1();
}
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
}

Additional Codes to show data in DataGridView1 (DisplayRecord1):


public void DisplayRecord1()
{
string qryDisplay = "SELECT EmpNo, LastName, FirstName, MiddleName, PresentAddress,
PermanentAddress, ContactNo, DOB, Age, Sex, CivilStatus, SpouseName, NoOfChildren, BloodType, Height,
Weight, Religion, Citizenship, DateHired, Position, SalaryGrade, EmployeeImage FROM tblpersonaldata ORDER
By LastName ASC";
MySqlCommand MyDisplay = new MySqlCommand(qryDisplay, conn);

MySqlDataAdapter DisplayAdapter = new MySqlDataAdapter();


DisplayAdapter.SelectCommand = MyDisplay;
DataTable dTable = new DataTable();
DisplayAdapter.Fill(dTable);

dataGridView1.RowTemplate.Height = 60;
dataGridView1.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders);

dataGridView1.DataSource = dTable;

DataGridViewImageColumn imgCol = new DataGridViewImageColumn();


imgCol = (DataGridViewImageColumn)dataGridView1.Columns[21];
imgCol.ImageLayout = DataGridViewImageCellLayout.Stretch;
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

dataGridView1.Font = new Font("Tahoma", 8);


dataGridView1.ReadOnly = true;
dataGridView1.MultiSelect = false;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.ShowRowErrors = false;
dataGridView1.ShowCellErrors = false;
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToResizeColumns = false;
dataGridView1.AllowUserToResizeRows = false;
dataGridView1.RowHeadersVisible = false;
dataGridView1.DefaultCellStyle.SelectionBackColor = Color.LightSeaGreen;
dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LightCyan;
}

DESIGNER REPORT
frmEmployeeInfo: Educational Background Tab

FORM SPECIFICATIONS
Control Type Control Name Control Text Remarks
Label  Label24  Employee No.
 label25  Educational Level
 label26  School Name
 label27  School Address
 label28  Course
 label29  Year Graduated
TextBox  textBox19  Employee No. Required
 textBox20  School Name
 textBox21  School Address
 textBox22  Course
 textBox23  Year Graduated
ComboBox  comboBox4  Educational Level Required
Button  button1  Browse Photo Required
 button6  New
 button7  Save
 button8  Update
 button9  Search
 button15  Exit
PictureBox  pictureBox1  Employee Image Required
TabControl  tabControl1 Required
TabPage  tabPage1  Personal Data Required
 tabPage2  Educational
 tabPage3 Background
 Document
Requirements
DataGrid  dataGridView2  Data from MySQL Required
tbleducationalbg

PROGRAMMERS’ REPORT
frmEmployeeInfo: Educational Background Tab

Codes for button6 (New):


private void button6_Click(object sender, EventArgs e)
{
textBox19.Clear();
textBox20.Clear();
textBox21.Clear();
textBox22.Clear();
textBox23.Clear();
comboBox4.Text = "";
}
Codes for button7 (Save):
private void button7_Click(object sender, EventArgs e)
{
try
{
MySqlCommand command = new MySqlCommand("INSERT INTO tbleducationalbg(EmployeeNo,
EducationalLevel, SchoolName, SchoolAddress, Course, YearGraduated)" +
"VALUES (@EmpNo, @EducLevel, @SName, @SAdd, @Course, @YGrad)", conn);

command.Parameters.Add("@EmpNo", MySqlDbType.VarChar).Value = textBox19.Text;


command.Parameters.Add("@EducLevel", MySqlDbType.VarChar).Value = comboBox4.Text;
command.Parameters.Add("@SName", MySqlDbType.VarChar).Value = textBox20.Text;
command.Parameters.Add("@SAdd", MySqlDbType.VarChar).Value = textBox21.Text;
command.Parameters.Add("@Course", MySqlDbType.VarChar).Value = textBox22.Text;
command.Parameters.Add("@YGrad", MySqlDbType.VarChar).Value = textBox23.Text;
conn.Open();
int RowData = command.ExecuteNonQuery();
if (RowData > 0)
{
MessageBox.Show("Record Saved Sucessfully!");
textBox19.Clear();
textBox20.Clear();
textBox21.Clear();
textBox22.Clear();
textBox23.Clear();
comboBox4.Text = "";
}
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
}

Codes for button8 (Update):


private void button8_Click(object sender, EventArgs e)
{
try
{
MySqlCommand command = new MySqlCommand("UPDATE tbleducationalbg SET
EducationalLevel=@EducLevel," +
" SchoolName=@SName, " +
" SchoolAddress=@SAdd, " +
" Course=@Course, " +
" YearGraduated=@YGrad WHERE EmployeeNo = '" +
textBox19.Text + "'", conn);

command.Parameters.Add("@EducLevel", MySqlDbType.VarChar).Value = comboBox4.Text;


command.Parameters.Add("@SName", MySqlDbType.VarChar).Value = textBox20.Text;
command.Parameters.Add("@SAdd", MySqlDbType.VarChar).Value = textBox21.Text;
command.Parameters.Add("@Course", MySqlDbType.VarChar).Value = textBox22.Text;
command.Parameters.Add("@YGrad", MySqlDbType.VarChar).Value = textBox23.Text;
conn.Open();
int RowData = command.ExecuteNonQuery();
if (RowData > 0)
{
MessageBox.Show("Record Updated Sucessfully!");
textBox19.Clear();
textBox20.Clear();
textBox21.Clear();
textBox22.Clear();
textBox23.Clear();
comboBox4.Text = "";
}
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
}

Codes for button9 (Search):


private void button9_Click(object sender, EventArgs e)
{
string qrySearch = "SELECT *FROM tbleducationalbg WHERE EmployeeNo = '" + this.textBox19.Text +
"'";
MySqlCommand MySearch = new MySqlCommand(qrySearch, conn);
MySqlDataReader MyReadRecord;
conn.Open();
MyReadRecord = MySearch.ExecuteReader();
while (MyReadRecord.Read())
{
this.textBox19.Text = MyReadRecord["EmployeeNo"].ToString();
this.comboBox4.Text = MyReadRecord["EducationalLevel"].ToString();
this.textBox20.Text = MyReadRecord["SchoolName"].ToString();
this.textBox21.Text = MyReadRecord["SchoolAddress"].ToString();
this.textBox22.Text = MyReadRecord["Course"].ToString();
this.textBox23.Text = MyReadRecord["YearGraduated"].ToString();
}
conn.Close();
}

Codes for button15 (Exit):


private void button15_Click(object sender, EventArgs e)
{
Close();
}

Codes for button19 (Delete [record]):


private void button19_Click(object sender, EventArgs e)
{
try
{
MySqlCommand command = new MySqlCommand("DELETE FROM tbleducationalbg WHERE
EmployeeNo = @EmpNo", conn);
command.Parameters.Add("@EmpNo", MySqlDbType.VarChar).Value = textBox19.Text;
conn.Open();
int RowData = command.ExecuteNonQuery();
if (RowData > 0)
{
MessageBox.Show("Record Deleted Successfully!");
textBox19.Clear();
textBox20.Clear();
textBox21.Clear();
textBox22.Clear();
textBox23.Clear();
comboBox4.Text = "";
DisplayRecord2();
}
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
}

Additional Codes to show data in DataGridView2 (DisplayRecord2):


public void DisplayRecord2()
{
string qryDisplay = "SELECT EmployeeNo, EducationalLevel, SchoolName, SchoolAddress, Course,
YearGraduated FROM tbleducationalbg ORDER By SchoolName ASC";
MySqlCommand MyDisplay = new MySqlCommand(qryDisplay, conn);

MySqlDataAdapter DisplayAdapter = new MySqlDataAdapter();


DisplayAdapter.SelectCommand = MyDisplay;
DataTable dTable = new DataTable();
DisplayAdapter.Fill(dTable);

dataGridView2.RowTemplate.Height = 60;
dataGridView2.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders);

dataGridView2.DataSource = dTable;

dataGridView2.Font = new Font("Tahoma", 8);


dataGridView2.ReadOnly = true;
dataGridView2.MultiSelect = false;
dataGridView2.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView2.ShowRowErrors = false;
dataGridView2.ShowCellErrors = false;
dataGridView2.AllowUserToAddRows = false;
dataGridView2.AllowUserToResizeColumns = false;
dataGridView2.AllowUserToResizeRows = false;
dataGridView2.RowHeadersVisible = false;
dataGridView2.DefaultCellStyle.SelectionBackColor = Color.LightSeaGreen;
dataGridView2.AlternatingRowsDefaultCellStyle.BackColor = Color.LightCyan;
}

DESIGNER REPORT
frmEmployeeInfo: Document Requirements Tab

FORM SPECIFICATION
Control Type Control Name Control Text Remarks
Label  label30  Employee No.
 label31  Credential ID
TextBox  textBox24  Employee No. Required
 textBox25  Credential ID
Button  button1  Browse Photo Required
 button10  Upload Credential Image
 button11  New
 button12  Save
 button13  Update
 button14  Search
 button15  Exit
PictureBox  pictureBox2  Credential Image Required
TabControl  tabControl1 Required
TabPage  tabPage1  Personal Data Required
 tabPage2  Educational Background
 tabPage3  Document Requirements
DataGrid  dataGridView3  Data from MySQL Required
tblcredentials

PROGRAMMERS’ REPORT
frmEmployeeInfo: Document Requirements Tab

Codes for button10 (Upload Credential Image):


private void button10_Click(object sender, EventArgs e)
{
try
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "Choose Image(*.JPG;*.PNG;*.GIF)|*.jpg;*.png;*.gif";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox2.Image = Image.FromFile(openFileDialog1.FileName);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Codes for button11 (New):
private void button11_Click(object sender, EventArgs e)
{
textBox24.Clear();
textBox25.Clear();

pictureBox2.Image = System.Drawing.Image.FromFile(Application.StartupPath + "\\documents.png");


}
Codes for button12 (Save):
private void button12_Click(object sender, EventArgs e)
{
try
{
MemoryStream ms = new MemoryStream();
pictureBox2.Image.Save(ms, pictureBox2.Image.RawFormat);
byte[] ImageData2 = ms.ToArray();

MySqlCommand command = new MySqlCommand("INSERT INTO tblcredentials(EmployeeNo,


CredentialID, CredentialImage)" +
"VALUES (@EmpNo, @CredID, @CredImage)", conn);

command.Parameters.Add("@EmpNo", MySqlDbType.VarChar).Value = textBox24.Text;


command.Parameters.Add("@CredID", MySqlDbType.VarChar).Value = textBox25.Text;
command.Parameters.Add("@CredImage", MySqlDbType.LongBlob).Value = ImageData2;
conn.Open();
int RowData = command.ExecuteNonQuery();
if (RowData > 0)
{
MessageBox.Show("Record Saved Sucessfully!");
textBox24.Clear();
textBox25.Clear();
pictureBox2.Image.Dispose();
}
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
}
Codes for button13 (Update):
private void button13_Click(object sender, EventArgs e)
{
try
{
MemoryStream ms = new MemoryStream();
pictureBox2.Image.Save(ms, pictureBox2.Image.RawFormat);
byte[] ImageData2 = ms.ToArray();

MySqlCommand command = new MySqlCommand("UPDATE tblcredentials SET


CredentialID=@CredID," +
" CredentialImage=@CredImage WHERE EmployeeNo = '" +
textBox24.Text + "'", conn);

command.Parameters.Add("@CredID", MySqlDbType.VarChar).Value = textBox22.Text;


command.Parameters.Add("@CredImage", MySqlDbType.VarChar).Value = ImageData2;
conn.Open();
int RowData = command.ExecuteNonQuery();
if (RowData > 0)
{
MessageBox.Show("Record Updated Sucessfully!");
textBox24.Clear();
textBox25.Clear();

pictureBox2.Image = System.Drawing.Image.FromFile(Application.StartupPath + "\\


documents.png");
}
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
}

Codes for button14 (Search):


private void button14_Click(object sender, EventArgs e)
{
string qrySearch = "SELECT *FROM tblcredentials WHERE EmployeeNo = '" + this.textBox24.Text + "'";
MySqlCommand MySearch = new MySqlCommand(qrySearch, conn);
MySqlDataReader MyReadRecord;
conn.Open();
MyReadRecord = MySearch.ExecuteReader();

if (MyReadRecord.Read())
{
this.textBox24.Text = MyReadRecord["EmployeeNo"].ToString();
this.textBox25.Text = MyReadRecord["CredentialID"].ToString();

byte[] arrImage = ((byte[])MyReadRecord["CredentialImage"]);


if (arrImage == null)
{
pictureBox2.Image = null;
}
else
{
MemoryStream ms = new MemoryStream(arrImage);
ms.Seek(0, SeekOrigin.Begin);
pictureBox2.Image = Image.FromStream(ms);
}
}
else
{
pictureBox2.Image = null;
}

conn.Close();
}

Codes for button15 (Exit):


private void button15_Click(object sender, EventArgs e)
{
Close();
}

Codes for button20 (Delete [record]):c


private void button20_Click(object sender, EventArgs e)
{
try
{
MySqlCommand command = new MySqlCommand("DELETE FROM tblcredentials WHERE
EmployeeNo = @EmpNo", conn);
command.Parameters.Add("@EmpNo", MySqlDbType.VarChar).Value = textBox24.Text;
conn.Open();
int RowData = command.ExecuteNonQuery();
if (RowData > 0)
{
MessageBox.Show("Record Deleted Successfully!");
textBox24.Clear();
textBox25.Clear();

pictureBox2.Image = System.Drawing.Image.FromFile(Application.StartupPath + "\\


documents.png");

DisplayRecord3();
}
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
}

Additional Codes to show data in DataGridView3 (DisplayRecord3):


public void DisplayRecord3()
{
string qryDisplay = "SELECT EmployeeNo, CredentialID, CredentialImage FROM tblcredentials ORDER By
CredentialID ASC";
MySqlCommand MyDisplay = new MySqlCommand(qryDisplay, conn);

MySqlDataAdapter DisplayAdapter = new MySqlDataAdapter();


DisplayAdapter.SelectCommand = MyDisplay;
DataTable dTable = new DataTable();
DisplayAdapter.Fill(dTable);

dataGridView3.RowTemplate.Height = 80;
dataGridView3.AutoResizeRows(DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders);
dataGridView3.DataSource = dTable;

DataGridViewImageColumn imgCol = new DataGridViewImageColumn();


imgCol = (DataGridViewImageColumn)dataGridView3.Columns[2];
imgCol.ImageLayout = DataGridViewImageCellLayout.Stretch;
dataGridView3.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

dataGridView3.Font = new Font("Tahoma", 8);


dataGridView3.ReadOnly = true;
dataGridView3.MultiSelect = false;
dataGridView3.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView3.ShowRowErrors = false;
dataGridView3.ShowCellErrors = false;
dataGridView3.AllowUserToAddRows = false;
dataGridView3.AllowUserToResizeColumns = false;
dataGridView3.AllowUserToResizeRows = false;
dataGridView3.RowHeadersVisible = false;
dataGridView3.DefaultCellStyle.SelectionBackColor = Color.LightSeaGreen;
dataGridView3.AlternatingRowsDefaultCellStyle.BackColor = Color.LightCyan;
}

ADDITIONAL CODES
using System.IO;
using MySql.Data.MySqlClient;

MySqlConnection conn = new MySqlConnection("datasource=localhost; username=root; password=;


database=dbhris");

You might also like