/// <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="tblGL_AccountRow"/> objects.</returns>
        protected virtual tblGL_AccountRow[] 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 gL_Act_IdColumnIndex      = reader.GetOrdinal("GL_Act_Id");
            int gL_Act_CodeColumnIndex    = reader.GetOrdinal("GL_Act_Code");
            int gL_Act_NameColumnIndex    = reader.GetOrdinal("GL_Act_Name");
            int gL_Act_Type_IdColumnIndex = reader.GetOrdinal("GL_Act_Type_Id");
            int statusColumnIndex         = reader.GetOrdinal("Status");
            int created_ByColumnIndex     = reader.GetOrdinal("Created_By");
            int created_TimeColumnIndex   = reader.GetOrdinal("Created_Time");
            int updated_ByColumnIndex     = reader.GetOrdinal("Updated_By");
            int updated_TimeColumnIndex   = reader.GetOrdinal("Updated_Time");

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

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

                    record.GL_Act_Id      = Convert.ToInt32(reader.GetValue(gL_Act_IdColumnIndex));
                    record.GL_Act_Code    = Convert.ToInt32(reader.GetValue(gL_Act_CodeColumnIndex));
                    record.GL_Act_Name    = Convert.ToString(reader.GetValue(gL_Act_NameColumnIndex));
                    record.GL_Act_Type_Id = Convert.ToInt32(reader.GetValue(gL_Act_Type_IdColumnIndex));
                    record.Status         = Convert.ToBoolean(reader.GetValue(statusColumnIndex));
                    record.Created_By     = Convert.ToInt32(reader.GetValue(created_ByColumnIndex));
                    record.Created_Time   = Convert.ToDateTime(reader.GetValue(created_TimeColumnIndex));
                    record.Updated_By     = Convert.ToInt32(reader.GetValue(updated_ByColumnIndex));
                    record.Updated_Time   = Convert.ToDateTime(reader.GetValue(updated_TimeColumnIndex));

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

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((tblGL_AccountRow[])(recordList.ToArray(typeof(tblGL_AccountRow))));
        }
        /// <summary>
        /// Adds a new record into the <c>tblGL_Account</c> table.
        /// </summary>
        /// <param name="value">The <see cref="tblGL_AccountRow"/> object to be inserted.</param>
        public virtual void Insert(tblGL_AccountRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._tblGL_Account_Insert", true);

            AddParameter(cmd, "GL_Act_Code", value.GL_Act_Code);
            AddParameter(cmd, "GL_Act_Name", value.GL_Act_Name);
            AddParameter(cmd, "GL_Act_Type_Id", value.GL_Act_Type_Id);
            AddParameter(cmd, "Status", value.Status);
            AddParameter(cmd, "Created_By", value.Created_By);
            AddParameter(cmd, "Created_Time", value.Created_Time);
            AddParameter(cmd, "Updated_By", value.Updated_By);
            AddParameter(cmd, "Updated_Time", value.Updated_Time);
            value.GL_Act_Id = Convert.ToInt32(cmd.ExecuteScalar());
        }
        /// <summary>
        /// Updates a record in the <c>tblGL_Account</c> table.
        /// </summary>
        /// <param name="value">The <see cref="tblGL_AccountRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(tblGL_AccountRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._tblGL_Account_Update", true);

            AddParameter(cmd, "GL_Act_Code", value.GL_Act_Code);
            AddParameter(cmd, "GL_Act_Name", value.GL_Act_Name);
            AddParameter(cmd, "GL_Act_Type_Id", value.GL_Act_Type_Id);
            AddParameter(cmd, "Status", value.Status);
            AddParameter(cmd, "Created_By", value.Created_By);
            AddParameter(cmd, "Created_Time", value.Created_Time);
            AddParameter(cmd, "Updated_By", value.Updated_By);
            AddParameter(cmd, "Updated_Time", value.Updated_Time);
            AddParameter(cmd, "GL_Act_Id", value.GL_Act_Id);
            return(0 != cmd.ExecuteNonQuery());
        }
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="tblGL_AccountRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="tblGL_AccountRow"/> object.</returns>
        protected virtual tblGL_AccountRow MapRow(DataRow row)
        {
            tblGL_AccountRow mappedObject = new tblGL_AccountRow();
            DataTable        dataTable    = row.Table;
            DataColumn       dataColumn;

            // Column "GL_Act_Id"
            dataColumn = dataTable.Columns["GL_Act_Id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.GL_Act_Id = (int)row[dataColumn];
            }
            // Column "GL_Act_Code"
            dataColumn = dataTable.Columns["GL_Act_Code"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.GL_Act_Code = (int)row[dataColumn];
            }
            // Column "GL_Act_Name"
            dataColumn = dataTable.Columns["GL_Act_Name"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.GL_Act_Name = (string)row[dataColumn];
            }
            // Column "GL_Act_Type_Id"
            dataColumn = dataTable.Columns["GL_Act_Type_Id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.GL_Act_Type_Id = (int)row[dataColumn];
            }
            // Column "Status"
            dataColumn = dataTable.Columns["Status"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Status = (bool)row[dataColumn];
            }
            // Column "Created_By"
            dataColumn = dataTable.Columns["Created_By"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Created_By = (int)row[dataColumn];
            }
            // Column "Created_Time"
            dataColumn = dataTable.Columns["Created_Time"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Created_Time = (System.DateTime)row[dataColumn];
            }
            // Column "Updated_By"
            dataColumn = dataTable.Columns["Updated_By"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Updated_By = (int)row[dataColumn];
            }
            // Column "Updated_Time"
            dataColumn = dataTable.Columns["Updated_Time"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Updated_Time = (System.DateTime)row[dataColumn];
            }
            return(mappedObject);
        }
 /// <summary>
 /// Deletes the specified object from the <c>tblGL_Account</c> table.
 /// </summary>
 /// <param name="value">The <see cref="tblGL_AccountRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(tblGL_AccountRow value)
 {
     return(DeleteByPrimaryKey(value.GL_Act_Id));
 }