private Dictionary <string, object> prepareBookParameters(clsBook clsBook) { Dictionary <string, object> par = new Dictionary <string, object>(6); par.Add("BookID", clsBook.BookID); par.Add("Name", clsBook.Name); par.Add("Price", clsBook.Price); par.Add("ProductTypeOldOrNew", clsBook.ProdType); par.Add("Condition", clsBook.Condition); par.Add("QuantityInHand", clsBook.Quantity); return(par); }
private Dictionary <string, object> prepareWorkParameters(clsBook prbook) { Dictionary <string, object> par = new Dictionary <string, object>(10); par.Add("Name", prbook.Name); par.Add("Price", prbook.Price); par.Add("ProductTypeOldOrNew", prbook.ProdType); par.Add("Genre", "1"); par.Add("GenreName", prbook.Genre); par.Add("Condition", prbook.Condition); par.Add("QuantityInHand", prbook.Quantity); return(par); }
public string PutBook(clsBook prBook) { // update try { int lcRecCount = clsDbConnection.Execute( "update tbl_AllBooks set Name =@Name , Price=@Price ,ProductTypeOldOrNew = @ProductTypeOldOrNew ,Condition =@Condition ,QuantityInHand =@QuantityInHand where productID = @BookID", prepareBookParameters(prBook)); if (lcRecCount == 1) { return("Book information updated"); } else { return("Unexpected Book update count: " + lcRecCount); } } catch (Exception ex) { return(ex.GetBaseException().Message); } }
// this is to insert the records to the all books public string PostBook(clsBook prBook) { try { int lcRecCount = clsDbConnection.Execute("INSERT INTO tbl_AllBooks " + "(Name, Price, ProductTypeOldOrNew, Genre, GenreName, Condition, QuantityInHand) " + "VALUES (@Name, @Price, @ProductTypeOldOrNew, @Genre, @GenreName, @Condition, @QuantityInHand)", prepareWorkParameters(prBook)); if (lcRecCount == 1) { return("One Book inserted"); } else { return("Unexpected artwork insert count: " + lcRecCount); } } catch (Exception ex) { return(ex.GetBaseException().Message); } }