Exemple #1
0
        private void AdministratorRunEnviroment(string uCommand)
        {
            switch (uCommand)
            {
            case "create user":
                var createdUser = User.createUserByInput();
                DbTool.CreateUserToDatabase(createdUser.UserName, createdUser.PassWord, createdUser.FirstName, createdUser.LastName, createdUser.Licence);
                Console.ReadKey(); Console.Clear(); Console.Clear();
                break;

            case "send message":
                Application.EnableVisualStyles();
                Application.Run(new WindowFormSendMessage(user)); Console.Clear();
                break;

            case "end":
                Console.WriteLine("\r\nYou logged out!\r\nAplication ended");
                Environment.Exit(0); Console.Clear();
                break;

            case "edit user":
                Application.EnableVisualStyles();
                Application.Run(new WindowFormEditUser(user)); Console.Clear();
                break;

            case "help":
                user.ShowWhatAUserCanDoInTheProgram();
                Console.ReadKey(); Console.Clear();
                break;

            case "search user":
                string searchOption = Menu.SearchUserMethod(), querry = "";
                string firstName, lastName, userName, licence;
                switch (searchOption)
                {
                case "Firstname and Lastname":
                    firstName = AskFirstNameFromUserAndTakeFirstName(); lastName = AskLastNameFromUserAndTakeLastName();
                    querry    = $"SELECT* FROM USERS WHERE Firstname = '{firstName}' AND Lastname = '{lastName}'";
                    Console.WriteLine(DbTool.SearchUserProfile(querry));
                    Console.WriteLine("\r\n Press any key..."); Console.ReadKey(); Console.Clear();
                    break;

                case "Username":
                    userName = AskUserNameFromUserAndTakeUserName();
                    querry   = $"SELECT* FROM USERS WHERE Username = '******'";
                    Console.WriteLine(DbTool.SearchUserProfile(querry));
                    Console.WriteLine("\r\n Press any key..."); Console.ReadKey(); Console.Clear();
                    break;

                case "Licence":
                    Console.Write("Give licence: ");
                    licence = Console.ReadLine();
                    querry  = $"SELECT* FROM USERS WHERE Licence = '{licence}'";
                    Console.WriteLine(DbTool.SearchUserProfile(querry));
                    Console.WriteLine("\r\n Press any key..."); Console.ReadKey(); Console.Clear();
                    break;

                default:
                    querry = $"SELECT* FROM USERS";
                    Console.WriteLine(DbTool.SearchUserProfile(querry));
                    Console.WriteLine("\r\n Press any key..."); Console.ReadKey(); Console.Clear();
                    break;
                }
                break;

            case "statistics":
                Application.EnableVisualStyles();
                Application.Run(new WindowFormStatistics());
                Console.Clear();
                break;

            case "my messages":
                DbTool.ShowUserMessage(user);
                Console.WriteLine("\r\n Press any key..."); Console.ReadKey(); Console.Clear();
                break;

            case "edit message":
                Application.EnableVisualStyles();
                Application.Run(new WindowFormEditMessage(user));
                Console.Clear();
                break;
            } // end first switch
        }     // end AdministratorRunEnviroment void