Пример #1
0
        public static void ShowCustomer()
        {
            Console.WriteLine("Hvilken kunde vil du se? (Vælg kunde nummer)");
            int CustomerNumber = Convert.ToInt32(Console.ReadLine());

            SQLCon.SelectCustomer("Select * from customer where id =(" + CustomerNumber + ")");
        }
Пример #2
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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        public static void WatchLibrary()
        {
            Console.WriteLine("Vælg bilens RegNr for at se alle bilens værkstedsbesøg");
            string chooseCar = ErrorHandling.IsRegValid(Console.ReadLine());

            SQLCon.SelectLibrary("select * from CarLibrary where RegNr = ('" + chooseCar + "')");
        }
Пример #5
0
        public static void WatchLog()
        {
            Console.WriteLine("Vælg bilens Registreringsnummer for at få vist værkstedsbesøg");
            string chooseCar = ErrorHandling.IsRegValid(Console.ReadLine());

            SQLCon.SelectLog("Select * from CarLog where RegNr = ('" + chooseCar + "')");
        }
Пример #6
0
        public static void ViewCarSorted()
        {
            Console.WriteLine("Vælg den bil du vil se 'RegNr'");
            string CarRegNr = Console.ReadLine();

            SQLCon.SelectCar("select * from Car where RegNr = ('" + CarRegNr + "')");
        }
Пример #7
0
        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;
            }
        }
Пример #8
0
        public static void Delete()
        {
            Console.WriteLine("Vælg kunde du vil slette (Kundeid)");
            int    delAnswer    = Convert.ToInt32(ErrorHandling.IsNumberValid(Console.ReadLine()));
            string fullSentence = "delete from customers where id = ('" + delAnswer + "')";

            SQLCon.Delete(fullSentence);
        }
Пример #9
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);
        }
Пример #10
0
        public static void Delete()
        {
            Console.WriteLine("Vælg kunde du vil slette bil (Regnr)");
            string delAnswer    = ErrorHandling.IsRegValid(Console.ReadLine());
            string fullSentence = "delete from car where RegNr = ('" + delAnswer + "')";

            SQLCon.Delete(fullSentence);
        }
Пример #11
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);
        }
Пример #12
0
        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);
        }
Пример #13
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);
        }
Пример #14
0
        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;
            }
        }
Пример #15
0
 public static void ChooseAllWatchLibrary()
 {
     Console.WriteLine("En liste over alle biler der har været på værksted");
     SQLCon.SelectLibrary("select * from CarLibrary");
 }
Пример #16
0
 public static void ChooseAllWatchLog()
 {
     Console.WriteLine("Liste over alle biler på værkstedet");
     Console.WriteLine();
     SQLCon.SelectLog("Select * from CarLog");
 }
Пример #17
0
 public static void WatchTabel()
 {
     SQLCon.SelectCustomer("Select * from customers order by navn asc");
     SQLCon.SelectCar("Select * from Car order by Brand, Model asc");
 }