Exemplo n.º 1
0
        /// <summary>
        /// Adds a new record into the <c>tblRecentLog</c> table.
        /// </summary>
        /// <param name="value">The <see cref="tblRecentLogRow"/> object to be inserted.</param>
        public virtual void Insert(tblRecentLogRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._tblRecentLog_Insert", true);

            AddParameter(cmd, "CaseNo", value.CaseNo);
            AddParameter(cmd, "RecentLogDateTime", value.RecentLogDateTime);
            AddParameter(cmd, "UserID", value.UserID);
            AddParameter(cmd, "UserName", value.UserName);
            AddParameter(cmd, "Action", value.Action);
            value.RecentLogID = Convert.ToInt32(cmd.ExecuteScalar());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reads data from the provided data reader and returns
        /// an array of mapped objects.
        /// </summary>
        /// <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param>
        /// <param name="startIndex">The index of the first record to map.</param>
        /// <param name="length">The number of records to map.</param>
        /// <param name="totalRecordCount">A reference parameter that returns the total number
        /// of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param>
        /// <returns>An array of <see cref="tblRecentLogRow"/> objects.</returns>
        protected virtual tblRecentLogRow[] MapRecords(IDataReader reader,
                                                       int startIndex, int length, ref int totalRecordCount)
        {
            if (0 > startIndex)
            {
                throw new ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero.");
            }
            if (0 > length)
            {
                throw new ArgumentOutOfRangeException("length", length, "Length cannot be less than zero.");
            }

            int recentLogIDColumnIndex       = reader.GetOrdinal("RecentLogID");
            int caseNoColumnIndex            = reader.GetOrdinal("CaseNo");
            int recentLogDateTimeColumnIndex = reader.GetOrdinal("RecentLogDateTime");
            int userIDColumnIndex            = reader.GetOrdinal("UserID");
            int userNameColumnIndex          = reader.GetOrdinal("UserName");
            int actionColumnIndex            = reader.GetOrdinal("Action");

            System.Collections.ArrayList recordList = new System.Collections.ArrayList();
            int ri = -startIndex;

            while (reader.Read())
            {
                ri++;
                if (ri > 0 && ri <= length)
                {
                    tblRecentLogRow record = new tblRecentLogRow();
                    recordList.Add(record);

                    record.RecentLogID       = Convert.ToInt32(reader.GetValue(recentLogIDColumnIndex));
                    record.CaseNo            = Convert.ToString(reader.GetValue(caseNoColumnIndex));
                    record.RecentLogDateTime = Convert.ToDateTime(reader.GetValue(recentLogDateTimeColumnIndex));
                    record.UserID            = Convert.ToInt32(reader.GetValue(userIDColumnIndex));
                    if (!reader.IsDBNull(userNameColumnIndex))
                    {
                        record.UserName = Convert.ToString(reader.GetValue(userNameColumnIndex));
                    }
                    if (!reader.IsDBNull(actionColumnIndex))
                    {
                        record.Action = Convert.ToString(reader.GetValue(actionColumnIndex));
                    }

                    if (ri == length && 0 != totalRecordCount)
                    {
                        break;
                    }
                }
            }

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((tblRecentLogRow[])(recordList.ToArray(typeof(tblRecentLogRow))));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Updates a record in the <c>tblRecentLog</c> table.
        /// </summary>
        /// <param name="value">The <see cref="tblRecentLogRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(tblRecentLogRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._tblRecentLog_Update", true);

            AddParameter(cmd, "CaseNo", value.CaseNo);
            AddParameter(cmd, "RecentLogDateTime", value.RecentLogDateTime);
            AddParameter(cmd, "UserID", value.UserID);
            AddParameter(cmd, "UserName", value.UserName);
            AddParameter(cmd, "Action", value.Action);
            AddParameter(cmd, "RecentLogID", value.RecentLogID);
            return(0 != cmd.ExecuteNonQuery());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="tblRecentLogRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="tblRecentLogRow"/> object.</returns>
        protected virtual tblRecentLogRow MapRow(DataRow row)
        {
            tblRecentLogRow mappedObject = new tblRecentLogRow();
            DataTable       dataTable    = row.Table;
            DataColumn      dataColumn;

            // Column "RecentLogID"
            dataColumn = dataTable.Columns["RecentLogID"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.RecentLogID = (int)row[dataColumn];
            }
            // Column "CaseNo"
            dataColumn = dataTable.Columns["CaseNo"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.CaseNo = (string)row[dataColumn];
            }
            // Column "RecentLogDateTime"
            dataColumn = dataTable.Columns["RecentLogDateTime"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.RecentLogDateTime = (System.DateTime)row[dataColumn];
            }
            // Column "UserID"
            dataColumn = dataTable.Columns["UserID"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.UserID = (int)row[dataColumn];
            }
            // Column "UserName"
            dataColumn = dataTable.Columns["UserName"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.UserName = (string)row[dataColumn];
            }
            // Column "Action"
            dataColumn = dataTable.Columns["Action"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Action = (string)row[dataColumn];
            }
            return(mappedObject);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Deletes the specified object from the <c>tblRecentLog</c> table.
 /// </summary>
 /// <param name="value">The <see cref="tblRecentLogRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(tblRecentLogRow value)
 {
     return(DeleteByPrimaryKey(value.RecentLogID));
 }