// 5. Update By Id public static bool UpdateInvoiceProductById(InvoiceProductModel invoiceProduct) { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { var count = cnn.Execute("UPDATE InvoiceProduct " + "SET Quantity= @Quantity, Sale= @Sale, TotalPrice= @TotalPrice, " + "Weight= @Weight " + "WHERE Id= @Id", invoiceProduct); return(count > 0); } }
// 4. Save To DB public static bool SaveInvoiceProduct(InvoiceProductModel invoiceProduct) { try{ using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { cnn.Execute("INSERT INTO InvoiceProduct " + "(InvoiceId, ProductId, Quantity, Sale, TotalPrice, Weight) " + "VALUES (@InvoiceId, @ProductId, @Quantity, " + "@Sale, @TotalPrice, @Weight);", invoiceProduct); } } catch (Exception ex) { General.LogError(ex); return(false); } return(true); }