Example #1
0
 // the following code connects with the insert function in the DataAccess logic through the BusinessLogic
 private void InsertOwner(string ownername, string petname, int petage, string contactphone, string firstname, string lastname, string username, string password, int age, string email, string role)
 {
     try
     {
         using (var owners = new OwnersBusiness())
         {
             var entity = new OwnersEntity();
             entity.OwnerName    = ownername;
             entity.PetName      = petname;
             entity.PetAge       = petage;
             entity.ContactPhone = contactphone;
             entity.FirstName    = firstname;
             entity.LastName     = lastname;
             entity.Username     = username;
             entity.Password     = password;
             entity.Age          = age;
             entity.Email        = email;
             entity.Role         = role;
             var opSuccessful = owners.InsertOwner(entity);
         }
     }
     catch (Exception ex)
     {
         //Log exception error
         _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true);
     }
 }
Example #2
0
        private void Insert(string ownername, int age, string petname, string contactphone)
        {
            try
            {
                using (var owners = new OwnersBusiness())
                {
                    var entity = new OwnersEntity();
                    entity.OwnerName    = ownername;
                    entity.PetName      = petname;
                    entity.PetAge       = age;
                    entity.ContactPhone = contactphone;
                    var opSuccessful = owners.InsertOwner(entity);

                    var resultMessage = opSuccessful ? "Done Successfully" : "Error happened!";

                    MessageBox.Show(resultMessage, "Success", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                //Log exception error
                _loggingHandler.LogEntry(ExceptionHandler.GetExceptionMessageFormatted(ex), true);

                MessageBox.Show("UserInterface:OwnersForm::Insert::Error occured." +
                                Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK);
            }
        }