Esempio n. 1
0
        public static Customer View()
        {
            List <Customer> customers = Read.AllCustomers().OrderBy(c => c.Mail).ToList();
            Customer        customer  = new Customer();

            Application.Init();
            var top = Application.Top;

            var win = new Window(new Rect(0, 0, top.Frame.Width, top.Frame.Height), "Login To Existing Customer");

            top.Add(win);

            var customerIdField = new TextField(17, 2, 37, "");

            var loginBtn = new Button(5, 8, "Login")
            {
                Clicked = () =>
                {
                    if (Utilities.CheckCustomerId(customerIdField, out int customerId))
                    {
                        Application.RequestStop();
                        customer = Read.SpecificCustomer(customerId);
                    }
                    else
                    {
                        win.Add(new Label(3, 6, "Invalid Input..."));
                    }
                }
            };

            win.Add(
                new Label(3, 2, "Customer (ID): "),
                new Label(56, 2, "Customer (ID)"),
                new Label(68, 2, "Mail"),
                customerIdField,
                loginBtn
                );;

            int y = 3;

            for (int i = 0; i < customers.Count; i++)
            {
                Customer c = customers[i];
                win.Add(
                    new Label(56, y, $"{c.CustomerId}"),
                    new Label(68, y, $"{c.Mail}")
                    );
                y++;
            }
            Application.Run();
            return(customer);
        }
    }
Esempio n. 2
0
 public static bool CheckCustomerId(TextField textField, out int number)
 {
     if (int.TryParse(FieldString(textField), out int n))
     {
         number = n;
         List <Customer> customers = Read.AllCustomers();
         foreach (Customer customer in customers)
         {
             if (number == customer.CustomerId)
             {
                 return(true);
             }
         }
     }
     number = 0;
     return(false);
 }
Esempio n. 3
0
        public static void View()
        {
            List <Customer> customers = Read.AllCustomers().OrderBy(c => c.Mail).ToList();

            Application.Init();
            var top = Application.Top;

            var win = new Window(new Rect(0, 0, top.Frame.Width, top.Frame.Height), "Show Customers");

            top.Add(win);

            var continueButton = new Button(1, 1, "Continue")
            {
                Clicked = () =>
                {
                    Application.RequestStop();
                }
            };

            win.Add(
                new Label(2, 3, "ID"),
                new Label(10, 3, "Mail"),
                new Label(40, 3, "First Name"),
                new Label(65, 3, "Last Name"),
                new Label(17, 1, "--- Sorted alpfabetic by customer mail ---"),
                continueButton
                );

            int y = 4;

            for (int i = 0; i < customers.Count; i++)
            {
                Customer c = customers[i];
                win.Add(
                    new Label(2, y, $"{c.CustomerId}"),
                    new Label(10, y, $"{c.Mail}"),
                    new Label(40, y, $"{Utilities.CheckProp(c.FirstName)}"),
                    new Label(65, y, $"{Utilities.CheckProp(c.LastName)}")
                    );
                y++;
            }
            ;
            Application.Run();
        }