/// <summary> /// Add a new Audited Item to the database /// </summary> /// <param name="theLicenseType"></param> /// <returns></returns> public int AuditedItemAdd(AuditedItem aItem) { if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in"); } int lItemID = 0; if (compactDatabaseType) { try { using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection()) { string commandText = "INSERT INTO AUDITEDITEMS " + "(_CATEGORY ,_NAME, _VALUE, _ICON, _ASSETID, _DISPLAY_UNITS, _DATATYPE ,_HISTORIED ,_GROUPED) " + "VALUES " + "(@cCategory, @cName, @cValue, @cIcon, @nAssetID, @cDisplayUnits, @nDataType, @bHistoried ,@bGrouped)"; using (SqlCeCommand command = new SqlCeCommand(commandText, conn)) { command.Parameters.AddWithValue("@cCategory", aItem.Category); command.Parameters.AddWithValue("@cName", aItem.Name); command.Parameters.AddWithValue("@cValue", aItem.Value); command.Parameters.AddWithValue("@cIcon", aItem.Icon); command.Parameters.AddWithValue("@nAssetID", aItem.AssetID); command.Parameters.AddWithValue("@cDisplayUnits", aItem.DisplayUnits); command.Parameters.AddWithValue("@nDataType", aItem.Datatype); command.Parameters.AddWithValue("@bHistoried", aItem.Historied); command.Parameters.AddWithValue("@bGrouped", aItem.Grouped); command.ExecuteNonQuery(); } } } catch (SqlCeException ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } catch (Exception ex) { Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine + "Please see the log file for further details."); logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex); } } else { AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess(); lItemID = lAuditWizardDataAccess.AuditedItemAdd(aItem); } if (isDebugEnabled) { logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out."); } return(lItemID); }