Esempio n. 1
0
        private void SetAdminView_AdminSet(object sender, EventArgs e)
        {
            if (e is AdminEventArgs)
            {
                AdminEventArgs              adminEventArgs    = e as AdminEventArgs;
                AccountController           accountController = (AccountController)GetControllerByName("accountController");
                Dictionary <string, string> accountInfo       = new Dictionary <string, string>()
                {
                    { "accountName", adminEventArgs.AccountName },
                    { "passwd", adminEventArgs.Passwd },
                    { "privilege", adminEventArgs.Privilege }
                };
                int returnCode = accountController.AddAccount(accountInfo);
                if (ControllerReturnCode.ACCOUNTADDACCOUNTSUCCESS != returnCode)
                {
                    int errorLevel;
                    switch (returnCode)
                    {
                    case ControllerReturnCode.ACCOUNTADDACCOUNTDUPLICATE:
                        lastError  = ErrorMessage.AcountNameExists;
                        errorLevel = ErrorLevel.ErrorLevelWarning;
                        break;

                    case ControllerReturnCode.ACCOUNTADDACCOUNTERROR:
                        lastError  = ErrorMessage.SetAdminFailed;
                        errorLevel = ErrorLevel.ErrorLevelSevere;
                        break;

                    default:
                        lastError  = ErrorMessage.SetAdminFailed;
                        errorLevel = ErrorLevel.ErrorLevelSevere;
                        break;
                    }
                    ErrorMessageView errorMessageView = new ErrorMessageView(lastError, errorLevel);
                    errorMessageView.ShowDialog();
                }
                FreeViewByName("setAdminView");
                IndexView indexView = (IndexView)GetViewByName("indexView");
                indexView.Login += IndexView_Login;
                indexView.ShowDialog();
            }
        }
Esempio n. 2
0
        public NavigationController(string databaseDriverName = "DatabaseDriver")
        {
            views       = new Dictionary <string, Form>();
            controllers = new Dictionary <string, Controller>();
            if (!InitDatabaseDriver(databaseDriverName))
            {
                ErrorMessageView errorMessageView = new ErrorMessageView(lastError, ErrorLevel.ErrorLevelSevere);
                errorMessageView.ShowDialog();
            }
            AccountController accountController = (AccountController)GetControllerByName("accountController");

            if (!accountController.IsAdminExists())
            {
                SetAdminView setAdminView = (SetAdminView)GetViewByName("setAdminView");
                setAdminView.AdminSet += SetAdminView_AdminSet;
                setAdminView.ShowDialog();
            }
            else
            {
                IndexView indexView = (IndexView)GetViewByName("indexView");
                indexView.Login += IndexView_Login;
                indexView.ShowDialog();
            }
        }