示例#1
0
        private void updateDataGrid()
        {
            string query = "select * from patients where ";

            query += "name like \'" + textBoxSearchN.Text + "%\' and ";
            query += "lastname like \'" + textBoxSearchLN.Text + "%\' and ";
            query += "CNP like \'" + maskedTextBoxSearchCNP.Text + "%\'";

            patients = connectionClass.getPatientsData(query);

            dataGridViewPatients.Rows.Clear();

            if (patients != null)
            {
                dataGridViewPatients.Visible = patients.Count > 0;
                buttonCancelSearch.Visible   = patients.Count > 0;

                foreach (Patient p in patients)
                {
                    DataGridViewRow newRow = new DataGridViewRow();

                    newRow.CreateCells(dataGridViewPatients);
                    newRow.Cells[0].Value = p.Name;
                    newRow.Cells[1].Value = p.MiddleInitials;
                    newRow.Cells[2].Value = p.LastName;
                    newRow.Cells[3].Value = p.CNP;
                    dataGridViewPatients.Rows.Add(newRow);
                }
            }
            else
            {
                dataGridViewPatients.Visible = false;
                buttonCancelSearch.Visible   = false;
            }
        }