diff --git a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs index 2eb8b36..fb903b1 100644 --- a/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs +++ b/Louis'-Pharmacy_CNSA212-FP/PharmacyDataTier.cs @@ -181,6 +181,58 @@ namespace Louis__Pharmacy_CNSA212_FP } } + + public static void UpdatePhysician( + string Physician_id, + string FirstName, + string LastName, + string MiddleInit, + DateTime DOB, + string Gender, + string City, + Int16 Zip, + string UsState, + string PhoneNumber, + string Speciality) + + { + try + { + myConn.Open(); + + cmdString.Parameters.Clear(); + + cmdString.Connection = myConn; + cmdString.CommandType = CommandType.StoredProcedure; + cmdString.CommandTimeout = 1500; + + cmdString.CommandText = "UpdatePhysician"; + + cmdString.Parameters.Add("@Physician_id", SqlDbType.VarChar, 8).Value = Physician_id; + cmdString.Parameters.Add("@FirstName", SqlDbType.VarChar, 30).Value = FirstName; + cmdString.Parameters.Add("@LastName", SqlDbType.VarChar, 30).Value = LastName; + cmdString.Parameters.Add("@MiddleIntials", SqlDbType.VarChar).Value = MiddleInit; + cmdString.Parameters.Add("@DOB", SqlDbType.DateTime).Value = DOB; + cmdString.Parameters.Add("@Gender", SqlDbType.Char).Value = Gender; + cmdString.Parameters.Add("@City", SqlDbType.VarChar, 30).Value = City; + cmdString.Parameters.Add("@Zip", SqlDbType.SmallInt).Value = Zip; + cmdString.Parameters.Add("@UsState", SqlDbType.VarChar, 2).Value = UsState; + cmdString.Parameters.Add("@PhoneNumber", SqlDbType.VarChar, 14).Value = PhoneNumber; + cmdString.Parameters.Add("@Speciality", SqlDbType.VarChar, 100).Value = Speciality; + + cmdString.ExecuteNonQuery(); + + } + catch (Exception ex) + { + throw new ArgumentException(ex.Message); + } + finally + { + myConn.Close(); + } + + } public static void DeletePatient(string Patient_id) diff --git a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs index f4ae666..039a6c9 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmInfo.cs @@ -23,6 +23,7 @@ namespace Louis__Pharmacy_CNSA212_FP InitializeComponent(); dgvPatient.DoubleClick += cmuPatientEdit_Click; + dgvPhysician.DoubleClick += cmuPhysicianEdit_Click; } diff --git a/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs b/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs index 9400c3d..45cb088 100644 --- a/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs +++ b/Louis'-Pharmacy_CNSA212-FP/frmPhysician.cs @@ -227,6 +227,8 @@ namespace Louis__Pharmacy_CNSA212_FP if (!hasFailed) { + if (isAdd) + { PharmacyDataTier.CreatePhysician( Physician_id, FirstName, @@ -239,6 +241,22 @@ namespace Louis__Pharmacy_CNSA212_FP UsState, PhoneNumber, Speciality); + } + else + { + PharmacyDataTier.UpdatePhysician( + Physician_id, + FirstName, + LastName, + MiddleIntials, + DOB, + Gender, + City, + Zip, + UsState, + PhoneNumber, + Speciality); + } SourceForm.txtPhysicianID.Text = Physician_id; SourceForm.btnPhysicianSearch_Click(sender, e);