Esempio n. 1
0
        /// <summary>
        /// Fill in the "next" and "previous" variables in record with the next and previous
        /// document ids.
        /// </summary>
        /// <param name="sql">Sql to add to document select to limit the documents returned,
        /// e.g. to the next cheque from this bank account.</param>
        protected void nextPreviousDocument(JObject record, string sql)
        {
            JObject header = (JObject)record["header"];
            int     id     = header.AsInt("idDocument");
            string  d      = Database.Quote(header.AsDate("DocumentDate"));
            JObject next   = id == 0 ? null : Database.QueryOne("SELECT idDocument FROM Document " + sql
                                                                + " AND (DocumentDate > " + d + " OR (DocumentDate = " + d + " AND idDocument > " + id + "))"
                                                                + " ORDER BY DocumentDate, idDocument");

            if (next != null || ReadWrite)
            {
                record["next"] = next == null ? 0 : next.AsInt("idDocument");
            }
            JObject previous = Database.QueryOne("SELECT idDocument FROM Document " + sql
                                                 + (id == 0 ? "" : " AND (DocumentDate < " + d + " OR (DocumentDate = " + d + " AND idDocument < " + id + "))")
                                                 + " ORDER BY DocumentDate DESC, idDocument DESC");

            if (previous != null || ReadWrite)
            {
                record["previous"] = previous == null ? 0 : previous.AsInt("idDocument");
            }
        }
Esempio n. 2
0
 public override FieldValue ValueFor(JObject o)
 {
     return(period(o.AsDate("DocumentDate")));
 }