private void frmShowPatient_Load(object sender, System.EventArgs e) { clsDomainControl_Register domain = new clsDomainControl_Register(); if (strPatientName != "") { DataTable dt = new DataTable(); domain.m_lngFindPatient(strPatientName, strSex, strBirth, out dt); int Age = 0; if (dt.Rows.Count > 0) { for (int i1 = 0; i1 < dt.Rows.Count; i1++) { ListViewItem newItem = new ListViewItem(dt.Rows[i1]["PATIENTCARDID_CHR"].ToString()); newItem.SubItems.Add(dt.Rows[i1]["LASTNAME_VCHR"].ToString().Trim()); newItem.SubItems.Add(dt.Rows[i1]["SEX_CHR"].ToString().Trim()); try { DateTime brith = DateTime.Parse(dt.Rows[i1]["BIRTH_DAT"].ToString()); Age = DateTime.Now.Year - brith.Year; } catch { } newItem.SubItems.Add(Age.ToString().Trim()); newItem.SubItems.Add(dt.Rows[i1]["HOMEADDRESS_VCHR"].ToString().Trim()); newItem.SubItems.Add(dt.Rows[i1]["HOMEPHONE_VCHR"].ToString().Trim()); newItem.SubItems.Add(dt.Rows[i1]["IDCARD_CHR"].ToString().Trim()); newItem.Tag = dt.Rows[i1]; listView1.Items.Add(newItem); } listView1.Items[0].Selected = true; } } }