private void SaveExecute()
 {
     try
     {
         using (HotelEntities db = new HotelEntities())
         {
             db.tblManagers.Add(Manager);
             db.SaveChanges();
         }
         MessageBox.Show("Manager Created Successfully!");
         main.Close();
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
 }
        /// <summary>
        /// method for saving data to the database
        /// </summary>
        private void SaveExecute()
        {
            try
            {
                using (CompanyDBEntities context = new CompanyDBEntities())
                {
                    tblUser    newUser    = new tblUser();
                    tblManager newManager = new tblManager();

                    // inputs and validations
                    if (user.FirstName.All(Char.IsLetter))
                    {
                        newUser.FirstName = user.FirstName;
                    }
                    else
                    {
                        MessageBox.Show("Wrong First Name input, please try again.");
                    }

                    if (user.LastName.All(Char.IsLetter))
                    {
                        newUser.LastName = user.LastName;
                    }
                    else
                    {
                        MessageBox.Show("Wrong Last Name input, please try again.");
                    }

                    newUser.JMBG = user.JMBG;

                    // JMBG validation
                    if (JmbgInputValidation(newUser.JMBG) == false)
                    {
                        MessageBox.Show("Wrong input, please check your JMBG (13 characters).");
                    }

                    string sex = user.Gender.ToUpper();

                    // gender validation
                    if ((sex == "M" || sex == "Z" || sex == "X" || sex == "N"))
                    {
                        newUser.Gender = sex;
                    }
                    else
                    {
                        MessageBox.Show("Wrong Gender input, please enter M, Z, X or N.");
                    }

                    user.UserID = newUser.UserID;

                    newUser.Residence = user.Residence;

                    string marriage = user.MarriageStatus.ToUpper();

                    if ((marriage == "MARRIED" || marriage == "UNMARRIED" || marriage == "DIVORCED"))
                    {
                        newUser.MarriageStatus = marriage;
                    }
                    else
                    {
                        MessageBox.Show("Wrong Marriage status input. Please try again.\n (Married/Unmarried/Divorced)");
                    }

                    newUser.Username     = user.Username;
                    newUser.UserPassword = user.UserPassword;

                    newManager.Email = manager.Email;
                    string reservedPassword = manager.ReservedPassword;

                    if (reservedPassword.Length >= 5)
                    {
                        newManager.ReservedPassword = reservedPassword + "WPF";
                    }
                    else
                    {
                        MessageBox.Show("Wrong Reserved Password input. Please try again.\n (Minimum 5 characters)");
                    }

                    newManager.SuccessfulProjects = manager.SuccessfulProjects;
                    newManager.OfficeNumber       = manager.OfficeNumber;
                    newManager.ManagerID          = manager.ManagerID;
                    newManager.UserID             = newUser.UserID;

                    // saving data
                    context.tblUsers.Add(newUser);
                    context.tblManagers.Add(newManager);
                    context.SaveChanges();

                    MessageBox.Show("The manager created successfully.");

                    // logging actions
                    FileActions.FileActions.Instance.Adding(FileActions.FileActions.path, FileActions.FileActions.actions, "user", newUser.FirstName + " " + newUser.LastName);
                    FileActions.FileActions.Instance.Adding(FileActions.FileActions.path, FileActions.FileActions.actions, "manager", newUser.FirstName + " " + newUser.LastName);
                }
                createManagerView.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Wrong inputs, please check your inputs or try again.");
            }
        }