/// <summary> /// adds a parmater to client's application paramater table. Mostly used by SetupClient /// </summary> /// <param name="app"></param> /// <param name="parm"></param> /// <param name="value"></param> /// <returns></returns> public static void Add(string app, string parm, string value) { string p = ApplicationParameters.GetParm(app, parm); if (p != null) { if (p == value) return; throw new Exception("parm already exists - cant change value"); } string i = String.Format("insert into ApplicationParameter (app, parm, [value]) values ('{0}', '{1}', '{2}')", app, parm, value); SqlUtil sql = new SqlUtil(TDatabase.Client); sql.ExecuteNoResultSetSQLQuery(i); }
/// <summary> /// you can supply your own SQL object and force the audit to go to that database. Used by GT /// </summary> /// <param name="status"></param> /// <param name="CompletionMsg"></param> /// <param name="SQL"></param> /// <returns></returns> public long Save(CompletionStatus status, string CompletionMsg, SqlUtil SQL) { //save it - just in case of recovery mCompletionStatus = status; mCompletionMsg = CompletionMsg; string sql; SqlParameterCollection oParameters = new SqlCommand().Parameters; long ID = -1; oParameters.AddWithValue("@iDataType", DataUtils.DBNullIfNull(mDataType)); oParameters.AddWithValue("@iDataID", DataUtils.DBNullIfNull(mDataID)); oParameters.AddWithValue("@iCorrespondenceID", DataUtils.DBNullIfNull(mCorrespondenceID)); oParameters.AddWithValue("@iEventID", DataUtils.DBNullIfNull(mEventID)); oParameters.AddWithValue("@iEventDescription", DataUtils.DBNullIfNull(mEventDescription)); oParameters.AddWithValue("@iCompletionMsg", DataUtils.DBNullIfNull(CompletionMsg)); oParameters.AddWithValue("@iCompletionStatus", DataUtils.DBNullIfNull(status)); if (mLogTime == DateTime.MinValue) mLogTime = DateTimeUtility.ServerDateNoRefresh(); oParameters.AddWithValue("@iTime", mLogTime); sql = "set ansi_warnings off;INSERT INTO AuditHeader (DataType,DataID,CorrespondenceID,EventID,EventDescription,CompletionMsg,CompletionStatus,LogTime)" + " VALUES (@iDataType,@iDataID,@iCorrespondenceID,@iEventID,@iEventDescription,@iCompletionMsg,@iCompletionStatus,@iTime)"; sql += "; select @@IDENTITY as ID"; DataTable oTable; try { oTable = SQL.ExecuteSingleResultSetSQLQuery(sql, oParameters); } catch (Exception x) { if (mRecover && SqlRecover.SaveForRecovery(x, true, this, "auditheader")) return 0; else throw new Exception("sql error", x); } if (oTable.Rows.Count == 0) return -1; ID = DataUtils.LongZeroIfNull(oTable.Rows[0]["ID"]); if (ID < 1) return -1; if (mFieldChanges != null) { string o; string n; oParameters = new SqlCommand().Parameters; foreach (string field in mFieldChanges.UpdateList.Keys) { mFieldChanges.GetAuditValue(field, out o, out n); oParameters.AddWithValue("@iAuditID", ID); oParameters.AddWithValue("@iField", DataUtils.DBNullIfNull(field)); oParameters.AddWithValue("@iOldVal", DataUtils.DBNullIfNull(o)); oParameters.AddWithValue("@iNewVal", DataUtils.DBNullIfNull(n)); sql = "set ansi_warnings off;INSERT INTO AuditDetail(AuditID,Field, OldValue,NewValue) " + " VALUES (@iAuditID,@iField, @iOldVal,@iNewVal);"; SQL.ExecuteNoResultSetSQLQuery(sql, oParameters); oParameters.Clear(); } } return ID; }
public void DeleteAudit() { SqlParameterCollection parms = new SqlCommand().Parameters; parms.AddWithValue("@ID", this.ID); SqlUtil sql = new SqlUtil(mDatabase); sql.ExecuteNoResultSetSQLQuery("delete from auditdetail where auditid = @ID", parms); parms = new SqlCommand().Parameters; parms.AddWithValue("@ID", this.ID); sql.ExecuteNoResultSetSQLQuery("delete from auditheader where id = @ID", parms); }