// Updates Existing patient private void btnUpdate_Click(object sender, EventArgs e) { PatientIndex = (int) numIndex.Value; //Takes index value from invisible numbox (tab2) /* int index = (int) numIndex.Value; //Takes index value from invisible numbox (tab2) */ PatientDataRecords a = Patients[PatientIndex]; //Value @ list[index] copied to new instance of PatientDataRecords Patients.RemoveAt(PatientIndex); //Old instance removed from list a.Name = tbName.Text; //Populate a a.PatientNumber = tbPatNum.Text; a.Consultant = cbConsultant.Text; a.Diagnosis = tbDiagnosis.Lines; a.Allergies = tbAllergies.Text; a.ActRegime = cbActRegime.Text; a.Prescription = tbPrescriptions.Lines; a.LastDose = dtLastDose.Value; a.NextDose = dtNextDose.Value; a.CurrentTreatment = (byte)numCurrentTreatment.Value; a.NoOfTreatments = (byte) Convert.ToInt32(numNoOfTreatments.Value.ToString()); a.DOB = dtDOB.Value; a.Gender = cbGender.Text; MedicalValues LMV = new MedicalValues(DateTime.Now.Date,//Last update DateTime<> numHeight.Value,//decimal Convert.ToInt32(numWeight.Value),//Int (int) numSC.Value, //int (int) numAUC.Value ); a.MedVals.Add(LMV); Patients.Add(a); //Append updates from a to list XmlSerializer XSR = new XmlSerializer(typeof(List<PatientDataRecords>)); //new instance of XML serialiser to store List PatientDataRecords FileStream DataOut = new FileStream("PatientRecords.xml", FileMode.Create); //Creates file object XSR.Serialize(DataOut, Patients); //Outputs data DataOut.Close(); //Closes File MessageBox.Show("Data Updated", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); }
//, List< public PatientDataRecords(string Name, string PatientNumber, string Consultant, string[] Diagnosis, string Allergies, string ActRegime, string[] Prescription, DateTime DOB, DateTime LastDose, DateTime NextDose, byte CurrentTreatment, byte NoOfTreatments, string Gender, MedicalValues LatestMedVal) { List<MedicalValues> Placebo = new List<MedicalValues>(); //Creates MedValList Placebo.Add(LatestMedVal); //Takes LatestMedVal adds it to list this.Name = Name; this.PatientNumber = PatientNumber; this.Consultant = Consultant; this.Diagnosis = Diagnosis; this.Allergies = Allergies; this.ActRegime = ActRegime; this.Prescription = Prescription; this.DOB = DOB; this.LastDose = LastDose; this.NextDose = NextDose; this.CurrentTreatment = CurrentTreatment; this.NoOfTreatments = NoOfTreatments; this.Gender = Gender; this.MedVals = Placebo; //Using above to to add data sans tantrum }
//Submit New Record private void btnSubmit_Click(object sender, EventArgs e) { ReadData(); //Populates List<Patient> with existing data MedicalValues LMV = new MedicalValues(DateTime.Now.Date,//Last update DateTime<> numHeight.Value,//decimal Convert.ToInt32(numWeight.Value),//Int (int) numSC.Value, //int (int) numAUC.Value ); //New instance of PatientDataRecords Populated with current patients info PatientDataRecords X = new PatientDataRecords( tbName.Text, //str tbPatNum.Text, cbConsultant.Text,//str tbDiagnosis.Lines, tbAllergies.Text,//str cbActRegime.Text, tbPrescriptions.Lines, DateTime.Parse(dtDOB.Text),//DateTime DateTime.Parse(dtLastDose.Text),//DateTime DateTime.Parse(dtNextDose.Text),//DateTime byte.Parse(numCurrentTreatment.Value.ToString()),//Byte byte.Parse(numNoOfTreatments.Value.ToString()),//Byte cbGender.Text,//Str LMV ); XmlSerializer XSR = new XmlSerializer(typeof(List<PatientDataRecords>)); //new instance of XML serialiser to store List PatientDataRecords Patients.Add(X); //Appends latest data to list FileStream DataOut = new FileStream("PatientRecords.xml", FileMode.Create); //Creates file object XSR.Serialize(DataOut, Patients); //Outputs data DataOut.Close(); //Closes File MessageBox.Show("Data Recorded", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); }