private void AddNewPatient() { string cs = @"server=oharam29-nolanm45-mmse-app.c4zhfzwco8qq.eu-west-1.rds.amazonaws.com;Port=3306;database=patient_info;user id=oharam29;password=f1sfo9mu;Persist Security Info=True;charset=utf8;"; MySqlConnection con = new MySqlConnection(cs); try { if (con.State == ConnectionState.Closed) { con.Open(); MySqlCommand cmd = new MySqlCommand("INSERT INTO TBL_PATIENT(FirstName, LastName, DateOfBirth,DoctorID) VALUES(@firstname, @lastname, @dateofbirth, @doc)", con); cmd.Parameters.AddWithValue("@firstname", Firstname); cmd.Parameters.AddWithValue("@lastname", Lastname); cmd.Parameters.AddWithValue("@dateofbirth", Dob); cmd.Parameters.AddWithValue("@doc", App.currentDoctor.DoctorId); cmd.ExecuteNonQuery(); } } catch (MySqlException ex) { throw (ex); } finally { con.Close(); string patientName = "Patient: " + Firstname + " " + Lastname + " added"; App.Current.MainPage.DisplayAlert(patientName, "", "OK"); var patientPage = new PatientsViewPage(); navigation.InsertPageBefore(patientPage, navigation.NavigationStack[navigation.NavigationStack.Count - 1]); navigation.RemovePage(navigation.NavigationStack[navigation.NavigationStack.Count - 1]); navigation.PopAsync(); } }
private void Delete_Patient(object sender, EventArgs e) { DbResult result = Delete_From_DB(); if (result.success) { App.Current.MainPage.DisplayAlert(result.msg, "", "Ok"); var patientPage = new PatientsViewPage(); Navigation.InsertPageBefore(patientPage, Navigation.NavigationStack[Navigation.NavigationStack.Count - 1]); Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 1]); Navigation.PopAsync(); } }