예제 #1
0
 //open the selected record if extant
 private void lstClients_DoubleClick(object sender, EventArgs e)
 {
     if (lstClients.SelectedItem != null)
     {
         ShortRecord record = lstClients.SelectedItem as ShortRecord;
         if (record != null)
         {
             new ClientRecord(record.IntID);
         }
     }
 }
예제 #2
0
 //by first and last name
 private void btnSearchName_Click(object sender, EventArgs e)
 {
     if (txtFamilyName.Text == "" && txtGivenName.Text == "")
     {
         new Message("No data entered.");
     }
     else
     {
         List <ShortRecord> newData = new List <ShortRecord>();
         OdbcCommand        query   = new OdbcCommand("SELECT id, client_id, citizen_cert, given_name, family_name, dob, contract_type from client where " +
                                                      "given_name LIKE '%" + Utilities.MySQL_String(txtGivenName.Text) + "%' AND " +
                                                      "family_name LIKE '%" + Utilities.MySQL_String(txtFamilyName.Text) + "%'");
         query.Connection = Utilities.kis_clients;
         OdbcDataReader results = query.ExecuteReader();
         if (results.HasRows)
         {
             while (results.Read())
             {
                 string extID;
                 if (results["citizen_cert"].ToString() != "")
                 {
                     extID = results["citizen_cert"].ToString();
                 }
                 else
                 {
                     extID = results["client_id"].ToString();
                 }
                 DateTime dob;
                 DateTime.TryParse(results["dob"].ToString(), out dob);
                 ShortRecord record = new ShortRecord((int)results["id"], extID, results["family_name"] + ", " + results["given_name"], dob, results["contract_type"].ToString());
                 newData.Add(record);
             }
         }
         else
         {
             new Message("No results found.");
         }
         results.Close();
         lstClients.DataSource = newData;
     }
 }