private void button1_Click(object sender, EventArgs e)
        {
            Validation valISBN     = new Validation();
            Validation valBEdition = new Validation();
            Validation noOfCps     = new Validation();
            Validation valPrice    = new Validation();

            if (valISBN.validateNum(textBox1.Text, "ISBN") && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && valBEdition.validateNum(textBox5.Text, "Book edition") && noOfCps.validateNum(textBox6.Text, "No of copies") && valPrice.validateDecNum(textBox7.Text, "Price"))
            {
                int           count = 0;
                string        Query = "select * from book where ISBN = '" + Convert.ToInt32(textBox1.Text) + "'";
                SqlCommand    cmd   = new SqlCommand(Query, conn);
                SqlDataReader reader;
                try
                {
                    conn.Open();
                    reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        count++;
                    }
                    conn.Close();
                }
                catch (Exception ex)
                {
                }

                if (count == 0)
                {
                    int    ISBN        = Convert.ToInt32(textBox1.Text);
                    string bName       = textBox2.Text;
                    string bSubject    = textBox3.Text;
                    string bAuthor     = textBox4.Text;
                    int    bEdition    = Convert.ToInt32(textBox5.Text);
                    int    bNoOfCopies = Convert.ToInt32(textBox6.Text);
                    float  bPrice      = float.Parse(textBox7.Text);

                    Book newBook = new Book();
                    newBook.setBook(ISBN, bName, bSubject, bAuthor, bEdition, bNoOfCopies, bPrice);
                    newBook.addBook();

                    newBook = null;
                    GC.Collect();
                    button2_Click(null, null);
                }
                else
                {
                    MessageBox.Show("The book details already stored");
                }
            }
            else
            {
                MessageBox.Show("Provide all the details");
            }
            valISBN     = null;
            valBEdition = null;
            noOfCps     = null;
            valPrice    = null;

            GC.Collect();
        }
Пример #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            Validation valBEdition = new Validation();
            Validation noOfCps     = new Validation();
            Validation valPrice    = new Validation();

            if (textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && valBEdition.validateNum(textBox5.Text, "Book edition") && noOfCps.validateNum(textBox6.Text, "No of copies") && valPrice.validateDecNum(textBox7.Text, "Price"))
            {
                int    ISBN        = Convert.ToInt32(label12.Text);
                string bName       = textBox2.Text;
                string bSubject    = textBox3.Text;
                string bAuthor     = textBox4.Text;
                int    bEdition    = Convert.ToInt32(textBox5.Text);
                int    bNoOfCopies = Convert.ToInt32(textBox6.Text);
                float  bPrice      = float.Parse(textBox7.Text);

                Book mngBook = new Book();
                mngBook.setBook(ISBN, bName, bSubject, bAuthor, bEdition, bNoOfCopies, bPrice);
                mngBook.updateBook();

                mngBook = null;
                GC.Collect();
                loadTable();
                loadDetails();
                borrowCount();
            }
            else
            {
                MessageBox.Show("Provide all the details");
            }
            valBEdition = null;
            noOfCps     = null;
            valPrice    = null;

            GC.Collect();
        }