Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            byte[]       img = null;
            FileStream   fs  = new FileStream(imgLoc, FileMode.Open, FileAccess.Read);
            BinaryReader br  = new BinaryReader(fs);

            img = br.ReadBytes((int)fs.Length);

            //Image img = pictureBox1.Image;
            //byte[] arr;
            //ImageConverter converter = new ImageConverter();
            //arr = (byte[])converter.ConvertTo(img, typeof(byte[]));


            AllMethods objMethods = new AllMethods();

            objMethods.Initialize();


            //string name = txtName.Text;
            //int age = Convert.ToInt32(txtAge.Text);

            //objMethods.Insert(name, age);

            // string book_id = BookIDText.Text;
            string material           = textBox1.Text;
            string source_combo_box   = textBox2.Text;
            string supplier_combo_box = textBox3.Text;
            string subject_combo_box  = textBox4.Text;
            int    shelf_text         = Convert.ToInt32(ShelfText.Text);
            int    buying_price       = Convert.ToInt32(BuyingPriceText.Text);
            int    selling_price      = Convert.ToInt32(SellingPriceText.Text);
            //  DateTime dateTime = dateTimePicker.Value;
            int    numberOfSellableBook = Convert.ToInt32(textBox6.Text);
            string bookTitle            = BookTitleText.Text;
            string authorName           = AuthorNameText.Text;
            string subTitle             = SubtitleText.Text;
            string isbn = ISBNText.Text;
            int    number_of_borrowable_books = Convert.ToInt32(NumberOfBorrowableBooksText.Text);
            // int number_of_not_borrowable_books = Convert.ToInt32(NumberOfNotBorrowableBooksText.Text);
            // int number_of_buyable_books = Convert.ToInt32(NumberOfBuyableableBooksText.Text);
            //string availability = AvailabilityComboBox.Text;
            int    number_of_readable_books = Convert.ToInt32(readableBooksText.Text);
            string edition = editionText.Text;

            objMethods.Insert(bookTitle, authorName, subTitle, subject_combo_box, isbn, buying_price, selling_price, numberOfSellableBook, shelf_text, number_of_borrowable_books, number_of_readable_books, material, supplier_combo_box, source_combo_box, edition, img, imageURL);

            // Formtwo objFormTwo = new Formtwo();
            // objFormTwo.Show();
            this.Hide();
            AdminHome admin = new AdminHome();

            admin.Show();
        }
        private void button1_Click(object sender, EventArgs e) //Button for submit
        {
            //Converting Image to Byte format
            byte[]       img = null;
            FileStream   fs  = new FileStream(imgLoc, FileMode.Open, FileAccess.Read);
            BinaryReader br  = new BinaryReader(fs);

            img = br.ReadBytes((int)fs.Length);

            //Calling All methods class to insert books
            //Almethods class has the method for the query
            AllMethods objMethods = new AllMethods();

            objMethods.Initialize(); //Initializing all method class

            //Taking all the values inside the variables
            string material             = textBox1.Text;
            string source_combo_box     = textBox2.Text;
            string supplier_combo_box   = textBox3.Text;
            string subject_combo_box    = textBox4.Text;
            int    shelf_text           = Convert.ToInt32(ShelfText.Text);        //Converting string to int
            int    buying_price         = Convert.ToInt32(BuyingPriceText.Text);  //Converting string to int
            int    selling_price        = Convert.ToInt32(SellingPriceText.Text); //Converting string to int
            int    numberOfSellableBook = Convert.ToInt32(textBox6.Text);         //Converting string to int
            string bookTitle            = BookTitleText.Text;
            string authorName           = AuthorNameText.Text;
            string subTitle             = SubtitleText.Text;
            string isbn = ISBNText.Text;
            int    number_of_borrowable_books = Convert.ToInt32(NumberOfBorrowableBooksText.Text); //Converting string to int
            int    number_of_readable_books   = Convert.ToInt32(readableBooksText.Text);           //Converting string to int
            string edition = editionText.Text;

            //calling insert method to insert the books in the database
            objMethods.Insert(bookTitle, authorName, subTitle, subject_combo_box, isbn, buying_price, selling_price, numberOfSellableBook, shelf_text, number_of_borrowable_books, number_of_readable_books, material, supplier_combo_box, source_combo_box, edition, img, imageURL);


            this.Hide();                       //Hiding the present page
            AdminHome admin = new AdminHome(); //Creating new instance of home

            admin.Show();                      // show admin home after pressing submit button
        }