internal static void f_remove(SQLExecuter sqlex, bool keepConnectionOpen, OEntry obj) { try { #region handle children // bool leave; //set null //while (true) { // leave = true; // foreach (OEmployee x in OEmployee.Obscol) { // if (x.p_department.p_id == obj.p_id) { // OEmployee.f_addEdit(sqlex, true, true, x, null, x.p_employee_boss, // x.p_name, x.p_birthday); // leave = false; // break; // } // } // if (leave) break; //} #endregion //exec sql statement sqlex.delete(DB_TABLE, "where pk=" + obj.p_id, keepConnectionOpen); //remove this from obscol Obscol.Remove(obj); } catch (Exception exc) { throw exc; } }
internal static OEntry f_addEdit(SQLExecuter sqlex, bool keepConnectionOpen, bool toActualObscol, OEntry obj, string name, string message, DateTime date) { try { //add if (obj == null) { //insert object into collection Obscol.Add(new OEntry { p_name = name, p_message = message, p_date = date }); //insert entity and identify pk int id = sqlex.insert(DB_TABLE, Obscol[Obscol.Count - 1].f_getDBTableRow(), keepConnectionOpen); //overwrite determined primary key for entity obj = Obscol[Obscol.Count - 1]; obj.p_id = id; } //edit else { //overwrite properties obj.p_name = name; obj.p_message = message; obj.p_date = date; //call update sqlex.update(DB_TABLE, obj.f_getDBTableRow(), keepConnectionOpen); } if (!toActualObscol) { Obscol.Remove(obj); } return(obj); } catch (Exception exc) { throw exc; } }