Example #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();
        }
Example #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);
         }
     }
 }
Example #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);
                }
            }
        }
Example #4
0
        public static void book()
        {
            //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");
                    Design.Welcome2();
                    Console.WriteLine();
                    Console.WriteLine("\n\t\t\t\t\t   Database Connected");
                    Console.WriteLine("Choose number from 1 to 3: ");
                    Console.WriteLine("1) Information System. ");
                    Console.WriteLine("2) Information Technology. ");
                    Console.WriteLine("3) Computer Science. ");
                    Console.Write("Please enter your choice:");
l5:
                    try
                    {
                        number = int.Parse(Console.ReadLine());
                    }
                    catch
                    {
                        Console.Write("Enter the number: ((1 or 2 or 3 )): ");
                        goto l5;
                    }
                    dept = number;
                    switch (number)
                    {
                    case 1:
                        Department(1);
                        break;

                    case 2:
                        Department(2);
                        break;

                    case 3:
                        Department(3);
                        break;

                    default:
                        Console.Write("Enter Just number: ((1 or 2 or 3 )): ");
                        goto l5;
                    }
l7:
                    Console.Write("\nEnter the number of book: ");
l6:
                    try
                    {
                        bookId = int.Parse(Console.ReadLine());
                        con.Open();
                        SqlCommand    search = new SqlCommand("Select number from books", con);
                        SqlDataReader value  = search.ExecuteReader();
                        while (value.Read())
                        {
                            if (value.GetValue(0).ToString() == Convert.ToString(bookId))
                            {
                                Not = 0;
                                Console.WriteLine("\t\t\t\t\t       ^_^ We find the book ^_^");
                                break;
                            }
                        }
                        con.Close();
                        if (Not == 1)
                        {
                            Console.WriteLine("\t\t\t\t\t<'_'> The book is Not in our Libraray <'_'>");
                            goto l7;
                        }
                    }
                    catch (Exception x)
                    {
                        Console.WriteLine(x.Message);
                        Console.Write("\nEnter THE NUMBER OF BOOK: ");
                        goto l6;
                    }
                    Design.Lines2();
                    Design.clear();
                    List();
                }
                catch (Exception x)
                {
                    Console.WriteLine(x.Message);
                }
            }
        }