示例#1
0
        private void updateDataGrid()
        {
            int    id   = (int)numericUpDownSearchID.Value;
            string cim  = new CimCodes(cims, textBoxDiagnostic.Text, "ID").ID;
            string date = (radioButtonToday.Checked) ? DateTime.Today.ToString("dd-MM-yyyy") : maskedTextBoxDate.Text;

            int count = 0;

            string query = "select * from consultations where ";

            if (checkBoxID.Checked)
            {
                query += "ID=" + id;
                count++;
            }
            if (checkBoxDiagnostic.Checked)
            {
                if (count > 0)
                {
                    query += " and ";
                }
                query += "CIM like \'%" + cim + "%\'";
                count++;
            }
            if (checkBoxDate.Checked)
            {
                if (count > 0)
                {
                    query += " and ";
                }
                query += "ConsDate like \'%" + date + "%\'";
                count++;
            }
            if (count > 0)
            {
                query += " and ";
            }
            query += "IdPatient=" + selectedPatient.ID;

            consultations = connectionClass.getConsultationsData(query);

            dataGridViewConsultations.Rows.Clear();
            if (consultations != null)
            {
                foreach (Consultation cons in consultations)
                {
                    DataGridViewRow newRow = new DataGridViewRow();

                    newRow.CreateCells(dataGridViewConsultations);
                    newRow.Cells[0].Value = cons.ID;
                    newRow.Cells[1].Value = cons.Date;
                    newRow.Cells[2].Value = new CimCodes(cims, cons.CIM, "Diagnostic").Diagnostic;
                    dataGridViewConsultations.Rows.Add(newRow);
                }
            }
        }