internal void SaveStudentMedical(MSDStudentMedical medical) { String query = ""; if (medical.Id != 0) { query = " UPDATE student_medical SET " + " insurance_company = '" + medical.InsuranceCompany + "'" + ", policy_number = '" + medical.PolicyNumber + "'" + ", phone = '" + medical.Phone + "'" + ", pediatrician_name = '" + medical.PediatricianName + "'" + ", emergency_name = '" + medical.EmergencyName + "'" + ", emergency_phone = '" + medical.EmergencyPhone + "'" + ", emergency_phone_alt = '" + medical.EmergencyPhoneAlt + "'" + " WHERE id = " + medical.Id; } else { query = " INSERT INTO student_medical (insurance_company, policy_number, phone, pediatrician_name, emergency_name, emergency_phone, emergency_phone_alt, student_id) VALUES (" + " '" + medical.InsuranceCompany + "'" + ", '" + medical.PolicyNumber + "'" + ", '" + medical.Phone + "'" + ", '" + medical.PediatricianName + "'" + ", '" + medical.EmergencyName + "'" + ", '" + medical.EmergencyPhone + "'" + ", '" + medical.EmergencyPhoneAlt + "'" + ", " + medical.MSDStudentId + ");"; } try { SQLiteCommand command = new SQLiteCommand(query, lconn); command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
internal MSDStudentMedical FindStudentMedicalByStudentId(int sid) { String query = "SELECT * FROM student_medical WHERE student_id = " + sid + ";"; MSDStudentMedical medical = new MSDStudentMedical(); try { SQLiteCommand command = new SQLiteCommand(query, lconn); SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { medical.Id = System.DBNull.Value != reader["id"] ? Convert.ToInt32(reader["id"]) : 0; medical.InsuranceCompany = System.DBNull.Value != reader["insurance_company"] ? (String)reader["insurance_company"] : null; medical.PolicyNumber = System.DBNull.Value != reader["policy_number"] ? (String)reader["policy_number"] : null; medical.Phone = System.DBNull.Value != reader["phone"] ? (String)reader["phone"] : null; medical.PediatricianName = System.DBNull.Value != reader["pediatrician_name"] ? (String)reader["pediatrician_name"] : null; medical.EmergencyName = System.DBNull.Value != reader["emergency_name"] ? (String)reader["emergency_name"] : null; medical.EmergencyPhone = System.DBNull.Value != reader["emergency_phone"] ? (String)reader["emergency_phone"] : null; medical.EmergencyPhoneAlt = System.DBNull.Value != reader["emergency_phone_alt"] ? (String)reader["emergency_phone_alt"] : null; medical.MSDStudentId = System.DBNull.Value != reader["student_id"] ? Convert.ToInt32(reader["student_id"]) : sid; break; } } catch (Exception ex) { Console.WriteLine(ex.Message); } return medical; }
internal void EditStudentMedical() { if (StudentMedicalEditButtonLabel.Equals("Edit")) { StudentMedicalEditButtonLabel = "Cancel"; CanEditStudentMedical = true; CanClickStudentMedicalSave = true; } else if (StudentMedicalEditButtonLabel.Equals("Cancel")) { if (null != CurrentMSDStudent && 0 != CurrentMSDStudent.Id) _msdStudentMedical = _studentModel.FindStudentMedicalByStudentId(CurrentMSDStudent.Id); StudentMedicalEditButtonLabel = "Edit"; CanEditStudentMedical = false; CanClickStudentMedicalSave = false; } StudentSearchErrorMesage = ""; NotifyPropertyChanged(""); }
internal void SearchStudentByFirstLastName() { if (String.IsNullOrEmpty(SearchFirstName) || String.IsNullOrEmpty(SearchLastName)) { StudentSearchErrorMesage = "Please Input First and Last Name."; NotifyPropertyChanged(""); return; } MSDStudent student = _studentModel.FindStudentByFirstNameLastName(SearchFirstName.Trim(), SearchLastName.Trim()); if (null == student) { StudentSearchErrorMesage = "Can't find student with first name : " + SearchFirstName.Trim() + " last name : " + SearchLastName.Trim(); NotifyPropertyChanged(""); return; } CurrentMSDStudent = student; ShowStudentTabControl = "Visible"; StudentSearchErrorMesage = ""; _msdStudentParents = _studentModel.FindStudentParentsByStudentId(CurrentMSDStudent.Id); StudentInformationEditButtonLabel = "Edit"; CanEditStudentInformation = false; CanClickStudentInformationSave = false; _msdStudentMedical = _studentModel.FindStudentMedicalByStudentId(CurrentMSDStudent.Id); StudentMedicalEditButtonLabel = "Edit"; CanEditStudentMedical = false; CanClickStudentMedicalSave = false; NotifyPropertyChanged(""); }
internal void AddNewStudent() { CurrentMSDStudent = new MSDStudent(); ShowStudentTabControl = "Visible"; StudentSearchErrorMesage = ""; SearchFirstName = ""; SearchLastName = ""; StudentInformationEditButtonLabel = "Cancel"; CanEditStudentInformation = true; CanClickStudentInformationSave = true; StudentMedicalEditButtonLabel = "Cancel"; CanEditStudentMedical = true; CanClickStudentMedicalSave = true; _msdStudentMedical = new MSDStudentMedical(); _msdStudentParents = new List<MSDStudentParent>(); _msdStudentParents.Add(new MSDStudentParent()); _msdStudentParents.Add(new MSDStudentParent()); NotifyPropertyChanged(""); }