public static void visBesøg() { Console.Clear(); Forside.DisplayTop(); Console.WriteLine("Værkstedslog:\n"); SQL.SelectBesøg("select * from Besøg"); Console.ReadKey(); }
public static void opdaterBesøg() { Console.Clear(); Forside.DisplayTop(); Console.WriteLine("Værksteds ophold:\n"); SQL.SelectBesøg("select * from Besøg"); Console.Write("\nIndtast ID på opholdet du vil redigere: "); int idValg = 0; try { idValg = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(); SQL.SelectBesøg("select * from Besøg where FakturaNr = " + idValg + ""); Console.WriteLine(); Console.WriteLine("Indtast nummeret på den information du vil opdatere:"); Console.WriteLine(); Console.WriteLine("1. BilId"); Console.WriteLine("2. Udført\n"); var info = ""; ConsoleKeyInfo nummer = Console.ReadKey(true); switch (nummer.Key) { case ConsoleKey.D1: Console.Write("Indtast et nyt bil ID: "); info = Console.ReadLine(); SQL.Change("update Besøg set BilId = '" + info + "' where FakturaNr = " + idValg + ""); break; case ConsoleKey.D2: Console.Write("Indtast nyt udført arbejde: "); info = Console.ReadLine(); SQL.Change("update Besøg set Udført = '" + info + "' where FakturaNr = " + idValg + ""); break; default: Console.WriteLine("Du må kun vælge et nummer fra listen."); break; } } catch (Exception) { } }
public static void sletBil() { Console.Clear(); Forside.DisplayTop(); Console.WriteLine("Bil liste:\n"); SQL.SelectFewBil("select * from Bil"); Console.WriteLine(); Console.Write("Indtast ID på bilen der skal slettes: "); int idValg = 0; try { idValg = Convert.ToInt32(Console.ReadLine()); } catch (Exception) { } SQL.Change("delete from Bil where BilId = " + idValg + ""); }
public static void visKunde() { int idValg = 0; Console.Clear(); Forside.DisplayTop(); Console.WriteLine("Kundekartotek:\n"); SQL.SelectFewKunde("select * from Kunder order by Efternavn"); Console.Write("\nIndtast ID på den kunde du vil se: "); try { idValg = Convert.ToInt32(Console.ReadLine()); } catch (FormatException) { Console.WriteLine("Du må kun indtaste tal. Tryk på en tast."); } SQL.SelectAllDataKunde("select * from Kunder where KundeId = " + idValg + ""); SQL.SelectFewBil("select * from Bil where KundeId = " + idValg + ""); Console.ReadKey(); }
public static void visBil() { int idValg = 0; Console.Clear(); Forside.DisplayTop(); Console.WriteLine("Bilkartotek:\n"); SQL.SelectFewBil("select * from Bil"); Console.Write("\nIndtast ID på den bil du vil se: "); try { idValg = Convert.ToInt32(Console.ReadLine()); } catch (FormatException) { Console.WriteLine("Du må kun indtaste tal. Tryk på en tast."); } SQL.SelectAllDataBil("select * from Bil where BilId = " + idValg + ""); SQL.SelectBesøg("select * from Besøg where BilId = " + idValg + ""); Console.ReadKey(); }
public void opretKunde() { Console.Clear(); Forside.DisplayTop(); Console.WriteLine("Indtast Navn: "); Console.WriteLine("Indtast Efternavn: "); Console.WriteLine("Indtast Adresse: "); Console.WriteLine("Indtast Postnummer: "); Console.WriteLine("Indtast Telefonnummer: "); Console.WriteLine("Indtast E-Mail adresse: "); Console.SetCursorPosition(50, 7); Navn = Console.ReadLine(); erDerTal = Navn.Any(c => char.IsDigit(c)); while (erDerTal) { Console.SetCursorPosition(0, 7); Console.Write(" "); Console.SetCursorPosition(0, 7); Console.WriteLine("Navn må ikke indeholde tal, prøv igen:"); Console.SetCursorPosition(50, 7); Navn = Console.ReadLine(); erDerTal = Navn.Any(c => char.IsDigit(c)); } Console.SetCursorPosition(0, 7); Console.Write(" "); Console.SetCursorPosition(0, 7); Console.WriteLine("Navn:"); Console.SetCursorPosition(50, 7); Console.WriteLine(Navn); Console.SetCursorPosition(50, 8); Efternavn = Console.ReadLine(); erDerTal = Efternavn.Any(c => char.IsDigit(c)); while (erDerTal) { Console.SetCursorPosition(0, 8); Console.Write(" "); Console.SetCursorPosition(0, 8); Console.WriteLine("Efternavn må ikke indeholde tal, prøv igen:"); Console.SetCursorPosition(50, 8); Efternavn = Console.ReadLine(); erDerTal = Efternavn.Any(c => char.IsDigit(c)); } Console.SetCursorPosition(0, 8); Console.Write(" "); Console.SetCursorPosition(0, 8); Console.WriteLine("Efternavn:"); Console.SetCursorPosition(50, 8); Console.WriteLine(Efternavn); Console.SetCursorPosition(50, 9); Adr = Console.ReadLine(); Console.SetCursorPosition(0, 9); Console.Write(" "); Console.SetCursorPosition(0, 9); Console.WriteLine("Adresse:"); Console.SetCursorPosition(50, 9); Console.WriteLine(Adr); Console.SetCursorPosition(50, 10); bool PostNrLoop = true; while (PostNrLoop) { try { Postnr = Convert.ToInt32(Console.ReadLine()); if (Postnr.ToString().Length != 4) { Console.SetCursorPosition(0, 10); Console.Write(" "); Console.SetCursorPosition(0, 10); Console.WriteLine("Et postnummer er altid 4 cifre, prøv igen:"); Console.SetCursorPosition(50, 10); } else { PostNrLoop = false; } } catch (Exception) { Console.SetCursorPosition(0, 10); Console.Write(" "); Console.SetCursorPosition(0, 10); Console.WriteLine("Et postnummer er altid et tal med 4 cifre, prøv igen:"); Console.SetCursorPosition(50, 10); } } Console.SetCursorPosition(0, 10); Console.Write(" "); Console.SetCursorPosition(0, 10); Console.WriteLine("Postnummer:"); Console.SetCursorPosition(50, 10); Console.WriteLine(Postnr); Console.SetCursorPosition(50, 11); bool TlfLoop = true; while (TlfLoop) { try { Tlf = Convert.ToInt32(Console.ReadLine()); if (Tlf.ToString().Length != 8) { Console.SetCursorPosition(0, 11); Console.Write(" "); Console.SetCursorPosition(0, 11); Console.WriteLine("Et telefonnummer er altid 8 cifre:"); Console.SetCursorPosition(50, 11); } else { TlfLoop = false; } } catch (Exception) { Console.SetCursorPosition(0, 11); Console.Write(" "); Console.SetCursorPosition(0, 11); Console.WriteLine("Et telefonnummer er altid tal med 8 cifre:"); Console.SetCursorPosition(50, 11); } } Console.SetCursorPosition(0, 11); Console.Write(" "); Console.SetCursorPosition(0, 11); Console.WriteLine("Telefonnummer:"); Console.SetCursorPosition(50, 11); Console.WriteLine(Tlf); Console.SetCursorPosition(50, 12); Email = Console.ReadLine(); while (!IsValidEmail(Email)) { Console.SetCursorPosition(0, 12); Console.Write(" "); Console.SetCursorPosition(0, 12); Console.WriteLine("Ugyldig indtastning, prøv igen:"); Console.SetCursorPosition(50, 12); Email = Console.ReadLine(); } Console.SetCursorPosition(0, 12); Console.Write(" "); Console.SetCursorPosition(0, 12); Console.WriteLine("Email adresse:"); Console.SetCursorPosition(50, 12); Console.WriteLine(Email); OpretDato = DateTime.Now.ToString("d"); SQL.Change("insert into Kunder values('" + Navn + "', '" + Efternavn + "', '" + Adr + "', " + Postnr + ", " + Tlf + ", '" + Email + "', '" + OpretDato + "')"); kunder.Add(new Kunde(Navn, Efternavn, Adr, Postnr, Tlf, Email, OpretDato)); }
public static void opdaterKunde() { Console.Clear(); Forside.DisplayTop(); Console.WriteLine("Kundeliste:\n"); SQL.SelectFewKunde("select * from Kunder"); Console.Write("\nIndtast ID på kunden du vil redigere: "); int idValg = 0; try { idValg = Convert.ToInt32(Console.ReadLine()); SQL.SelectAllDataKunde("select * from Kunder where KundeId = " + idValg + ""); Console.WriteLine("Indtast nummeret på den information du vil opdatere:"); Console.WriteLine("1. Navn"); Console.WriteLine("2. Efternavn"); Console.WriteLine("3. Adresse"); Console.WriteLine("4. Postnummer"); Console.WriteLine("5. Telefonnummer"); Console.WriteLine("6. E-Mail adresse\n"); var info = ""; bool erDerTal; ConsoleKeyInfo nummer = Console.ReadKey(true); switch (nummer.Key) { case ConsoleKey.D1: Console.Write("Indtast et nyt navn: "); info = Console.ReadLine(); erDerTal = info.Any(c => char.IsDigit(c)); while (erDerTal) { Console.WriteLine("Navn kan ikke indeholde tal, prøv igen"); Console.Write("Indtast et nyt navn: "); info = Console.ReadLine(); erDerTal = info.Any(c => char.IsDigit(c)); } SQL.Change("update Kunder set Navn = '" + info + "' where KundeId = " + idValg + ""); break; case ConsoleKey.D2: Console.Write("Indtast et nyt efternavn: "); info = Console.ReadLine(); erDerTal = info.Any(c => char.IsDigit(c)); while (erDerTal) { Console.WriteLine("Navn kan ikke indeholde tal, prøv igen"); Console.Write("Indtast et nyt navn: "); info = Console.ReadLine(); erDerTal = info.Any(c => char.IsDigit(c)); } SQL.Change("update Kunder set Efternavn = '" + info + "' where KundeId = " + idValg + ""); break; case ConsoleKey.D3: Console.Write("Indtast en ny adresse: "); info = Console.ReadLine(); SQL.Change("update Kunder set Adresse = '" + info + "' where KundeId = " + idValg + ""); break; case ConsoleKey.D4: Console.Write("Indtast et nyt postnummer: "); bool PostNrLoop = true; while (PostNrLoop) { try { info = Console.ReadLine(); if (info.ToString().Length != 4) { Console.WriteLine("Et postnummer er altid 4 cifre, prøv igen:"); Console.Write("Indtast et nyt postnummer: "); } else { PostNrLoop = false; } } catch (Exception) { Console.WriteLine("Et postnummer er altid et tal med 4 cifre, prøv igen:"); Console.Write("Indtast et nyt postnummer: "); } } SQL.Change("update Kunder set PostNr = " + info + " where KundeId = " + idValg + ""); break; case ConsoleKey.D5: Console.Write("Indtast et nyt telefonnummer: "); bool TlfLoop = true; while (TlfLoop) { try { info = Console.ReadLine(); if (info.ToString().Length != 8) { Console.WriteLine("Et telefonnummer er altid 8 cifre:"); Console.Write("Indtast et nyt telefonnummer: "); } else { TlfLoop = false; } } catch (Exception) { Console.WriteLine("Et telefonnummer er altid tal med 8 cifre:"); Console.Write("Indtast et nyt telefonnummer: "); } } SQL.Change("update Kunder set Tlf = " + info + " where KundeId = " + idValg + ""); break; case ConsoleKey.D6: Console.Write("Indtast en ny E-Mail adresse: "); info = Console.ReadLine(); while (!IsValidEmail(info)) { Console.WriteLine("Ugyldig indtastning, prøv igen:"); Console.Write("Indtast en ny E-Mail adresse: "); info = Console.ReadLine(); } SQL.Change("update Kunder set Email = '" + info + "' where KundeId = " + idValg + ""); break; default: Console.WriteLine("Du må kun vælge et nummer fra listen."); break; } } catch (Exception) { } }
static void Main(string[] args) { Forside.Menu(); }
public void opretBesøg() { Console.Clear(); Forside.DisplayTop(); Console.WriteLine("Indtast Bil ID: "); Console.WriteLine("Indtast udført arbejde: "); Console.SetCursorPosition(50, 7); BilId = 0; bool loop = true; int idFindes = 0; while (loop) { try { BilId = Convert.ToInt32(Console.ReadLine()); foreach (DataRow item in SQL.Liste("Select BilId from Bil").Rows) { if (BilId == Convert.ToInt32(item["BilId"])) { idFindes = Convert.ToInt32(item["BilId"]); } } if (BilId == idFindes) { loop = false; } else { Console.SetCursorPosition(0, 7); Console.Write(" "); Console.SetCursorPosition(0, 7); Console.WriteLine("Ugyldigt BilId, prøv igen:"); Console.SetCursorPosition(50, 7); } } catch (FormatException) { Console.SetCursorPosition(0, 7); Console.Write(" "); Console.SetCursorPosition(0, 7); Console.WriteLine("BilId skal være et tal:"); Console.SetCursorPosition(50, 7); } catch (OverflowException) { Console.SetCursorPosition(0, 7); Console.Write(" "); Console.SetCursorPosition(0, 7); Console.WriteLine("Tallet er for stort, prøv igen:"); Console.SetCursorPosition(50, 7); } } Console.SetCursorPosition(0, 7); Console.Write(" "); Console.SetCursorPosition(0, 7); Console.WriteLine("BilId:"); Console.SetCursorPosition(50, 7); Console.WriteLine(BilId); Console.SetCursorPosition(50, 8); Udført = Console.ReadLine(); Dato = DateTime.Now; SQL.Change("insert into Besøg values(" + BilId + ", '" + Udført + "', '" + Dato + "')"); visits.Add(new Besøg(BilId, Dato, Udført)); }
public void opretBil() { Console.Clear(); Forside.DisplayTop(); Console.WriteLine("Indtast KundeID: "); Console.WriteLine("Indtast Mærke: "); Console.WriteLine("Indtast Model: "); Console.WriteLine("Indtast Årgang: "); Console.WriteLine("Indtast KmKørt: "); Console.WriteLine("Indtast Brændstof: "); Console.WriteLine("Indtast RegistreringsNr: "); Console.SetCursorPosition(50, 7); bool loop = true; int idFindes = 0; while (loop) { try { KundeId = Convert.ToInt32(Console.ReadLine()); foreach (DataRow item in SQL.Liste("Select KundeId from Kunder").Rows) { if (KundeId == Convert.ToInt32(item["KundeId"])) { idFindes = Convert.ToInt32(item["KundeId"]); } } if (KundeId == idFindes) { loop = false; } else { Console.SetCursorPosition(0, 7); Console.Write(" "); Console.SetCursorPosition(0, 7); Console.WriteLine("Ugyldigt kundeId, prøv igen:"); Console.SetCursorPosition(50, 7); } } catch (FormatException) { Console.SetCursorPosition(0, 7); Console.Write(" "); Console.SetCursorPosition(0, 7); Console.WriteLine("KundeId skal være et tal:"); Console.SetCursorPosition(50, 7); } catch (OverflowException) { Console.SetCursorPosition(0, 7); Console.Write(" "); Console.SetCursorPosition(0, 7); Console.WriteLine("Tallet er for stort, prøv igen:"); Console.SetCursorPosition(50, 7); } } Console.SetCursorPosition(0, 7); Console.Write(" "); Console.SetCursorPosition(0, 7); Console.WriteLine("KundeId:"); Console.SetCursorPosition(50, 7); Console.WriteLine(KundeId); Console.SetCursorPosition(50, 8); Mærke = Console.ReadLine(); Console.SetCursorPosition(0, 8); Console.Write(" "); Console.SetCursorPosition(0, 8); Console.WriteLine("Mærke:"); Console.SetCursorPosition(50, 8); Console.WriteLine(Mærke); Console.SetCursorPosition(50, 9); Model = Console.ReadLine(); Console.SetCursorPosition(0, 9); Console.Write(" "); Console.SetCursorPosition(0, 9); Console.WriteLine("Model:"); Console.SetCursorPosition(50, 9); Console.WriteLine(Model); Console.SetCursorPosition(50, 10); while (Årgang == 0) { try { Årgang = Convert.ToInt32(Console.ReadLine()); if (Årgang < 1900 || Årgang > 2019) { Console.SetCursorPosition(0, 10); Console.Write(" "); Console.SetCursorPosition(0, 10); Console.WriteLine("Indtast en gyldig årgang:"); Console.SetCursorPosition(50, 10); Årgang = 0; } } catch (FormatException) { Console.SetCursorPosition(0, 10); Console.Write(" "); Console.SetCursorPosition(0, 10); Console.WriteLine("En årgang indeholder kun tal, prøv igen:"); Console.SetCursorPosition(50, 10); Console.ReadKey(true); } } Console.SetCursorPosition(0, 10); Console.Write(" "); Console.SetCursorPosition(0, 10); Console.WriteLine("Årgang:"); Console.SetCursorPosition(50, 10); Console.WriteLine(Årgang); Console.SetCursorPosition(50, 11); while (KmKørt == 0) { try { KmKørt = Convert.ToInt32(Console.ReadLine()); } catch (FormatException) { Console.SetCursorPosition(0, 11); Console.Write(" "); Console.SetCursorPosition(0, 11); Console.WriteLine("Km kørt skal være et tal, prøv igen:"); Console.SetCursorPosition(50, 11); } } Console.SetCursorPosition(0, 11); Console.Write(" "); Console.SetCursorPosition(0, 11); Console.WriteLine("Kilometer kørt:"); Console.SetCursorPosition(50, 11); Console.WriteLine(KmKørt); Console.SetCursorPosition(50, 12); Brændstof = Console.ReadLine(); while (Brændstof.ToLower() != "benzin" && Brændstof.ToLower() != "diesel") { Console.SetCursorPosition(0, 12); Console.Write(" "); Console.SetCursorPosition(0, 12); Console.WriteLine("Benzin eller diesel:"); Console.SetCursorPosition(50, 12); Brændstof = Console.ReadLine(); } Console.SetCursorPosition(0, 12); Console.Write(" "); Console.SetCursorPosition(0, 12); Console.WriteLine("Brændstof:"); Console.SetCursorPosition(50, 12); Console.WriteLine(Brændstof); Console.SetCursorPosition(50, 13); RegNr = Console.ReadLine(); OpretDato = DateTime.Now.ToString("d"); SQL.Change("insert into Bil values(" + KundeId + ",'" + Mærke + "', '" + Model + "', " + Årgang + ", " + KmKørt + ", '" + Brændstof + "', '" + RegNr + "', '" + OpretDato + "')"); biler.Add(new Bil(Mærke, Model, Årgang, KmKørt, Brændstof, OpretDato, RegNr, KundeId)); }
public static void opdaterBil() { Console.Clear(); Forside.DisplayTop(); Console.WriteLine("Bil liste:\n"); SQL.SelectFewBil("select * from Bil"); Console.Write("\nIndtast ID på bilen du vil redigere: "); int idValg = 0; try { idValg = Convert.ToInt32(Console.ReadLine()); SQL.SelectAllDataBil("select * from Bil where BilId = " + idValg + ""); Console.WriteLine("Indtast nummeret på den information du vil opdatere:"); Console.WriteLine("1. Mærke"); Console.WriteLine("2. Model"); Console.WriteLine("3. Årgang"); Console.WriteLine("4. Km Kørt"); Console.WriteLine("5. Brændstof"); Console.WriteLine("6. Registrerings Nr"); Console.WriteLine("7. Kunde ID\n"); var info = ""; ConsoleKeyInfo nummer = Console.ReadKey(true); switch (nummer.Key) { case ConsoleKey.D1: Console.Write("Indtast et nyt mærke: "); info = Console.ReadLine(); SQL.Change("update Bil set Mærke = '" + info + "' where BilId = " + idValg + ""); break; case ConsoleKey.D2: Console.Write("Indtast en ny model: "); info = Console.ReadLine(); SQL.Change("update Bil set Model = '" + info + "' where BilId = " + idValg + ""); break; case ConsoleKey.D3: Console.Write("Indtast en ny årgang: "); info = Console.ReadLine(); SQL.Change("update Bil set Årgang = '" + info + "' where BilId = " + idValg + ""); break; case ConsoleKey.D4: Console.Write("Indtast et antal Km kørt: "); info = Console.ReadLine(); SQL.Change("update Bil set KmKørt = " + info + " where BilId = " + idValg + ""); break; case ConsoleKey.D5: Console.Write("Indtast en ny slags brændstof: "); info = Console.ReadLine(); SQL.Change("update Bil set Brændstof = " + info + " where BilId = " + idValg + ""); break; case ConsoleKey.D6: Console.Write("Indtast et nyt registrerings nr: "); info = Console.ReadLine(); SQL.Change("update Bil set RegNr = '" + info + "' where BilId = " + idValg + ""); break; case ConsoleKey.D7: Console.Write("Indtast et nyt kunde ID: "); info = Console.ReadLine(); SQL.Change("update Bil set KundeId = '" + info + "' where BilId = " + idValg + ""); break; default: Console.WriteLine("Du må kun vælge et nummer fra listen."); break; } } catch (Exception) { } }