Пример #1
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow currRow = ((DataGridView)sender).CurrentRow;

            try
            {
                long     patientID = Int64.Parse(currRow.Cells[0].Value.ToString());
                string   firstName = currRow.Cells[1].Value == null ? "" : currRow.Cells[1].Value.ToString();
                string   lastName  = currRow.Cells[2].Value == null ? "" : currRow.Cells[2].Value.ToString();
                DateTime birthdate;
                DateTime.TryParse(currRow.Cells[3].Value.ToString(), out birthdate);
                Patient patient = new Patient()
                {
                    PatientID = patientID, FirstName = firstName, LastName = lastName, Birthday = birthdate
                };
                if (!fachkonzept.UpdatePatient(patient))
                {
                    throw new Exception("Änderung konnte nicht gespeichert werden.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }