From 1f62a8d06ec7f0ff94f43f2a6197aa56b6f9b4a7 Mon Sep 17 00:00:00 2001 From: kougyokugentou <41278462+kougyokugentou@users.noreply.github.com> Date: Fri, 29 Jan 2021 21:17:26 -0800 Subject: [PATCH] Clean up unneeded usings Check for existing guardian on 'save and close' --- frmGuardianCrud.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/frmGuardianCrud.cs b/frmGuardianCrud.cs index 5fc23aa..6c61616 100644 --- a/frmGuardianCrud.cs +++ b/frmGuardianCrud.cs @@ -1,12 +1,6 @@ using System; -using System.Collections.Generic; using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; using System.Text.RegularExpressions; -using System.Threading.Tasks; using System.Windows.Forms; using GreatHomeChildcare.Models; @@ -94,6 +88,8 @@ namespace GreatHomeChildcare */ private void btnSaveClose_Click(object sender, EventArgs e) { + Guardian checkExistingGuardian = new Guardian(); + MessageBox.Show("Save and close clicked"); this.Validate(); @@ -109,6 +105,15 @@ namespace GreatHomeChildcare } } + checkExistingGuardian = SqliteDataAccess.GetGuardianByPin(Int32.Parse(strPin)); + + if(checkExistingGuardian != null) + { + MessageBox.Show("Please choose a different PIN number.", "Great Home Childcare", MessageBoxButtons.OK, MessageBoxIcon.None); + return; + } + + guardian.id = Int32.Parse(idNumericUpDown.Value.ToString()); guardian.LastName = lastNameTextBox.Text; guardian.FirstName = firstNameTextBox.Text;