public void Add(clsDatabase db, string userID) { DateTimeLastMaint = DateTime.Now; string sql = "INSERT INTO TimeLogEntries (" + "EmployeeID, " + "DateWorked, " + "HoursWorked, " + "Billable, " + "Description, " + "DateTimeLastMaint" + ") VALUES (" + db.ToSql(EmployeeID) + ", " + db.ToSql(DateWorked) + ", " + db.ToSql(HoursWorked) + ", " + db.ToSql(Billable) + ", " + db.ToSql(Description) + ", " + db.ToSql(DateTimeLastMaint) + ")"; db.ExecuteSQL(sql); addTimeLogHistory(sql, userID, db); mEntryID = getEntryID(db); }
public void Update(clsDatabase db, string userID) { using (clsQueryResults results = new clsQueryResults()) { string sql1 = "SELECT * FROM TimeLogEntries WHERE EntryID = " + db.ToSql(mEntryID); results.Open(db, sql1); DateTime lastMaint = (DateTime)results.GetColValue("DateTimeLastMaint"); if (lastMaint != DateTimeLastMaint) { throw new Exception("Entry has been modified since retrieval from the database."); } } DateTimeLastMaint = DateTime.Now; string sql2 = "UPDATE TimeLogEntries SET " + "EmployeeID = " + db.ToSql(EmployeeID) + ", DateWorked = " + db.ToSql(DateWorked) + ", HoursWorked = " + db.ToSql(HoursWorked) + ", Billable = " + db.ToSql(Billable) + ", Description = " + db.ToSql(Description) + ", DateTimeLastMaint = " + db.ToSql(DateTimeLastMaint) + " WHERE EntryID = " + db.ToSql(mEntryID); db.ExecuteSQL(sql2); addTimeLogHistory(sql2, userID, db); }
public void Delete(clsDatabase db, string userID) { string sql = "DELETE FROM TimeLogEntries WHERE EntryID = " + db.ToSql(mEntryID); db.ExecuteSQL(sql); addTimeLogHistory(sql, userID, db); }
public void addTimeLogHistory(string sqlCommand, string userID, clsDatabase db) { string sql = "INSERT INTO TimeLogHistory (" + "HistoryDateTime, " + "UserID, " + "SqlCommand " + ") VALUES (" + db.ToSql(DateTime.Now.Date) + ", " + db.ToSql(userID) + ", " + db.ToSql(sqlCommand) + ")"; db.ExecuteSQL(sql); }