Beispiel #1
0
        /*
         * Pre:
         * Post: If the user has entered valid information, the new contact information is added
         *       to the database.
         *       If the add is successful, the new contacts's id number will be displayed to the user,
         *       otherwise an error message will take its place.
         */
        private void Register()
        {
            try
            {
                //if the entered information is valid, add the new contact
                if (verifyInformation())
                {
                    int    contactId, year;
                    string mtnaId;

                    //get input information
                    contactId = Convert.ToInt32(lblId.Text);
                    year      = Convert.ToInt32(ddlYear.SelectedValue);
                    mtnaId    = txtMtnaId.Text;

                    if (DbInterfaceContact.RegisterContact(contactId, year, mtnaId)) //show success message
                    {
                        showSuccessMessage("The contact was successfully registered.");

                        pnlButtons.Visible       = false;
                        pnlFullPage.Visible      = false;
                        pnlContactSearch.Visible = true;

                        clearData();
                        clearContactSearch();
                    }
                    else //show error message
                    {
                        showErrorMessage("Error: There was an error registering the contact.");
                    }
                }
            }
            catch (Exception e)
            {
                showErrorMessage("Error: There was an error registering the contact.");

                Utility.LogError("Register Contact", "Register", "", "Message: " + e.Message + "   Stack Trace: " + e.StackTrace, -1);
            }
        }