Пример #1
0
        public static void Create()
        {
            Console.WriteLine("Vælg den kundes kundeNr du vil tilføje en bil til");
            int idChoice = Convert.ToInt32(ErrorHandling.IsNumberValid(Console.ReadLine()));

            Console.WriteLine("Indtast bilens model");
            string modelIN = ErrorHandling.BigStartLetters(ErrorHandling.IsNameValid(Console.ReadLine()));

            Console.WriteLine("Indtast bilens mærke");
            string brandIN = ErrorHandling.BigStartLetters(ErrorHandling.IsNameValid(Console.ReadLine()));

            Console.WriteLine("Hvad er bilens registrerings nummer?");
            string regIN = ErrorHandling.IsRegValid(Console.ReadLine());

            Console.WriteLine("Hvor mange km har bilen kørt?");
            int kmIN = Convert.ToInt32(ErrorHandling.IsNumberValid(Console.ReadLine()));

            Console.WriteLine("Hvilken type brandstof bruger bilen?");
            string fuelIN = ErrorHandling.IsFuelValid(Console.ReadLine());

            Console.WriteLine("Hvilket år er bilen fra?");
            int    yearIN        = Convert.ToInt32(ErrorHandling.IsNumberValid(Console.ReadLine()));
            string fullStatement = "insert into Car (id, Model, Brand, RegNr, KiloMeter, Fuel, [Year]) values ((select id from customers where id =(" + idChoice + ")),'" + modelIN + "','" + brandIN + "','" + regIN + "', " + kmIN + ", '" + fuelIN + "', " + yearIN + ")";

            SQLCon.Insert(fullStatement);
        }
Пример #2
0
        public static void Create()
        {
            Console.WriteLine("Vælg Bil du gerne vil have på værksted(RegNr)");
            string regNrIN      = ErrorHandling.IsRegValid(Console.ReadLine());
            string fullSentence = "INSERT INTO CarLog VALUES ((SELECT RegNr FROM Car WHERE RegNr = ('" + regNrIN + "')), GETDATE())";

            SQLCon.Insert(fullSentence);
        }
Пример #3
0
        public static void Delete()
        {
            Console.WriteLine("Vælg bil du vil slette(RegNr) fra værkstedet");
            string delAnswer      = ErrorHandling.IsRegValid(Console.ReadLine());
            string insertSentence = "insert into CarLibary(RegNr, VisitDate, LeftDate) Values ((select RegNr from CarLog where RegNr = ('" + delAnswer + "')), (select VisitDate from CarLog where RegNr = ('" + delAnswer + "')), GETDATE())";
            string fullSentence   = "DELETE FROM CarLog WHERE RegNr = ('" + delAnswer + "')";

            SQLCon.Insert(insertSentence);
            SQLCon.Delete(fullSentence);
        }
Пример #4
0
        public static void Create()
        {
            Console.WriteLine("Indtast kundens navn");
            string kundeIN = ErrorHandling.BigStartLetters(ErrorHandling.IsNameValid(Console.ReadLine()));

            Console.WriteLine("Adresse");
            string addIN = ErrorHandling.IsAddressValid(Console.ReadLine());

            Console.WriteLine("Indtast kundens alder");
            int    ageIN         = Convert.ToInt32(ErrorHandling.IsNumberValid(Console.ReadLine()));
            string fullStatement = "insert into customers values ('" + kundeIN + "','" + addIN + "'," + ageIN + ", getdate())";

            SQLCon.Insert(fullStatement);
        }