Esempio n. 1
0
        private void dataGridView3_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow currRow = ((DataGridView)sender).CurrentRow;

            try
            {
                long     illnessID  = Int64.Parse(currRow.Cells[0].Value.ToString());
                string   name       = currRow.Cells[1].Value == null ? "" : currRow.Cells[1].Value.ToString();
                bool     contagious = currRow.Cells[2].Value == null ? false : (bool)currRow.Cells[2].Value;
                bool     lethal     = currRow.Cells[3].Value == null ? false : (bool)currRow.Cells[3].Value;
                bool     curable    = currRow.Cells[4].Value == null ? false : (bool)currRow.Cells[4].Value;
                DateTime birthdate;
                DateTime.TryParse(currRow.Cells[3].Value.ToString(), out birthdate);
                Illness illness = new Illness()
                {
                    IllnessID = illnessID, Name = name, Contagious = contagious, Lethal = lethal, Curable = curable
                };
                if (!fachkonzept.UpdateIllness(illness))
                {
                    throw new Exception("Änderung konnte nicht gespeichert werden.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }