public static void UpdateCustomer()
        {
            Console.Clear();
            Console.WriteLine("ClientID:");
            int clientID = int.Parse(Console.ReadLine());

            while (clientID.ToString() == "")
            {
                clientID = int.Parse(Console.ReadLine());
            }
            Console.WriteLine("Client Name:");
            string name = Console.ReadLine();

            while (name == "")
            {
                name = Console.ReadLine();
            }
            Console.WriteLine("Birth Date:");
            string birthDate = Console.ReadLine();

            Console.WriteLine("ZIP:");
            string zip = Console.ReadLine();

            while (zip == "")
            {
                zip = Console.ReadLine();
            }

            string        conString = "Data Source=DESKTOP-MJA5A7T;Initial Catalog=Car Rent;Integrated Security=True";
            SqlConnection con       = new SqlConnection(conString);

            con.Open();

            if (Register_New_Customer.ClientExist(con, clientID) && Register_New_Customer.ZipValidation(zip) && Register_New_Customer.DataValidation(birthDate))
            {
                SqlCommand addCustomer = new SqlCommand("update Customers set Name=@name, BirthDate=@birthDate, Location=@location where CostumerID=@clientID", con);
                addCustomer.Parameters.AddWithValue("@clientId", clientID);
                addCustomer.Parameters.AddWithValue("@name", name);
                addCustomer.Parameters.AddWithValue("@birthDate", birthDate);
                addCustomer.Parameters.AddWithValue("@location", zip);
                SqlDataReader reader = addCustomer.ExecuteReader();
                Program.MenuScreen();
            }
            else
            {
                Console.WriteLine("invalid data");
            }
        }
Beispiel #2
0
        public static void MenuScreen()
        {
            Console.Clear();
            Console.WriteLine("Menu Screen");
            Console.WriteLine();
            Console.WriteLine("1. Register new Car Rent");
            Console.WriteLine("2. Update Car Rent");
            Console.WriteLine("3. List Rents");
            Console.WriteLine("4. List Available Cars");
            Console.WriteLine("5. Register new Customer");
            Console.WriteLine("6. Update Customer");
            Console.WriteLine("7. List Customers");
            Console.WriteLine("8. Gold/Silver Customers");
            Console.WriteLine("9. Most Recent Rented Cars");
            Console.WriteLine("10. Most Rented Cars");
            Console.WriteLine("11. Less rented Cars");
            Console.WriteLine("12. Quit");
            Console.WriteLine();
            Console.WriteLine("Please, type the number associated with the option you want and the press ENTER");
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new MenuScreen());
            int number;

            //ConsoleKeyInfo cki= Console.ReadKey()
            try
            {
                number = int.Parse(Console.ReadLine());

                if (number < 1 || number > 12)
                {
                    Console.WriteLine("This is not a valid option");
                }
                switch (number)
                {
                case 1:
                    Register_New_Rent.RegisterNewCarRent();
                    break;

                case 2:
                    Update_Rent.UpdateCarRent();
                    break;

                case 3:
                    List_Rents.ListRents();
                    break;

                case 4:
                    List_Available_Cars.ListAvailableCars();
                    break;

                case 5:
                    Register_New_Customer.RegisterNewCustomer();
                    break;

                case 6:
                    Update_Customer.UpdateCustomer();
                    break;

                case 7:
                    List_Customers.ListCustomers();
                    break;

                case 8:
                    Golden_Silver_Customers.GoldSilverCostumers();
                    break;

                case 9:
                    Most_Recent_Rented_Cars.MostRecentRentedCars();
                    break;

                case 10:
                    Most_Less_Rented_Cars.MostRentedCars();
                    break;

                case 11:
                    Most_Less_Rented_Cars.LessRentedCars();
                    break;

                case 12:
                    Environment.Exit(0);
                    break;
                }
            }
            catch (FormatException)
            {
                Console.WriteLine("This is not a valid option");
            }
        }