Esempio n. 1
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (dgvPersons.SelectedRows.Count > 0)
     {
         var           _selectedPerson = dgvPersons.SelectedRows[0].DataBoundItem as Person;
         FrmEditPerson _frmEdit        = new FrmEditPerson(_selectedPerson);
         _frmEdit.ShowDialog();
     }
 }
Esempio n. 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Person        _newPerson = new Person();
            FrmEditPerson _frmEdit   = new FrmEditPerson(_newPerson);

            if (_frmEdit.ShowDialog() == DialogResult.OK)
            {
                _newPerson.GUID = System.Guid.NewGuid().ToString();
                m_PersonList.Add(_newPerson);
            }
        }
Esempio n. 3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            FrmEditPerson _frmEdit = new FrmEditPerson();

            _frmEdit.PersonDateOfBirth = DateTime.Today;

            if (_frmEdit.ShowDialog() == DialogResult.OK)
            {
                dgvPersons.Rows.Add(_frmEdit.PersonName, _frmEdit.PersonSurname, _frmEdit.PersonDateOfBirth);
            }
        }
Esempio n. 4
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (dgvPersons.SelectedRows.Count > 0)
            {
                var           _selectedRow = dgvPersons.SelectedRows[0];
                FrmEditPerson _frmEdit     = new FrmEditPerson();
                _frmEdit.PersonName        = (string)_selectedRow.Cells[0].Value;
                _frmEdit.PersonSurname     = (string)_selectedRow.Cells[1].Value;
                _frmEdit.PersonDateOfBirth = (DateTime)_selectedRow.Cells[2].Value;

                if (_frmEdit.ShowDialog() == DialogResult.OK)
                {
                    _selectedRow.Cells[0].Value = _frmEdit.PersonName;
                    _selectedRow.Cells[1].Value = _frmEdit.PersonSurname;
                    _selectedRow.Cells[2].Value = _frmEdit.PersonDateOfBirth;
                }
            }
        }