Пример #1
0
 private void ClearAll_Click(object sender, EventArgs e)
 {
     memResult.Visible  = false;
     memResult2.Visible = false;
     bookResult.Visible = false;
     memId.Clear();
     BookID.Clear();
 }
Пример #2
0
        private void AddBook(object sender, EventArgs e)
        {
            Book       book = new Book();
            FileStream FS   = new FileStream("Book.txt", FileMode.Append, FileAccess.Write);


            byte[] p; string Temp;

            //Write Field ID.
            book.set_FieldID(FieldID.Text);
            Temp = book.get_FieldID();
            FS.WriteByte((byte)book.get_FieldID().Length);
            p = new byte[book.get_FieldID().Length];
            for (int i = 0; i < book.get_FieldID().Length; i++)
            {
                p[i] = (byte)Temp[i];
            }
            FS.Write(p, 0, book.get_FieldID().Length);

            //Write Book ID.
            if (book.set_BookID(BookID.Text))
            {
                p    = new byte[book.get_BookID().Length];
                Temp = book.get_BookID();
                for (int i = 0; i < book.get_BookID().Length; i++)
                {
                    p[i] = (byte)Temp[i];
                }
                FS.Write(p, 0, book.get_BookID().Length);
            }
            else
            {
                MessageBox.Show("Error !! Book_ID  Length Very Large .");
            }


            //Write Book Name.
            if (book.set_BookName(NameBook.Text))
            {
                p    = new byte[book.get_BookName().Length];
                Temp = book.get_BookName();
                for (int i = 0; i < book.get_BookName().Length; i++)
                {
                    p[i] = (byte)Temp[i];
                }
                FS.Write(p, 0, book.get_BookName().Length);
            }
            else
            {
                MessageBox.Show("Error !! Book_Name Length Very Large .");
            }


            //Write Book Author.
            book.set_BookAuthor(BookAuthor.Text);
            Temp = book.get_BookAuthor();
            FS.WriteByte((byte)book.get_BookAuthor().Length);
            p = new byte[book.get_BookAuthor().Length];
            for (int i = 0; i < book.get_BookAuthor().Length; i++)
            {
                p[i] = (byte)Temp[i];
            }
            FS.Write(p, 0, book.get_BookAuthor().Length);

            BookID.Clear();
            NameBook.Clear();
            FieldID.Clear();
            BookAuthor.Clear();

            FS.Close();
        }