Exemple #1
0
        static void Main(string[] args)
        {
            window = new ConsoleWindowFrame
            {
                Width  = 70,
                Height = 20
            };

            window.StartRender();

            try
            {
                remoteName = "localhost";
                remotePort = 5150;
                running    = true;
                client     = null;

                string input = window.GetInputWithQuestion("Enter your name: ");

                client = new Client(input);

                while (running)
                {
                    try
                    {
                        string message = window.GetInputWithQuestion("Skriv ett meddelande: ");

                        DecodeMessage(message);
                    }
                    catch (Exception e)
                    {
                    }
                }

                client.Close();
            }
            catch (Exception e)
            {
                ErrorMessage(e.Message);
            }

            window.Abort();

            PressAnyKey();
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            MainWindow.Width  = 115;
            MainWindow.Height = 25;

            MainWindow.StartRender();

            string connectionString;
            var    input = MainWindow.GetInputWithQuestion("Vill du koppla upp mot Azure?").ToLower();

            if (input == "ja" ||
                input == "azure")
            {
                connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Kundregister"]
                                   .ConnectionString;
            }
            else
            {
                connectionString = "Server = localdb/mssqllocaldb; Database=KundregisterAndreasOVictor; Trusted Connection = true; UID = CustomerWriter; PWD = 1234test_!";
            }


            _customerDbManager =
                new CustomerDbManager(connectionString);

            _productDbManager =
                new ProductDbManager(connectionString);


            var customerGui = new CustomerGui(MainWindow);
            var productGui  = new ProductGui(MainWindow);

            var running = true;

            var mainQuestion = new Question("Vad vill du göra", "Administrera en kund,Kund", "Administrera en produkt,Produkt", "Rensa skärmen,CLS", "Avsluta,Quit,Exit");

            while (running)
            {
                try
                {
                    input = MainWindow.GetInputWithQuestion(mainQuestion);

                    if (input == "Administrera en kund")
                    {
                        customerGui.Administrate();
                    }
                    else if (input == "Administrera en produkt")
                    {
                        productGui.Administrate();
                    }
                    else if (input == "Rensa skärmen")
                    {
                        MainWindow.Clear();
                    }
                    else if (input == "Avsluta")
                    {
                        running = false;
                    }
                    MainWindow.AddSeparator();
                }
                catch (Exception e)
                {
                    MainWindow.ErrorMessage(e.Message);
                }
            }

            MainWindow.PressAnyKeyToContinue();

            MainWindow.Abort();
        }