private void isssueButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(bookIdTexBox.Text) || string.IsNullOrEmpty(nameTextBox.Text))
         {
             MessageBox.Show("Enter Book Id Or Name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         }
         else
         {
             info.Id = int.Parse(bookIdTexBox.Text);
             info.Name = nameTextBox.Text;
             // info.BookIssueTo = issueDateTextBox.Text;
             cm.InsertIssue(info);
             ob = sd.GetBookName(info.Id);
             quantity = ob.BookInventory - 1;
             if (quantity > 0)
             {
                 sd.ReturnBook(info.Id, quantity);
                 MessageBox.Show("Issued Successfully", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             }
             else
             {
                 MessageBox.Show("Book Is not Available.", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             }
         }
     }
     catch (FormatException)
     {
         MessageBox.Show("Book Id Can Not Be Name", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
 private void bookTextBox_TextChanged(object sender, EventArgs e)
 {
     name = bookTextBox.Text;
     ob = sd.GetBookName(name);
     authorNameLabel.Text = ob.AuthorName;
     quantityLabel.Text = ob.BookInventory.ToString();
     catagoryLabel.Text = ob.Catagory;
 }
 private void returnBookText_TextChanged(object sender, EventArgs e)
 {
     name = returnBookText.Text;
     ob = sd.GetBookName(name);
     nameLabel.Text = ob.AuthorName;
     idLabel.Text = ob.Id.ToString();
     catagoryLabel.Text = ob.Catagory;
     returnbook = ob.BookInventory + 1;
     id = ob.Id;
 }
 BookStatus GetData(SqlCommand cmd)
 {
     cmd.Connection.Open();
        SqlDataReader reader = cmd.ExecuteReader();
        BookStatus ob = new BookStatus();
        using (reader)
        {
        while (reader.Read())
        {
            ob.Id = reader.GetInt32(0);
            ob.BookTitle = reader.GetString(1);
            ob.AuthorName = reader.GetString(2);
            ob.BookInventory = reader.GetInt32(3);
            ob.Catagory = reader.GetString(4);
        }
        reader.Close();
        }
        cmd.Connection.Close();
        return ob;
 }
 public bool InsertBook(BookStatus obj)
 {
     SqlDBdataAccess da = new SqlDBdataAccess();
     SqlCommand cmd = da.GetCommand("insert into [dbo].[Lib_Book_Details] ([Book_Title],[Lib_Book_Author_Name],[Lib_Book_In_Inventory],[Category_Name])" + "values(@Title,@Author,@Quantity,@Category)");
     SqlParameter p = new SqlParameter("@Title", SqlDbType.VarChar, 50);
     p.Value = obj.BookTitle;
     SqlParameter p1 = new SqlParameter("@Author", SqlDbType.VarChar, 50);
     p1.Value = obj.AuthorName;
     SqlParameter p2 = new SqlParameter("@Quantity", SqlDbType.Int);
     p2.Value = obj.BookInventory;
     SqlParameter p3 = new SqlParameter("@Category", SqlDbType.VarChar, 50);
     p3.Value = obj.Catagory;
     cmd.Parameters.Add(p);
     cmd.Parameters.Add(p1);
     cmd.Parameters.Add(p2);
     cmd.Parameters.Add(p3);
     cmd.Connection.Open();
     int val = cmd.ExecuteNonQuery();
     cmd.Connection.Close();
     return val > 0;
 }
 private void booktitletxt_TextChanged(object sender, EventArgs e)
 {
     booktitle = booktitletxt.Text;
     ob = sd.GetBookName(booktitle);
     authorNameLabel.Text = ob.AuthorName;
 }