Beispiel #1
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="tblBudgetRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="tblBudgetRow"/> object.</returns>
        protected virtual tblBudgetRow MapRow(DataRow row)
        {
            tblBudgetRow mappedObject = new tblBudgetRow();
            DataTable    dataTable    = row.Table;
            DataColumn   dataColumn;

            // Column "Budget_Id"
            dataColumn = dataTable.Columns["Budget_Id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Budget_Id = (int)row[dataColumn];
            }
            // Column "Year"
            dataColumn = dataTable.Columns["Year"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Year = (System.DateTime)row[dataColumn];
            }
            // Column "GL_Act_Id"
            dataColumn = dataTable.Columns["GL_Act_Id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.GL_Act_Id = (int)row[dataColumn];
            }
            // Column "Amount"
            dataColumn = dataTable.Columns["Amount"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Amount = (int)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);
        }
Beispiel #2
0
        /// <summary>
        /// Adds a new record into the <c>tblBudget</c> table.
        /// </summary>
        /// <param name="value">The <see cref="tblBudgetRow"/> object to be inserted.</param>
        public virtual void Insert(tblBudgetRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._tblBudget_Insert", true);

            AddParameter(cmd, "Year", value.Year);
            AddParameter(cmd, "GL_Act_Id", value.GL_Act_Id);
            AddParameter(cmd, "Amount", value.Amount);
            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.Budget_Id = Convert.ToInt32(cmd.ExecuteScalar());
        }
Beispiel #3
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="tblBudgetRow"/> objects.</returns>
        protected virtual tblBudgetRow[] 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 budget_IdColumnIndex    = reader.GetOrdinal("Budget_Id");
            int yearColumnIndex         = reader.GetOrdinal("Year");
            int gL_Act_IdColumnIndex    = reader.GetOrdinal("GL_Act_Id");
            int amountColumnIndex       = reader.GetOrdinal("Amount");
            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)
                {
                    tblBudgetRow record = new tblBudgetRow();
                    recordList.Add(record);

                    record.Budget_Id    = Convert.ToInt32(reader.GetValue(budget_IdColumnIndex));
                    record.Year         = Convert.ToDateTime(reader.GetValue(yearColumnIndex));
                    record.GL_Act_Id    = Convert.ToInt32(reader.GetValue(gL_Act_IdColumnIndex));
                    record.Amount       = Convert.ToInt32(reader.GetValue(amountColumnIndex));
                    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((tblBudgetRow[])(recordList.ToArray(typeof(tblBudgetRow))));
        }
Beispiel #4
0
        /// <summary>
        /// Updates a record in the <c>tblBudget</c> table.
        /// </summary>
        /// <param name="value">The <see cref="tblBudgetRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(tblBudgetRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._tblBudget_Update", true);

            AddParameter(cmd, "Year", value.Year);
            AddParameter(cmd, "GL_Act_Id", value.GL_Act_Id);
            AddParameter(cmd, "Amount", value.Amount);
            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, "Budget_Id", value.Budget_Id);
            return(0 != cmd.ExecuteNonQuery());
        }
Beispiel #5
0
 /// <summary>
 /// Deletes the specified object from the <c>tblBudget</c> table.
 /// </summary>
 /// <param name="value">The <see cref="tblBudgetRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(tblBudgetRow value)
 {
     return(DeleteByPrimaryKey(value.Budget_Id));
 }