private void BtnClear_Click(object sender, EventArgs e) { TxtFirstName.Clear(); TxtLastName.Clear(); TxtGrade.Clear(); TxtAddress.Clear(); TxtContactNo.Clear(); }
/// <summary> /// this will clear all the educational fields /// </summary> private void ClearEducation() { CkbApproved.Checked = true; TxtCourseID.Clear(); TxtGrade.Clear(); TxtDescription.Clear(); TxtDateApproved.Clear(); TxtCredits.Clear(); }
private void BtnUpdate_Click(object sender, EventArgs e) { if (TxtFirstName.Text == "") { MessageBox.Show("Please fill empty fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (TxtLastName.Text == "") { MessageBox.Show("Please fill empty fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (TxtGrade.Text == "") { MessageBox.Show("Please fill empty fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (TxtAddress.Text == "") { MessageBox.Show("Please fill empty fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (TxtContactNo.Text == "") { MessageBox.Show("Please fill empty fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { var result = MessageBox.Show("Confirm editing new record?", "Edit New Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { using (var con = new MySqlConnection(GetConnection())) { string command = $"UPDATE `lms.sad`.`tblusers`" + $" SET " + $"`First_Name`='{TxtFirstName.Text}',`Last_Name`='{TxtLastName.Text}',`Year_Level`='{TxtGrade.Text}',`Address`='{TxtAddress.Text}',`Contact_Number`='{TxtContactNo.Text}'" + $" WHERE `User_ID`='{TxtUserID.Text}'"; con.Open(); using (var cmd = new MySqlCommand(command, con)) { cmd.CommandType = CommandType.Text; var i = cmd.ExecuteNonQuery(); if (i > 0) { MessageBox.Show("Successfully Updated! Please refresh Book List to view entry!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtFirstName.Clear(); TxtLastName.Clear(); TxtGrade.Clear(); TxtAddress.Clear(); TxtContactNo.Clear(); TxtUserID.Clear(); } } con.Close(); } } } }
private void BtnRegister_Click(object sender, EventArgs e) { if (TxtFirstName.Text == "") { MessageBox.Show("Please enter missing fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (TxtLastName.Text == "") { MessageBox.Show("Please enter missing fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (TxtGrade.Text == "") { MessageBox.Show("Please enter missing fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (TxtAddress.Text == "") { MessageBox.Show("Please enter missing fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (TxtContactNo.Text == "") { MessageBox.Show("Please enter missing fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { var result = MessageBox.Show("Confirm adding new record?", "Add New Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { using (var con = new MySqlConnection(GetConnection())) { string command = $"INSERT INTO `lms.sad`.`tblusers` (`First_Name`,`Last_Name`, `Year_Level`, `Address`,`Contact_Number`) " + "VALUES " + $"('{TxtFirstName.Text}','{TxtLastName.Text}','{TxtGrade.Text}','{TxtAddress.Text}','{TxtContactNo.Text}')"; con.Open(); using (var cmd = new MySqlCommand(command, con)) { cmd.CommandType = CommandType.Text; var i = cmd.ExecuteNonQuery(); if (i > 0) { MessageBox.Show("Successfully Added! Please refresh Borrower List to view entry!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); TxtFirstName.Clear(); TxtLastName.Clear(); TxtGrade.Clear(); TxtAddress.Clear(); TxtContactNo.Clear(); } } con.Close(); } } } }
/*************************************** * * This is where the UTILITY METHODS are. * ***************************************/ /// <summary> /// This clears the form after an entry is added. /// </summary> private void ClearForm() { TxtEmpID.Clear(); TxtFirstName.Clear(); TxtLastName.Clear(); TxtMiddleName.Clear(); TxtXtraProp1.Clear(); TxtXtraProp2.Clear(); CkbActiveEmployee.Checked = true; CkbBenefits.Checked = true; CkbApproved.Checked = true; LVxCourses.Items.Clear(); TxtCourseID.Clear(); TxtGrade.Clear(); TxtDescription.Clear(); TxtDateApproved.Clear(); TxtCredits.Clear(); TxtMaritalStatus.Clear(); TxtDepartment.Clear(); TxtTitle.Clear(); TxtStartDate.Clear(); }