/// <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="tblFundRow"/> objects.</returns> protected virtual tblFundRow[] 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 fund_IdColumnIndex = reader.GetOrdinal("Fund_Id"); int receipt_DateColumnIndex = reader.GetOrdinal("Receipt_Date"); int receiptNoColumnIndex = reader.GetOrdinal("ReceiptNo"); int referenceColumnIndex = reader.GetOrdinal("Reference"); int donor_IdColumnIndex = reader.GetOrdinal("Donor_Id"); int amountColumnIndex = reader.GetOrdinal("Amount"); int gL_Act_IdColumnIndex = reader.GetOrdinal("GL_Act_Id"); 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) { tblFundRow record = new tblFundRow(); recordList.Add(record); record.Fund_Id = Convert.ToInt32(reader.GetValue(fund_IdColumnIndex)); record.Receipt_Date = Convert.ToDateTime(reader.GetValue(receipt_DateColumnIndex)); record.ReceiptNo = Convert.ToString(reader.GetValue(receiptNoColumnIndex)); if (!reader.IsDBNull(referenceColumnIndex)) { record.Reference = Convert.ToString(reader.GetValue(referenceColumnIndex)); } record.Donor_Id = Convert.ToInt32(reader.GetValue(donor_IdColumnIndex)); record.Amount = Convert.ToInt32(reader.GetValue(amountColumnIndex)); record.GL_Act_Id = Convert.ToInt32(reader.GetValue(gL_Act_IdColumnIndex)); 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((tblFundRow[])(recordList.ToArray(typeof(tblFundRow)))); }
/// <summary> /// Adds a new record into the <c>tblFund</c> table. /// </summary> /// <param name="value">The <see cref="tblFundRow"/> object to be inserted.</param> public virtual void Insert(tblFundRow value) { IDbCommand cmd = _db.CreateCommand("dbo._tblFund_Insert", true); AddParameter(cmd, "Receipt_Date", value.Receipt_Date); AddParameter(cmd, "ReceiptNo", value.ReceiptNo); AddParameter(cmd, "Reference", value.Reference); AddParameter(cmd, "Donor_Id", value.Donor_Id); AddParameter(cmd, "Amount", value.Amount); AddParameter(cmd, "GL_Act_Id", value.GL_Act_Id); 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.Fund_Id = Convert.ToInt32(cmd.ExecuteScalar()); }
/// <summary> /// Updates a record in the <c>tblFund</c> table. /// </summary> /// <param name="value">The <see cref="tblFundRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(tblFundRow value) { IDbCommand cmd = _db.CreateCommand("dbo._tblFund_Update", true); AddParameter(cmd, "Receipt_Date", value.Receipt_Date); AddParameter(cmd, "ReceiptNo", value.ReceiptNo); AddParameter(cmd, "Reference", value.Reference); AddParameter(cmd, "Donor_Id", value.Donor_Id); AddParameter(cmd, "Amount", value.Amount); AddParameter(cmd, "GL_Act_Id", value.GL_Act_Id); 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, "Fund_Id", value.Fund_Id); return(0 != cmd.ExecuteNonQuery()); }
/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="tblFundRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="tblFundRow"/> object.</returns> protected virtual tblFundRow MapRow(DataRow row) { tblFundRow mappedObject = new tblFundRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Fund_Id" dataColumn = dataTable.Columns["Fund_Id"]; if (!row.IsNull(dataColumn)) { mappedObject.Fund_Id = (int)row[dataColumn]; } // Column "Receipt_Date" dataColumn = dataTable.Columns["Receipt_Date"]; if (!row.IsNull(dataColumn)) { mappedObject.Receipt_Date = (System.DateTime)row[dataColumn]; } // Column "ReceiptNo" dataColumn = dataTable.Columns["ReceiptNo"]; if (!row.IsNull(dataColumn)) { mappedObject.ReceiptNo = (string)row[dataColumn]; } // Column "Reference" dataColumn = dataTable.Columns["Reference"]; if (!row.IsNull(dataColumn)) { mappedObject.Reference = (string)row[dataColumn]; } // Column "Donor_Id" dataColumn = dataTable.Columns["Donor_Id"]; if (!row.IsNull(dataColumn)) { mappedObject.Donor_Id = (int)row[dataColumn]; } // Column "Amount" dataColumn = dataTable.Columns["Amount"]; if (!row.IsNull(dataColumn)) { mappedObject.Amount = (int)row[dataColumn]; } // Column "GL_Act_Id" dataColumn = dataTable.Columns["GL_Act_Id"]; if (!row.IsNull(dataColumn)) { mappedObject.GL_Act_Id = (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); }
/// <summary> /// Deletes the specified object from the <c>tblFund</c> table. /// </summary> /// <param name="value">The <see cref="tblFundRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(tblFundRow value) { return(DeleteByPrimaryKey(value.Fund_Id)); }