private void UpdateDb(ComponentArt.Web.UI.GridItem item, string command) { IBusRole engine = new IBusRole(HELPERS.NewOdbcConn()); IEntAssignment engineEA = new IEntAssignment(HELPERS.NewOdbcConn()); switch (command) { case "INSERT": ValidateAbbrev(item["c_u_Abbrev"] as string, -1); item["c_id"] = engine.NewBusRole( item["c_u_Name"] as string, item["c_u_Description"] as string, this.session.idSubprocess); engine.SetBusRole ( (int)(item["c_id"]), item["c_u_Name"] as string, item["c_u_Description"] as string, this.session.idSubprocess, item["c_u_Abbrev"] as string, null, null, null); break; case "UPDATE": ValidateAbbrev(item["c_u_Abbrev"] as string, int.Parse(item["c_id"] as string)); engine.SetBusRole (int.Parse(item["c_id"] as string), item["c_u_Name"] as string, item["c_u_Description"] as string, this.session.idSubprocess, item["c_u_Abbrev"] as string); break; case "DELETE": int IDbusrole = int.Parse(item["c_id"] as string); // 1. Delete any EntAssignments involving this business role... // ... in this workspace... ...that have status "X". returnListEntAssignmentByBusRole[] ret = engineEA.ListEntAssignmentByBusRole (null, "", new string[] {}, "", IDbusrole); int refsStillPresent = 0; for (int i = 0; i < ret.Length; i++) { if (ret[i].Status == "X") { engineEA.DeleteEntAssignment(ret[i].ID); } else { refsStillPresent++; } } // 2. Check to see if there are any more references to this bus role if (refsStillPresent > 0) { throw new Exception ("This business role cannot be deleted at this time, because there is/are still " + refsStillPresent + " reference(s) to this business role, in other workspaces or historical snapshots."); } // 3. Delete the business role itself. engine.DeleteBusRole(IDbusrole); break; } }