private async void AddVisitClicked(object sender, RoutedEventArgs e) { VisitFormCmdbar.IsOpen = false; VisitFormBar.IsOpen = true; VisitCustomDialogAnimation.Begin(); try { string query = "SELECT Height, Weight FROM MedicalDetails WHERE PID = @pid"; Statement statement = await database.PrepareStatementAsync(query); statement.BindTextParameterWithName("@pid", this.PID); statement.EnableColumnsProperty(); double height = -1; Int32 weight = -1; while (await statement.StepAsync()) { height = Double.Parse(statement.Columns["Height"]); weight = Int32.Parse(statement.Columns["Weight"]); } if (height != -1) { this.setHeightBoxFromMeterHeight(height); } if (weight != -1) { VisitWeight.Text = weight.ToString(); } } catch (Exception ex) { var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult); Debug.WriteLine("CREATE_NEW_VISIT---Add_Visit_Clicked" + "\n" + ex.Message + "\n" + result.ToString()); } }
private async void EditVisitClicked(object sender, RoutedEventArgs e) { VisitFormCmdbar.IsOpen = false; VisitCustomDialogAnimation.Begin(); if (VisitListBox.SelectedItem != null) { VisitFormBar.IsOpen = true; try { string query = "SELECT * FROM MedicalDetails WHERE PID = @pid AND DateVisited = @dv"; Statement statement = await this.database.PrepareStatementAsync(query); statement.BindTextParameterWithName("@pid", this.PID); statement.BindTextParameterWithName("@dv", VisitListBox.Items[VisitListBox.SelectedIndex].ToString()); statement.EnableColumnsProperty(); if (await statement.StepAsync()) { string[] dv = statement.Columns["DateVisited"].Split('-'); this.setHeightBoxFromMeterHeight(Convert.ToDouble(statement.Columns["Height"])); VisitDayComboBox.SelectedIndex = VisitDayComboBox.Items.IndexOf(Int32.Parse(dv[2])); VisitMonthComboBox.SelectedIndex = VisitMonthComboBox.Items.IndexOf(dv[1]); VisitYearComboBox.SelectedIndex = VisitYearComboBox.Items.IndexOf(Int32.Parse(dv[0])); VisitSymptoms.Text = statement.Columns["Symptoms"]; VisitDiseasesDiagnosed.Text = statement.Columns["DiseaseFound"]; VisitWeight.Text = statement.Columns["Weight"]; VisitSystolicBP.Text = statement.Columns["SystolicBP"]; VisitDiastolicBP.Text = statement.Columns["DiastolicBP"]; VisitBloodGlucose.Text = statement.Columns["BloodGlucose"]; } } catch (Exception ex) { var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult); Debug.WriteLine("CREATE_NEW_VISIT---EDIT_VISIT_CLICKED---MEDIC_DETAILS" + "\n" + ex.Message + "\n" + result.ToString()); } try { string query = "SELECT Medicine FROM MedicalDetailsMedicine WHERE PID = @pid AND DateVisited = @dv"; Statement statement = await this.database.PrepareStatementAsync(query); statement.BindTextParameterWithName("@pid", this.PID); statement.BindTextParameterWithName("@dv", VisitListBox.Items[VisitListBox.SelectedIndex].ToString()); statement.EnableColumnsProperty(); VisitMedicineGiven.Text = ""; while (await statement.StepAsync()) { VisitMedicineGiven.Text += statement.Columns["Medicine"] + ","; } if (!VisitMedicineGiven.Text.Equals("")) { VisitMedicineGiven.Text = VisitMedicineGiven.Text.Substring(0, VisitMedicineGiven.Text.Length - 1); } } catch (Exception ex) { var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult); Debug.WriteLine("CREATE_NEW_VISIT---EDIT_VISIT_CLICKED---MEDIC_DETAILS_MEDICINE" + "\n" + ex.Message + "\n" + result.ToString()); } try { string query = "SELECT Vaccine FROM MedicalDetailsVaccine WHERE PID = @pid AND DateVisited = @dv"; Statement statement = await this.database.PrepareStatementAsync(query); statement.BindTextParameterWithName("@pid", this.PID); statement.BindTextParameterWithName("@dv", VisitListBox.Items[VisitListBox.SelectedIndex].ToString()); statement.EnableColumnsProperty(); VisitVaccine.Text = ""; while (await statement.StepAsync()) { //Debug.WriteLine(statement.Columns["Vaccine"]); VisitVaccine.Text += statement.Columns["Vaccine"] + ","; } if (!VisitVaccine.Text.Equals("")) { VisitVaccine.Text = VisitVaccine.Text.Substring(0, VisitVaccine.Text.Length - 1); } } catch (Exception ex) { var result = SQLiteWinRT.Database.GetSqliteErrorCode(ex.HResult); Debug.WriteLine("CREATE_NEW_VISIT---EDIT_VISIT_CLICKED---MEDIC_DETAILS_VACCINE" + "\n" + ex.Message + "\n" + result.ToString()); } isUpdating = true; } }