Example #1
0
 public void DataToUI(Patient p)
 {
     txtName.Text = p.name;
     txtId.Text = p.id.ToString();
     txtAge.Text = p.age.ToString();
     txtReportId.Text = p.report.reportId.ToString();
     txtReport1.Text = p.report.report1;
     txtReport2.Text = p.report.report2;
 }
Example #2
0
 private string fileName = "patient.xml";//文件名称与路径
 public Patient UIToData()
 {
     Patient patient = new Patient();
     patient.report = new Report();
     patient.name = txtName.Text;
     patient.id = Convert.ToInt32(txtId.Text);
     patient.age = Convert.ToInt32(txtAge.Text);
     patient.report.reportId = Convert.ToInt32(txtReportId.Text);
     patient.report.report1 = txtReport1.Text;
     patient.report.report2 = txtReport2.Text;
     return patient;
 }
Example #3
0
        private void btnRead_Click(object sender, RoutedEventArgs e)
        {
            Patient p = new Patient();

            using (Stream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            {

                if (rdBtnSoap.IsChecked == true)
                {
                    SoapFormatter soapFormat = new SoapFormatter();
                    p = (Patient)soapFormat.Deserialize(fStream);
                }
                else
                {
                    BinaryFormatter binFormat = new BinaryFormatter();
                    p = (Patient)binFormat.Deserialize(fStream);
                }
            }
            DataToUI(p);
        }