Пример #1
0
        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();
        }
Пример #2
0
 public static void Return()
 {
     //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();
             Console.WriteLine();
             SqlCommand    readB = new SqlCommand("select * from books where number= '" + bookId + "'", con);
             SqlDataReader drB   = readB.ExecuteReader();
             drB.Read();
             if (drB.GetValue(10).ToString() != Convert.ToString(Windows.id))
             {
                 array[5] = "You didn't borrow this book Before!";
                 Console.WriteLine("You didn't borrow this book Before!");
                 Design.Lines2();
                 Design.clear();
                 book();
             }
             else
             {
                 studentInformation();
                 thatday = Convert.ToDateTime(drB.GetValue(5));
                 Dept    = Convert.ToInt32(drB.GetValue(9));
                 st      = thatday - today;
                 days    = st.Days - 1;
                 if (dept == Dept)
                 {
                     if (days > 3)
                     {
                         array[5] = "The book's situation is: Return after " + days + " days of the metaphor from " + today.ToShortDateString() + " to " + Convert.ToDateTime(drB.GetValue(5)).ToShortDateString() + ". ";
                         Console.WriteLine("The book's situation is: Return after {0} days of the metaphor from {1} to {2}. ", drB.GetValue(4).ToString(), today.ToShortDateString(), Convert.ToDateTime(drB.GetValue(5)).ToShortDateString());
                         for (int i = days - 3; i > 0; i--)
                         {
                             money += 3;
                         }
                         array[10] = "The money that you must to pay is " + money + "$.";
                         Console.WriteLine("The money that you must to pay is {0}$.", money);
                     }
                     else
                     {
                         array[5] = "Thanks for returning our book ^_^";
                         Console.WriteLine("Thanks for returning our book ^_^");
                     }
                     bookInformation();
                     con.Close();
                     con.Open();
                     SqlCommand NullDays = new SqlCommand("update books set borrow = DEFAULT where number= '" + bookId + "'", con);
                     NullDays.ExecuteNonQuery();
                     SqlCommand NullDate = new SqlCommand("update books set Returning = DEFAULT where number= '" + bookId + "'", con);
                     NullDate.ExecuteNonQuery();
                     SqlCommand NullDepartment = new SqlCommand("update books set tokenFrom = DEFAULT where number= '" + bookId + "'", con);
                     NullDepartment.ExecuteNonQuery();
                     SqlCommand NullStudentID = new SqlCommand("update books set studentID = DEFAULT where number= '" + bookId + "'", con);
                     NullStudentID.ExecuteNonQuery();
                     Design.Lines2();
                     Design.clear();
                     Design.exit();
                 }
                 else
                 {
                     array[5] = "<'_'> You Don't borrow this book from this depatment. <'_'>";
                     Console.WriteLine("<'_'> You Don't borrow this book from this depatment. <'_'>");
                 }
             }
             con.Close();
         }
         catch (Exception x)
         {
             Console.WriteLine(x.Message);
         }
     }
 }
Пример #3
0
        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);
                }
            }
        }
Пример #4
0
        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;
            }
        }