/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="tblGeneral_JournalRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="tblGeneral_JournalRow"/> object.</returns> protected virtual tblGeneral_JournalRow MapRow(DataRow row) { tblGeneral_JournalRow mappedObject = new tblGeneral_JournalRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "GL_Id" dataColumn = dataTable.Columns["GL_Id"]; if (!row.IsNull(dataColumn)) { mappedObject.GL_Id = (int)row[dataColumn]; } // Column "GL_Date" dataColumn = dataTable.Columns["GL_Date"]; if (!row.IsNull(dataColumn)) { mappedObject.GL_Date = (System.DateTime)row[dataColumn]; } // Column "Reference" dataColumn = dataTable.Columns["Reference"]; if (!row.IsNull(dataColumn)) { mappedObject.Reference = (string)row[dataColumn]; } // Column "GL_Act_Id" dataColumn = dataTable.Columns["GL_Act_Id"]; if (!row.IsNull(dataColumn)) { mappedObject.GL_Act_Id = (int)row[dataColumn]; } // Column "Debit" dataColumn = dataTable.Columns["Debit"]; if (!row.IsNull(dataColumn)) { mappedObject.Debit = (int)row[dataColumn]; } // Column "Credit" dataColumn = dataTable.Columns["Credit"]; if (!row.IsNull(dataColumn)) { mappedObject.Credit = (int)row[dataColumn]; } // Column "Donor_Id" dataColumn = dataTable.Columns["Donor_Id"]; if (!row.IsNull(dataColumn)) { mappedObject.Donor_Id = (int)row[dataColumn]; } // Column "Company_Id" dataColumn = dataTable.Columns["Company_Id"]; if (!row.IsNull(dataColumn)) { mappedObject.Company_Id = (int)row[dataColumn]; } return(mappedObject); }
/// <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="tblGeneral_JournalRow"/> objects.</returns> protected virtual tblGeneral_JournalRow[] 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_IdColumnIndex = reader.GetOrdinal("GL_Id"); int gL_DateColumnIndex = reader.GetOrdinal("GL_Date"); int referenceColumnIndex = reader.GetOrdinal("Reference"); int gL_Act_IdColumnIndex = reader.GetOrdinal("GL_Act_Id"); int debitColumnIndex = reader.GetOrdinal("Debit"); int creditColumnIndex = reader.GetOrdinal("Credit"); int donor_IdColumnIndex = reader.GetOrdinal("Donor_Id"); int company_IdColumnIndex = reader.GetOrdinal("Company_Id"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { tblGeneral_JournalRow record = new tblGeneral_JournalRow(); recordList.Add(record); record.GL_Id = Convert.ToInt32(reader.GetValue(gL_IdColumnIndex)); record.GL_Date = Convert.ToDateTime(reader.GetValue(gL_DateColumnIndex)); if (!reader.IsDBNull(referenceColumnIndex)) { record.Reference = Convert.ToString(reader.GetValue(referenceColumnIndex)); } record.GL_Act_Id = Convert.ToInt32(reader.GetValue(gL_Act_IdColumnIndex)); record.Debit = Convert.ToInt32(reader.GetValue(debitColumnIndex)); record.Credit = Convert.ToInt32(reader.GetValue(creditColumnIndex)); record.Donor_Id = Convert.ToInt32(reader.GetValue(donor_IdColumnIndex)); record.Company_Id = Convert.ToInt32(reader.GetValue(company_IdColumnIndex)); if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((tblGeneral_JournalRow[])(recordList.ToArray(typeof(tblGeneral_JournalRow)))); }
/// <summary> /// Adds a new record into the <c>tblGeneral_Journal</c> table. /// </summary> /// <param name="value">The <see cref="tblGeneral_JournalRow"/> object to be inserted.</param> public virtual void Insert(tblGeneral_JournalRow value) { IDbCommand cmd = _db.CreateCommand("dbo._tblGeneral_Journal_Insert", true); AddParameter(cmd, "GL_Date", value.GL_Date); AddParameter(cmd, "Reference", value.Reference); AddParameter(cmd, "GL_Act_Id", value.GL_Act_Id); AddParameter(cmd, "Debit", value.Debit); AddParameter(cmd, "Credit", value.Credit); AddParameter(cmd, "Donor_Id", value.Donor_Id); AddParameter(cmd, "Company_Id", value.Company_Id); value.GL_Id = Convert.ToInt32(cmd.ExecuteScalar()); }
/// <summary> /// Updates a record in the <c>tblGeneral_Journal</c> table. /// </summary> /// <param name="value">The <see cref="tblGeneral_JournalRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(tblGeneral_JournalRow value) { IDbCommand cmd = _db.CreateCommand("dbo._tblGeneral_Journal_Update", true); AddParameter(cmd, "GL_Date", value.GL_Date); AddParameter(cmd, "Reference", value.Reference); AddParameter(cmd, "GL_Act_Id", value.GL_Act_Id); AddParameter(cmd, "Debit", value.Debit); AddParameter(cmd, "Credit", value.Credit); AddParameter(cmd, "Donor_Id", value.Donor_Id); AddParameter(cmd, "Company_Id", value.Company_Id); AddParameter(cmd, "GL_Id", value.GL_Id); return(0 != cmd.ExecuteNonQuery()); }
/// <summary> /// Deletes the specified object from the <c>tblGeneral_Journal</c> table. /// </summary> /// <param name="value">The <see cref="tblGeneral_JournalRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(tblGeneral_JournalRow value) { return(DeleteByPrimaryKey(value.GL_Id)); }