コード例 #1
0
ファイル: Program.cs プロジェクト: pmdmartins21/Supermercado
        public static void MostrarPrincipal(Employee activeuser) //Menu principal
        {
            int menuOption2;

            EmployeeList employeelist = new EmployeeList();
            InvoiceList  invoiceList  = new InvoiceList();

            do
            {
                employeelist.LerFicheiro();
                invoiceList = GravadorFaturas.ReadInvoiceList();
                Console.WriteLine("************SUPERMERCADO BINHAS ONTE***************");
                Console.WriteLine("**                                              **");
                Console.WriteLine("**                  Bem-vindo/a!                **");
                Console.WriteLine("**                                              **");
                Console.WriteLine("**\t" + DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm") + "\t\t**");
                Console.WriteLine("**************************************************\n");
                Console.WriteLine("1- Vendas\n");
                Console.WriteLine("2- Stock\n");
                Console.WriteLine("3- Funcionarios\n");
                Console.WriteLine("4- Listagem de Faturas\n");
                //Console.WriteLine("5- Remover Faturas\n"); Legalmente nao se pode remover faturas, apenas inserimos aqui esta opçao para remover faturas teste
                Console.WriteLine("--------------------------------------------------");
                Console.WriteLine("0- Sair");

                while (int.TryParse(Console.ReadLine(), out menuOption2) == false)
                {
                    Console.WriteLine("Opçao errada");
                }

                Console.Clear();

                switch (menuOption2)
                {
                case 0:
                    break;

                case 1:
                    if (activeuser.EmployeeRole.Equals(EmployeeRole.Repositor))
                    {
                        Console.WriteLine("Lamento, não tem permissão para esta opção!");
                        break;
                    }
                    Invoice newInvoice = (MenuVendas(activeuser, invoiceList));
                    if (newInvoice.InvoiceProducts.Count > 0)
                    {
                        invoiceList.AddInvoice(newInvoice);
                        GravadorFaturas.SaveInvoiceList(invoiceList);
                    }

                    break;

                case 2:
                    if (activeuser.EmployeeRole.Equals(EmployeeRole.Caixa))
                    {
                        Console.WriteLine("Lamento, não tem permissão para esta opção!");
                        break;
                    }
                    MenuStock(activeuser);
                    break;

                case 3:
                    if (activeuser.EmployeeRole.Equals(EmployeeRole.Gerente))
                    {
                        MenuFuncionarios(activeuser);
                        break;
                    }
                    Console.WriteLine("Lamento, não tem permissão para esta opção!");
                    break;

                case 4:
                    Table.PrintLine();
                    Table.PrintRow("LISTAGEM DE FATURAS");
                    Table.PrintLine();
                    invoiceList.ToString();

                    //invoiceList.ListInvoiceList(invoiceList);
                    break;

                case 5:
                /*
                 * invoiceList.ListInvoiceList(invoiceList);
                 * invoiceList.RemoveInvoiceFromList(invoiceList);
                 * GravadorFaturas.SaveInvoiceList(invoiceList);
                 * break;
                 */
                default:
                    Console.WriteLine("Escolheu uma opção inválida");
                    break;
                }
                Console.ReadKey();
                Console.Clear();
            } while (menuOption2 != 0);
        }