private void btnDelete_Click(object sender, EventArgs e) { foreach (Control control in groupBoxMemberData.Controls) { if (string.IsNullOrEmpty(control.Text.Trim())) { MessageBox.Show("Please enter a value for " + control.Name.ToString()); control.Focus(); return; } } Member objMember = new Member(); objMember.memberNumber = Convert.ToInt32(lblSelected.Text); try { bool status = MemberDB.DeleteMember(objMember); if (status) //You can use this syntax as well..if (status ==true) { Reload_Data(); MessageBox.Show("Member was deleted from the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Member was not deleted from the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnDelete_Click(object sender, EventArgs e) { //Validate the UI if (string.IsNullOrEmpty(txtJoinDate.Text.Trim())) { MessageBox.Show("Please enter a member name."); txtJoinDate.Focus(); return; } Member objMember = MemberDB.GetMember(txtNumber.Text); try { bool status = MemberDB.DeleteMember(objMember); if (status) //You can use this syntax as well..if (status ==true) { MessageBox.Show("Member was deleted from the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Member was not deleted from the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnDelete_Click(object sender, EventArgs e) { if (!(validateUI(btnDelete))) { return; } try { Member myMember = new Member(); myMember.member_status = "A"; myMember.member_number = Convert.ToInt32(txtMemberNumber.Text.Trim()); myMember.joindate = Convert.ToDateTime(txtJoinDate.Text.Trim()); myMember.firstname = txtFirstName.Text.Trim(); myMember.lastname = txtLastName.Text.Trim(); myMember.zipcode = txtZipCode.Text.Trim(); myMember.cell_phone = txtCellPhone.Text.Trim(); myMember.username = txtUsername.Text.Trim(); myMember.password = txtPassword.Text.Trim(); myMember.email = txtEmail.Text.Trim(); bool status = MemberDB.DeleteMember(myMember); if (status) //returns true { MessageBox.Show("Member ID has been deleted from the database.", "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Information); //Automatically refresh the data grid this.btnBrowse_Click(null, null); } else //returns false { MessageBox.Show("Member ID was not deleted from the database.", "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_Delete_Click(object sender, EventArgs e) { try { Member m = GetMemberObjFromUI(); if (m != null) { if (MemberDB.DeleteMember(GetMemberObjFromUI())) { MessageBox.Show("Delete Successful."); } else { MessageBox.Show("Delete Failed. Make sure all information has been entered."); } } } catch (Exception ex) { MessageBox.Show("There was a technical error during the operation.\n\nMessage:\n" + ex.Message + "\n\nStack Trace:\n" + ex.StackTrace); } }