示例#1
0
        private void ShowMainMenu(View.Console view, Model.MemberRegister register)
        {
            while (true)
            {
                view.ShowMenu(View.Console.MenuEvent.MainMenu, null);
                switch (view.GetMenuSelection())
                {
                    case View.Console.MenuEvent.AddNewMember:
                        HandleEventNewMember(view, register);
                        break;
                    case View.Console.MenuEvent.MemberListMenu:
                        HandleEventShowMemberListMenu(view, register);
                        break;
                    case View.Console.MenuEvent.MemberInfoMenu:
                        view.ShowInputInfo(View.Console.MenuEvent.MemberInfoMenu, null);
                        int id = view.InputMemberID();
                        if (id == 0)
                            break;

                        try
                        {
                            Model.Member m = register.GetMember(id);
                            HandleEventShowMemberInfoMenu(m, view, register);
                        }
                        catch (ArgumentException)
                        {
                            view.ShowErrorMessage(View.Console.Error.NoMemberWithId, id.ToString());
                            view.Wait();
                        }
                        break;
                    case View.Console.MenuEvent.DeleteMember:
                        view.ShowInputInfo(View.Console.MenuEvent.DeleteMember, null);
                        id = view.InputMemberID();
                        if (id == 0)
                            break;

                        try
                        {
                            register.DeleteMember(register.GetMember(id));
                            register.Save();
                        }
                        catch (ArgumentException)
                        {
                            view.ShowErrorMessage(View.Console.Error.NoMemberWithId, id.ToString());
                            view.Wait();
                        }
                        break;
                    case View.Console.MenuEvent.Exit:
                        return;
                }
            }
        }