public static void AddCar() { Console.WriteLine("Tilføj en bil pr kunde (Kundes Id)"); int CostumerId = 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 fullSentence = "insert into Car (id, Model, Brand, RegNr, KiloMeter, Fuel, [Year]) values ((select id from customers where id =(" + CostumerId + ")),'" + modelIN + "','" + brandIN + "','" + regIN + "', " + kmIN + ", '" + fuelIN + "', " + yearIN + ")"; SQLCon.Update(fullSentence); }
public static void Update() { Console.WriteLine("Vælg bil du vil rette (Reg-Nr)"); string chooseCar = ErrorHandling.IsRegValid(Console.ReadLine()); Console.WriteLine("Vælg hvad du vil rette"); Console.WriteLine("1. Km"); Console.WriteLine("2. Fuel"); string fullSentence; int answerTwo = Convert.ToInt32(ErrorHandling.IsNumberValid(Console.ReadLine())); switch (answerTwo) { case 1: Console.Write("Skriv din ændring: "); int retKM = Convert.ToInt32(ErrorHandling.IsNumberValid(Console.ReadLine())); fullSentence = "update car set KiloMeter = ('" + retKM + "') where RegNr = ('" + chooseCar + "')"; SQLCon.Update(fullSentence); break; case 2: Console.Write("Skriv din ændring: "); string retFuel = ErrorHandling.IsFuelValid(Console.ReadLine()); fullSentence = "update car set Fuel = ('" + retFuel + "') where RegNr = ('" + chooseCar + "')"; SQLCon.Update(fullSentence); break; } }
public static void Update() { Console.WriteLine("Vælg værkstedsbesøg du gerne vil rette (RegNr)"); string chooseCarLog = ErrorHandling.IsRegValid(Console.ReadLine()); string fullSentence; int answerTwo = Convert.ToInt32(ErrorHandling.IsNumberValid(Console.ReadLine())); Console.WriteLine("Skriv din ændring"); string retRegNr = ErrorHandling.IsRegValid(Console.ReadLine()); fullSentence = "UPDATE CarLog SET RegNr = ('" + retRegNr + "') WHERE RegNr = ('" + chooseCarLog + "')"; SQLCon.Update(fullSentence); }
public static void Update() { Console.WriteLine("Vælg kunde du vil rette (Kunde id)"); int chooseCustomer = Convert.ToInt32(ErrorHandling.IsNumberValid(Console.ReadLine())); Console.WriteLine("Vælg hvad du vil rette"); Console.WriteLine("1. Navn"); Console.WriteLine("2. Adresse"); Console.WriteLine("3. Alder"); string fullSentence; int answerTwo = Convert.ToInt32(ErrorHandling.IsNumberValid(Console.ReadLine())); switch (answerTwo) { case 1: Console.Write("Skriv din ændring: "); string retNavn = ErrorHandling.BigStartLetters(ErrorHandling.IsNameValid(Console.ReadLine())); fullSentence = "update customers set navn = ('" + retNavn + "') where id = ('" + chooseCustomer + "')"; SQLCon.Update(fullSentence); break; case 2: Console.Write("Skriv din ændring: "); string retAdr = ErrorHandling.IsAddressValid(Console.ReadLine()); fullSentence = "update customers set adr = ('" + retAdr + "') where id = ('" + chooseCustomer + "')"; SQLCon.Update(fullSentence); break; case 3: Console.Write("Skriv din ændring: "); int retAlder = Convert.ToInt32(ErrorHandling.IsNumberValid(Console.ReadLine())); fullSentence = "update customers set alder = ('" + retAlder + "') where id = ('" + chooseCustomer + "')"; SQLCon.Update(fullSentence); break; } }