public static bool DeleteItem(Int32 itemId) { var dbItems = new DbItems(); var result = dbItems.Delete(itemId); return(result); }
public static string DeleteProposal(Int32 id) { var result = ""; var dbProposal = new DbProposals(); var db = DbaseTools.CreateDbase(); try { db.Open(); db.BeginTransaction(); var delItems = true; var items = DbItems.LoadAll(id, db); if (items.Count > 0) { var dbItems = new DbItems(); foreach (var i in items) { delItems = dbItems.Delete(i.ID, db); if (!delItems) { db.Rollback(); result = "Error on deleting proposal item " + i.ID + "!"; break; } } } if (delItems) { var delProposal = dbProposal.Delete(id, db); if (!delProposal) { db.Rollback(); result = "Error on deleting proposal!"; } db.Commit(); result = "OK"; } } catch { result = "Error on database!"; } finally { db.Close(); db.Dispose(); db = null; } return(result); }