private void deleteButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(bookTextBox.Text)) { MessageBox.Show("Enter Book Name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (!string.IsNullOrEmpty(QuantityRemovedTxt.Text)) { MessageBox.Show("You Can Not Delete The Quantity You Can Delete The Book Details When Book Inventory Is zero", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { ob1 = cmd.GetBookName(ob.Id); if (ob1.Id == ob.Id) { MessageBox.Show("Book is in issue....", "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (ob.BookInventory == 0) { cmd1.DeleteDetails(ob.Id); MessageBox.Show("Book Information Deleted Successfully", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else if (ob.BookInventory > 0) { MessageBox.Show("There are book In your library you can not delete the information", "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
BookIssueInfo GetData(SqlCommand cmd) { cmd.Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); BookIssueInfo ob = new BookIssueInfo(); using (reader) { while (reader.Read()) { ob.IssueId = reader.GetInt32(0); ob.Id = reader.GetInt32(1); } reader.Close(); } cmd.Connection.Close(); return ob; }
public bool InsertIssue(BookIssueInfo obj) { SqlDBdataAccess da = new SqlDBdataAccess(); SqlCommand cmd = da.GetCommand("insert into [dbo].[Lib_Book_Issued_Details] ([Lib_Book_Id],[Lib_Book_Issued_To],[Lib-Book_Issued_On])" + "values(@id,@IssueDate,@Name)"); SqlParameter p = new SqlParameter("@id", SqlDbType.Int); p.Value = obj.Id; SqlParameter p1 = new SqlParameter("@IssueDate", SqlDbType.DateTime); p1.Value = DateTime.Now; SqlParameter p2 = new SqlParameter("@Name", SqlDbType.VarChar,50); p2.Value = obj.Name; cmd.Parameters.Add(p); cmd.Parameters.Add(p1); cmd.Parameters.Add(p2); cmd.Connection.Open(); int val = cmd.ExecuteNonQuery(); cmd.Connection.Close(); return val > 0; }
private void returnButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(returnBookText.Text)) { MessageBox.Show("Please Enter Book Name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { int issueid; ob1 = cmd.GetBookName(ob.Id); issueid = ob1.IssueId; if (ob.Id == ob1.Id) { sd.ReturnBook1(name, returnbook); sd.DeleteIssue(issueid); MessageBox.Show("Book Returned Successfullly", "Congratulation", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("Book Does Not Issue", "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }