Ejemplo n.º 1
0
        public static void addUser()
        {
            AddInformation addInformation = new AddInformation();

            string fname;
            string lname;
            int    pNumber;

            Presentation.Adduser();

            Console.Write("Skriv in förnamn: ");
            fname = Console.ReadLine();

            Console.Write("Skriv in efternamn: ");
            lname = Console.ReadLine();

            do
            {
                Console.Write("Skriv in personnummer: ");
            } while (!int.TryParse(Console.ReadLine(), out pNumber) || pNumber < 0);


            //string addUserQuery = "INSERT INTO member (firstname, lastname, socialsecuritynumber) VALUES(" + "'" + fname + "'" + "," + "'" + lname + "'" + "," + "'" + pNumber + "'" + ")";

            string addUserQuery = "INSERT INTO member (firstname, lastname, socialsecuritynumber) VALUES ( " + "'" + fname + "'" + "," + "'" + lname + "'" + "," + "'" + pNumber + "'" + ")";


            SQLconnection.con(addUserQuery);

            Console.Clear();
            Presentation.UserIsAdded();
            Program.ContinueOnKeyPressed();
            Program.Menu();
        }
Ejemplo n.º 2
0
        public static void EditUserInfo()
        {
            AddInformation addInfo = new AddInformation();

            Presentation.EditUsers();

            ShowUser.ShowUsers();

            Console.WriteLine("Välj vem du vill editera: ");
            string userEdit = Console.ReadLine();

            Console.Write("Skriv in ett nytt förnamn: ");
            string fName = Console.ReadLine();

            Console.Write("Skriv in ett nytt efternamn: ");
            string lName = Console.ReadLine();

            Console.Write("Skriv in ett nytt  personnummer: ");
            string pNumber = Console.ReadLine();

            string editUserQuery = "UPDATE member SET firstname='" + fName + "'" + ", lastname='" + lName + "'" + ", socialsecuritynumber= '" + pNumber + "'" + " WHERE memberID='" + userEdit + "'";

            SQLconnection.addBoatconn(editUserQuery);

            Console.WriteLine("Medlemen är ändrad");
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        public static void AddBoatToMember()
        {
            AddInformation addInfo = new AddInformation();

            Presentation.EditUsers();

            Console.WriteLine("Vill du lägga till båt? J/N");
            string userInput = Console.ReadLine();

            if (userInput == "J" || userInput == "j")
            {
                ShowUser.ShowUsers();

                Console.WriteLine("Hos vem?");
                int userChoice = int.Parse(Console.ReadLine());

                Console.WriteLine("Hur lång är båten ");
                string boatLength = Console.ReadLine();

                Console.WriteLine("Vad vill du lägga till för båt?");
                Console.WriteLine("1.Segelbåt 2.Motorseglare 3.Motorbåt 4.Kajak/Kanot 5.Övrigt");
                string boatType = Console.ReadLine();


                string addUserQuery = "INSERT INTO boat (memberID, boattypeID, boatlength) VALUES ( " + "'" + userChoice + "'" + "," + "'" + boatType + "'" + "," + "'" + boatLength + "'" + ")";

                SQLconnection.addBoatconn(addUserQuery);
                Console.WriteLine("Båten tillagd");
                Console.ReadLine();

                //Skriv in "WHERE USER = userChoice för att lägga till eller ersätta en båt.
            }
        }
Ejemplo n.º 4
0
        public static void SpecificUserInfo()
        {
            AddInformation addInfo = new AddInformation();

            Console.Write("Vill du visa ytterligare information om användarna? j / n: ");
            string userChoice = (Console.ReadLine());

            if (userChoice == "j" || userChoice == "J")
            {
                int specificUser = Program.Index("Välj vem du vill visa mer information om: ");
                //int SelectedUser = int.Parse(Console.ReadLine());
                Console.WriteLine("------------------");
                Console.WriteLine("Användare");
                Console.WriteLine("------------------");
                Console.WriteLine("Förnamn: {0}", addInfo.FirstNameList[specificUser]);
                Console.WriteLine("Efteramn: {0}", addInfo.LastNameList[specificUser]);
                Console.WriteLine("Personnummer: {0}", addInfo.SocialSecurityNumber[specificUser]);
                Console.WriteLine("Medlemsnummer: {0}", addInfo.IDNumber[specificUser]);
                Console.WriteLine("Båttyp: {0}", addInfo.BoatTypeList[specificUser]);
                Console.WriteLine("Båtlängd: {0}", addInfo.BoatLengthList[specificUser]);
                Program.ContinueOnKeyPressed();
                Console.Clear();
            }
            else
            {
                Console.Clear();
                Program.Menu();
            }
        }
Ejemplo n.º 5
0
        public static void ShowCompleteUser()
        {
            AddInformation addInfo       = new AddInformation();
            string         callProcedure = "CALL `memberlist`();";

            SQLconnection.Procedure(callProcedure);
        }
Ejemplo n.º 6
0
        //Metod som används för att kontrollera att avändaren inte skriver in fel saker i programmet vid val
        public static int Index(string str)
        {
            AddInformation addInfo = new AddInformation();

            int index;

            do
            {
                Console.Write(str);
            } while (!int.TryParse(Console.ReadLine(), out index) || index < 0 || index > addInfo.FirstNameList.Count - 1);
            return(index);
        }