예제 #1
0
        static void Main(string[] args)
        {
            // Function Variables
            FlueXSystem mainSystem = new FlueXSystem();

            // Function Body
            while (mainSystem._systemState != FLUEX_SYSTEMSTATE.EXIT)
            {
                mainSystem._systemState = FLUEX_SYSTEMSTATE.RUNNING;

                mainSystem.ShowInfo();

                if (mainSystem._systemState != FLUEX_SYSTEMSTATE.RUNNING)
                {
                    // Function Temp Variables
                    string f_fileName = null;

                    // Check System State
                    switch (mainSystem._systemState)
                    {
                    case FLUEX_SYSTEMSTATE.LOADING:             // Load File
                        Console.Clear();
                        if (0 == FlueXInput.TextInput("Enter load file name without file extension:",
                                                      ref f_fileName, true))
                        {
                            continue;
                        }
                        if (!FlueXFileSystem.LoadFile(ref f_fileName, ref mainSystem))
                        {
                            continue;
                        }
                        break;

                    case FLUEX_SYSTEMSTATE.SAVING:             // Save File
                        Console.Clear();
                        if (0 == FlueXInput.TextInput("Enter save file name without file extension:",
                                                      ref f_fileName, true))
                        {
                            continue;
                        }
                        if (!FlueXFileSystem.SaveFile(ref f_fileName, ref mainSystem))
                        {
                            continue;
                        }
                        break;
                    }
                }
            }
        }
예제 #2
0
        public bool DeleteElement()
        {
            // Function Variables
            int f_number = 0;

            // Function Body
            if (0 == FlueXInput.TextInput("\nID of the deleted task", ref f_number, _listTask.Count, true, false, 1))
            {
                return(false);
            }

            _listTask[f_number - 1]._user.DeleteTaskByID(_listTask[f_number - 1]._id);
            _listTask[f_number - 1]._project.DeleteTaskByID(_listTask[f_number - 1]._id);
            _listTask.RemoveAt(f_number - 1);

            // Successful Return Value
            return(true);
        }
예제 #3
0
        public bool AddElement()
        {
            // Function Variables
            string f_name = null;

            // Function Body
            Console.Clear();
            Console.WriteLine("\tAdding new project");

            if (0 == FlueXInput.TextInput("Project name", ref f_name, true))
            {
                return(false);
            }

            _listProject.Add(new FlueXProject(ref f_name));

            // Successful Return Value
            return(true);
        }
예제 #4
0
        public bool DeleteElement()
        {
            // Function Variables
            int f_number = 0;

            // Function Body
            while (true)
            {
                if (0 == FlueXInput.TextInput("\nID of the deleted project", ref f_number, _listProject.Count, true, false, 1))
                {
                    return(false);
                }
                else if (_listProject[f_number - 1]._listTask.Count > 0)
                {
                    Console.WriteLine("ERROR: This project has tasks!");
                    continue;
                }
                _listProject.RemoveAt(f_number - 1);
                break;
            }

            // Successful return value
            return(true);
        }
예제 #5
0
        // Class Methods::Create
        bool CreateTask()
        {
            // Function Variables
            int                f_num         = 0;
            FlueXProject       f_project     = null;
            FlueXUser          f_user        = null;
            string             f_topic       = null;
            string             f_type        = null;
            string             f_description = null;
            FLUEX_PRIORITITYPE f_priorType   = FLUEX_PRIORITITYPE.LOW;

            // Variables Defenition
            if (!ControlUserList(ref f_num, true))
            {
                return(false);
            }
            f_user = _systemUser._listUser[f_num - 1];

            if (!ControlProjectList(ref f_num, true))
            {
                return(false);
            }
            f_project = _systemProject._listProject[f_num - 1];

            Console.Clear();
            if (0 == FlueXInput.TextInput("Topic", ref f_topic, true))
            {
                return(false);
            }

            Console.Clear();
            if (0 == FlueXInput.TextInput("Type", ref f_type, true))
            {
                return(false);
            }

            Console.Clear();
            if (0 == FlueXInput.TextInput("Prioriti (1-3)", ref f_num, 3, true, false, 1))
            {
                return(false);
            }
            f_priorType = (FLUEX_PRIORITITYPE)f_num - 1;

            Console.Clear();
            if (0 == FlueXInput.TextInput("Description", ref f_description, true))
            {
                return(false);
            }

            // Create New Object
            _systemTask._listTask.Add(new FlueXTask(ref f_topic, ref f_type, f_priorType,
                                                    ref f_user, ref f_project, ref f_description));
            // Set Personal ID
            _systemTask._listTask[_systemTask._listTask.Count - 1]._id = _systemTask._idCounter++;

            // Add Pointers
            f_user._listTask.Add(_systemTask._listTask[_systemTask._listTask.Count - 1]);
            f_project._listTask.Add(_systemTask._listTask[_systemTask._listTask.Count - 1]);

            // Successful Return Value
            return(true);
        }
예제 #6
0
        // Class Methods
        public void ShowInfo()
        {
            // Function Attributes
            int f_num = 0;

            // Function Body
            if (!_systemTask.ShowList())        // If user doesn't have tasks
            {
                Console.WriteLine("Task list is empty.");
                FlueXInput.TextInput("1 - Create / 2 - Load / 3 - Users / 4 - Projects / 5 - Exit", ref f_num, 5);

                switch (f_num)
                {
                case 1:             // Creating New Task
                    if (!CreateTask())
                    {
                        return;
                    }
                    break;

                case 2:             // Load From File
                    _systemState = FLUEX_SYSTEMSTATE.LOADING;
                    break;

                case 3:             // User List
                    if (!ControlUserList(ref f_num))
                    {
                        return;
                    }
                    break;

                case 4:             // Project List
                    if (!ControlProjectList(ref f_num))
                    {
                        return;
                    }
                    break;

                case 5:             // Close Program
                    _systemState = FLUEX_SYSTEMSTATE.EXIT;
                    break;
                }
            }
            else         // If user has tasks
            {
                FlueXInput.TextInput("1 - Create / 2 - Delete / 3 - Load / 4 - Save / 5 - Users / 6 - Projects / 7 - Exit",
                                     ref f_num, 7);
                switch (f_num)
                {
                case 1:             // Creating New Task
                    if (!CreateTask())
                    {
                        return;
                    }
                    break;

                case 2:             // Delete Task
                    if (!_systemTask.DeleteElement())
                    {
                        return;
                    }
                    break;

                case 3:             // Load From File
                    _systemState = FLUEX_SYSTEMSTATE.LOADING;
                    break;

                case 4:             // Save File
                    _systemState = FLUEX_SYSTEMSTATE.SAVING;
                    break;

                case 5:             // User List
                    if (!ControlUserList(ref f_num))
                    {
                        return;
                    }
                    break;

                case 6:             // Project List
                    if (!ControlProjectList(ref f_num))
                    {
                        return;
                    }
                    break;

                case 7:             // Close Program
                    _systemState = FLUEX_SYSTEMSTATE.EXIT;
                    break;
                }
            }
        }
예제 #7
0
        bool ControlProjectList(ref int f_num, bool f_choise = false)
        {
            while (true)
            {
                if (!_systemProject.ShowList()) // If List is empty
                {
                    Console.WriteLine("Project List is Empty");
                    if (0 == FlueXInput.TextInput("1 - Create", ref f_num, 1, true))
                    {
                        return(false);
                    }
                    if (!_systemProject.AddElement())
                    {
                        return(false);
                    }
                    continue;
                }
                else // If List has projects
                {
                    if (f_choise)
                    {
                        if (0 == FlueXInput.TextInput("1 - Create / 2 - Delete / 3 - Select", ref f_num, 3, true))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if (0 == FlueXInput.TextInput("1 - Create / 2 - Delete", ref f_num, 3, true))
                        {
                            return(false);
                        }
                    }
                    switch (f_num)
                    {
                    case 1:
                        if (!_systemProject.AddElement())
                        {
                            return(false);
                        }
                        continue;

                    case 2:
                        if (!_systemProject.DeleteElement())
                        {
                            return(false);
                        }
                        continue;

                    case 3:
                        if (0 == FlueXInput.TextInput("\nSelect Project ID", ref f_num, _systemUser._listUser.Count, true, false))
                        {
                            return(false);
                        }
                        break;
                    }
                }
                break;
            }

            // Successful Return Value
            return(true);
        }
예제 #8
0
        // Class Methods::Control Processes
        bool ControlUserList(ref int f_num, bool f_choise = false)
        {
            //Function Body
            while (true)
            {
                if (!_systemUser.ShowList())         // If List is empty
                {
                    Console.WriteLine("User List is Empty");
                    if (0 == FlueXInput.TextInput("1 - Create", ref f_num, 1, true))
                    {
                        return(false);
                    }
                    if (!_systemUser.AddElement())
                    {
                        return(false);
                    }
                    continue;
                }
                else         // If List has objects
                {
                    if (f_choise)
                    {
                        if (0 == FlueXInput.TextInput("1 - Create / 2 - Delete / 3 - User Tasks / 4 - Select", ref f_num, 4, true))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if (0 == FlueXInput.TextInput("1 - Create / 2 - Delete / 3 - User Tasks", ref f_num, 3, true))
                        {
                            return(false);
                        }
                    }
                    switch (f_num)
                    {
                    case 1:             // Create User
                        if (!_systemUser.AddElement())
                        {
                            return(false);
                        }
                        continue;

                    case 2:             // Delete User
                        if (!_systemUser.DeleteElement())
                        {
                            return(false);
                        }
                        continue;

                    case 3:             // Check User Tasks
                        if (0 == FlueXInput.TextInput("\nSelect User ID", ref f_num, _systemUser._listUser.Count, true, false))
                        {
                            return(false);
                        }

                        if (!_systemUser._listUser[f_num - 1].ShowList())
                        {
                            Console.Write("ERROR:User doesn't have tasks!\nPress any key to return...");
                            Console.ReadKey();
                            return(false);
                        }

                        Console.Write("Press any key to return...");
                        Console.ReadKey();
                        break;

                    case 4:             // Select User to Continue
                        if (0 == FlueXInput.TextInput("\nSelect User ID", ref f_num, _systemUser._listUser.Count, true, false))
                        {
                            return(false);
                        }
                        break;
                    }
                }
                break;
            }

            // Successful Return Value
            return(true);
        }
예제 #9
0
        public bool AddElement()
        {
            // Function Variables
            FLUEX_INPUTVALUE f_inputValue = FLUEX_INPUTVALUE.CANCEL;
            string           f_name       = null;
            string           f_surname    = null;
            string           f_patronymic = null;

            //Birthday
            int f_day   = 0;
            int f_month = 0;
            int f_year  = 0;

            // Function Body
            Console.Clear();
            Console.WriteLine("\tAdding new user");

            //Input Process
            if (0 == FlueXInput.TextInput("Name", ref f_name, true))
            {
                return(false);
            }

            if (0 == FlueXInput.TextInput("Surname", ref f_surname, true))
            {
                return(false);
            }

            if (0 == FlueXInput.TextInput("Patronymic", ref f_patronymic, true, true))
            {
                return(false);
            }

            //Birthday
            while (true)              // Just for the borders
            {
                Console.WriteLine("\n\tBirthday");
                // Day
                if (0 == (f_inputValue = FlueXInput.TextInput("Day", ref f_day, 31, true, true)))
                {
                    return(false);
                }
                else if (f_inputValue == FLUEX_INPUTVALUE.SKIP)
                {
                    break;
                }
                // Month
                if (0 == (f_inputValue = FlueXInput.TextInput("Month", ref f_month, 12, true, true)))
                {
                    return(false);
                }
                else if (f_inputValue == FLUEX_INPUTVALUE.SKIP)
                {
                    f_day = 0;
                    break;
                }

                // Year
                if (0 == (f_inputValue = FlueXInput.TextInput("Year", ref f_year, 2019, true, true, 1950)))
                {
                    return(false);
                }
                else if (f_inputValue == FLUEX_INPUTVALUE.SKIP)
                {
                    f_month = f_day = 0;
                    break;
                }
                break;
            }

            // Create User Object
            _listUser.Add(new FlueXUser(ref f_name, ref f_surname, _listUser.Count + 1, f_day, f_month, f_year, ref f_patronymic));

            // Successful Return Value
            return(true);
        }