Exemple #1
0
        private void btnSaveCat_Click(object sender, EventArgs e)
        {
            lblCatID.Text = null;
            DataRow newCatRow = DM.dtCat.NewRow();

            if ((txtAddName.Text == ""))
            {
                MessageBox.Show("You must type in a Cat name", "Error");
            }
            else
            {
                try
                {
                    newCatRow["Name"]        = txtAddName.Text;
                    newCatRow["Breed"]       = txtAddBreed.Text;
                    newCatRow["Gender"]      = cboAddGender.Text;
                    newCatRow["DateOfBirth"] = dtpAddDateOfBirth.Text;
                    newCatRow["Neutered"]    = cbxAddNeutered.Checked;
                    newCatRow["OwnerID"]     = cboAddOwnerID.Text;
                    DM.dtCat.Rows.Add(newCatRow);
                    MessageBox.Show("Cat added successfully", "Success");
                    DM.UpdateCat();
                }
                catch (FormatException ex)
                {
                    MessageBox.Show("Please enter a number for cost", "Error");
                }
            }
        }
Exemple #2
0
        private void btnDeleteCat_Click(object sender, EventArgs e)
        {
            DataRow deleteCatRow = DM.dtCat.Rows[currencyManager.Position];

            DataRow[] CatRow = DM.dtVisit.Select("CatID = " + lblCatID.Text);
            if (CatRow.Length != 0)
            {
                MessageBox.Show("You may only delete cats who are not assigned visits", "Error");
            }
            else
            {
                if (MessageBox.Show("Are you sure you want to delete this record?", "Warning",
                                    MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    deleteCatRow.Delete();
                    DM.UpdateCat();
                }
            }
            return;
        }