Exemple #1
0
        private void btnDeleteDetails_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure want to Delete this animal", "Confirmation", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                db.DeleteAnimal(animal);
                HomePanel.Show();
                AnmDetailsPanel.Hide();
                MessageBox.Show("Animal successfully deleted");
            }
            else
            {
                AnmDetailsPanel.Show();
            }
        }
Exemple #2
0
        private void btnUpdateDetails_Click(object sender, EventArgs e)
        {
            try
            {
                animal.setDateBrought(Convert.ToString(dtpDateBroughtDetails.Value));
                animal.setDescription(tbDescriptionDetails.Text);
                animal.setLocationFound(tbLocationFoundDetails.Text);

                if (tbOwnersIdDetails.Text != string.Empty)
                {
                    int po_id = Convert.ToInt32(tbOwnersIdDetails.Text);
                    try {
                        po = db.getOwnerById(po_id);
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show("Can't find previous owner: " + err.ToString());
                    }
                }
                else
                {
                    po = null;
                }
                animal.setOwner(po);

                if (animal.GetType() == typeof(Dog))
                {
                    Dog dog = (Dog)animal;
                    dog.setLastWalked(dtpLastWalkedDetails.Value);
                }
                else if (animal.GetType() == typeof(Cat))
                {
                    Cat cat = (Cat)animal;
                    cat.setExtra(tbExtraDetails.Text);
                }
                db.updateAnimal(animal);
                MessageBox.Show("Animal successfully updated");
                AnmDetailsPanel.Hide();
                HomePanel.Show();
            } catch (Exception er)
            {
                MessageBox.Show(er.ToString());
            }
        }