コード例 #1
0
        /// <summary>
        /// method for checking username and password and opening the windows
        /// </summary>
        private void SaveExecute()
        {
            string adminType = AdminType(Username, UserPassword);

            if (username == "WPFMaster" && userPassword == "WPFAccess")
            {
                MasterView master = new MasterView();
                master.ShowDialog();
            }
            else if (adminType == "TEAM")
            {
                TeamAdminView team = new TeamAdminView();
                team.ShowDialog();
            }
            else if (adminType == "SYSTEM")
            {
                SystemAdminView system = new SystemAdminView();
                system.ShowDialog();
            }
            else if (adminType == "LOCAL")
            {
                LocalAdminView local = new LocalAdminView();
                local.ShowDialog();
            }
            else if (IsManager(username, userPassword))
            {
                try
                {
                    using (CompanyDBEntities context = new CompanyDBEntities())
                    {
                        // getting the manager for later actions with projects
                        tblUser user = (from x in context.tblUsers where x.Username == username select x).First();
                        manager = (from y in context.tblManagers where y.UserID == user.UserID select y).First();

                        ManagerView managerView = new ManagerView(manager);
                        managerView.ShowDialog();
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
                }
            }
            else
            {
                MessageBox.Show("Wrong username or password, please try again.");
            }
        }