public static void Read() { Design.Welcome2(); Console.Write("How many hour you want to read this book:"); l7: try { hour = int.Parse(Console.ReadLine()); if (hour > 12) { Console.Write("Enter number of hours less than 12 hours: "); goto l7; } } catch { Console.Write("Enter the ((number)) of hours: "); goto l7; } Console.WriteLine(); Console.WriteLine(); Design.Line(); Console.WriteLine(); studentInformation(); array[5] = "The book's situation is: Read for " + hour + " hours. "; Console.WriteLine("The book's situation is: Read for {0} hours. ", hour); bookInformation(); Design.Lines2(); Design.clear(); Design.exit(); }
public static void Department(int dept) { //Collection With the database of book { try { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\السباعي\Desktop\Library System\Library System\Library System\Books.mdf;Integrated Security=True"); con.Open(); Design.Line(); Console.WriteLine(); Console.WriteLine("\n\t\t\t\t\t Database Connected"); if (dept == 1) { Console.WriteLine("\t\t\t\t ^_^ The Information System's 1books ^_^"); quere = "select * from books where [IS] != 0 "; } if (dept == 2) { Console.WriteLine("\t\t\t\t ^_^ The Information Technology's books ^_^"); quere = "select * from books where IT != 0 "; } if (dept == 3) { Console.WriteLine("\t\t\t\t ^_^ The Computer Science's books ^_^"); quere = "select * from books where CS != 0 "; } SqlCommand department = new SqlCommand(quere, con); department.ExecuteNonQuery(); SqlDataReader Dr = department.ExecuteReader(); while (Dr.Read()) { Console.WriteLine(Dr.GetValue(0).ToString() + ") " + Dr.GetValue(1).ToString()); } con.Close(); con.Open(); SqlCommand insert = new SqlCommand("Insert into books (tokenFrom) values ('" + dept + "')", con); insert.ExecuteNonQuery(); con.Close(); } catch (Exception x) { Console.WriteLine(x.Message); } } }
/*2)Question Card * yes goto verification from that * no goto Registering a Student */ public static void page2() { Console.BackgroundColor = ConsoleColor.Red; Console.Clear(); Console.SetCursorPosition(0, 3); Console.ForegroundColor = ConsoleColor.Black; Design.Line(); Design.Line(); Console.ForegroundColor = ConsoleColor.Yellow; Console.SetCursorPosition(40, 7); Console.WriteLine("Do You Have an universal card?"); Console.SetCursorPosition(40, 9); Console.Write("1- Yes."); Console.WriteLine("\t\t 2- No."); Console.SetCursorPosition(40, 11); Console.Write("Enter the number: "); l1: try { number = int.Parse(Console.ReadLine()); } catch { Console.Write("Enter the number: ((1 or 2)): "); goto l1; } switch (number) { case 1: Design.Lines(); verification(); break; case 2: Design.Lines(); Pagestudent(); break; default: Console.Write("Enter Just number: ((1 or 2)): "); goto l1; } }
public static void Borrow() { //Collection With the database of book { try { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\السباعي\Desktop\Library System\Library System\Library System\Books.mdf;Integrated Security=True"); con.Open(); Design.Welcome2(); SqlCommand readborrow = new SqlCommand("select * from books where number='" + bookId + "'", con); SqlDataReader read = readborrow.ExecuteReader(); read.Read(); if (read.GetValue(4).ToString() != "0") { array[5] = "Sorry <-_-> You can't borrow this book!"; Console.WriteLine("Sorry <-_-> You can't borrow this book!"); con.Close(); Design.Lines2(); Design.clear(); book(); } else { Console.WriteLine("\nNote: "); Console.WriteLine("You can borrow the book for 3 days"); Console.Write("How many days you want to borrow the book:"); l8: try { days = int.Parse(Console.ReadLine()); if (days != 1 && days != 2 && days != 3) { Console.Write("Enter number of days <<1 or 2 or 3>>: "); goto l8; } } catch { Console.Write("Enter the ((number)) of days: "); goto l8; } con.Close(); con.Open(); SqlCommand readDays = new SqlCommand("update books set borrow= '" + days + "'where number= '" + bookId + "'", con); readDays.ExecuteNonQuery(); SqlCommand readDept = new SqlCommand("update books set tokenFrom= '" + dept + "'where number= '" + bookId + "'", con); readDept.ExecuteNonQuery(); SqlCommand readID = new SqlCommand("update books set studentID= '" + Windows.id + "'where number= '" + bookId + "'", con); readID.ExecuteNonQuery(); Console.WriteLine(); Design.Line(); Console.WriteLine(); studentInformation(); thatday = today.AddDays(days); if (days == 1) { array[5] = "The book's situation is: Borrow for " + days + " day from " + today.ToString("d/M/yyyy") + " to " + thatday.ToString("d/M/yyyy") + ". "; Console.WriteLine("The book's situation is: Borrow for {0} day from {1} to {2}. ", days, today.ToString("d/M/yyyy"), thatday.ToString("d/M/yyyy")); } else { array[5] = "The book's situation is: Borrow for " + days + " days from " + today.ToString("d/M/yyyy") + " to " + thatday.ToString("d/M/yyyy") + ". "; Console.WriteLine("The book's situation is: Borrow for {0} days from {1} to {2}. ", days, today.ToString("d/M/yyyy"), thatday.ToString("d/M/yyyy")); } SqlCommand setDate = new SqlCommand("update books set Returning= '" + thatday.ToShortDateString() + "'where number= '" + bookId + "'", con); setDate.ExecuteNonQuery(); bookInformation(); Console.WriteLine(); Design.Line(); Console.WriteLine("\nNote: "); Console.WriteLine("If you return the book after more than three days you'll pay 3$ for each day."); Design.Lines2(); Design.clear(); Design.exit(); con.Close(); } } catch (Exception x) { Console.WriteLine(x.Message); } } }
public static void List() { Console.BackgroundColor = ConsoleColor.Black; Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Design.Line(); Design.Line(); Console.SetCursorPosition(47, 3); Console.WriteLine("Welcome To Library System"); Console.SetCursorPosition(0, 5); Design.Line(); Design.Line(); Console.SetCursorPosition(45, 10); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("Enter Number from 1 to 4: "); Console.ForegroundColor = ConsoleColor.DarkBlue; Console.SetCursorPosition(45, 11); Console.WriteLine("1- Read the Book."); Console.ForegroundColor = ConsoleColor.DarkMagenta; Console.SetCursorPosition(45, 12); Console.WriteLine("2- Borrow the book."); Console.ForegroundColor = ConsoleColor.DarkYellow; Console.SetCursorPosition(45, 13); Console.WriteLine("3- Return the book."); Console.ForegroundColor = ConsoleColor.DarkGreen; Console.SetCursorPosition(45, 14); Console.WriteLine("4- Exit from the System."); Console.ForegroundColor = ConsoleColor.Gray; Console.SetCursorPosition(45, 17); Console.Write("Enter the number:"); l4: try { number = int.Parse(Console.ReadLine()); } catch { Console.Write("Enter the number: ((1 or 2 or 3 or 4)): "); goto l4; } switch (number) { case 1: Design.Lines2red(); Read(); break; case 2: Design.Lines2red(); Borrow(); break; case 3: Design.Lines2red(); Return(); break; case 4: Design.Lines2red(); Design.exit(); break; default: Console.Write("Enter Just number: ((1 or 2 or 3 or 4)): "); goto l4; } }