コード例 #1
0
        private void btnAlter_Click(object sender, EventArgs e)
        {
            if (txtId.Text.Trim().Equals(String.Empty))
            {
                MessageBox.Show("A caixa de Id não deve estar vazia, selecione um pet antes de alterar.");
                return;
            }
            else if (allFullfilled())
            {
                var   ownerId  = Convert.ToInt64(cbOwner.SelectedValue);
                Owner petOwner = (Owner)ownerService.GetById(ownerId);
                Pet   newPet   = new Pet(txtName.Text, dtBirthday.Value, petOwner.OwnerId, txtSpecies.Text)
                {
                    PetId = Convert.ToInt64(txtId.Text)
                };

                Composition.AddSlice <Owner, Pet>(petOwner, newPet);

                petService.Alter(newPet);

                refreshDataGridView(petOwner);

                resetForm();
            }
        }