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

            // Column "Company_Id"
            dataColumn = dataTable.Columns["Company_Id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Company_Id = (int)row[dataColumn];
            }
            // Column "Company_Name"
            dataColumn = dataTable.Columns["Company_Name"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Company_Name = (string)row[dataColumn];
            }
            // Column "Address"
            dataColumn = dataTable.Columns["Address"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Address = (string)row[dataColumn];
            }
            // Column "Contact_Person"
            dataColumn = dataTable.Columns["Contact_Person"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Contact_Person = (string)row[dataColumn];
            }
            // Column "Contact_No"
            dataColumn = dataTable.Columns["Contact_No"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Contact_No = (string)row[dataColumn];
            }
            // Column "Email"
            dataColumn = dataTable.Columns["Email"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Email = (string)row[dataColumn];
            }
            // Column "Status"
            dataColumn = dataTable.Columns["Status"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Status = (bool)row[dataColumn];
            }
            // Column "IsDeleted"
            dataColumn = dataTable.Columns["IsDeleted"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.IsDeleted = (bool)row[dataColumn];
            }
            return(mappedObject);
        }
コード例 #2
0
        /// <summary>
        /// Adds a new record into the <c>tblcompany</c> table.
        /// </summary>
        /// <param name="value">The <see cref="tblcompanyRow"/> object to be inserted.</param>
        public virtual void Insert(tblcompanyRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._tblcompany_Insert", true);

            AddParameter(cmd, "Company_Name", value.Company_Name);
            AddParameter(cmd, "Address", value.Address);
            AddParameter(cmd, "Contact_Person", value.Contact_Person);
            AddParameter(cmd, "Contact_No", value.Contact_No);
            AddParameter(cmd, "Email", value.Email);
            AddParameter(cmd, "Status", value.Status);
            AddParameter(cmd, "IsDeleted", value.IsDeleted);
            value.Company_Id = Convert.ToInt32(cmd.ExecuteScalar());
        }
コード例 #3
0
        /// <summary>
        /// Updates a record in the <c>tblcompany</c> table.
        /// </summary>
        /// <param name="value">The <see cref="tblcompanyRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(tblcompanyRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._tblcompany_Update", true);

            AddParameter(cmd, "Company_Name", value.Company_Name);
            AddParameter(cmd, "Address", value.Address);
            AddParameter(cmd, "Contact_Person", value.Contact_Person);
            AddParameter(cmd, "Contact_No", value.Contact_No);
            AddParameter(cmd, "Email", value.Email);
            AddParameter(cmd, "Status", value.Status);
            AddParameter(cmd, "IsDeleted", value.IsDeleted);
            AddParameter(cmd, "Company_Id", value.Company_Id);
            return(0 != cmd.ExecuteNonQuery());
        }
コード例 #4
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="tblcompanyRow"/> objects.</returns>
        protected virtual tblcompanyRow[] 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 company_IdColumnIndex     = reader.GetOrdinal("Company_Id");
            int company_NameColumnIndex   = reader.GetOrdinal("Company_Name");
            int addressColumnIndex        = reader.GetOrdinal("Address");
            int contact_PersonColumnIndex = reader.GetOrdinal("Contact_Person");
            int contact_NoColumnIndex     = reader.GetOrdinal("Contact_No");
            int emailColumnIndex          = reader.GetOrdinal("Email");
            int statusColumnIndex         = reader.GetOrdinal("Status");
            int isDeletedColumnIndex      = reader.GetOrdinal("isDeleted");

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

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

                    record.Company_Id   = Convert.ToInt32(reader.GetValue(company_IdColumnIndex));
                    record.Company_Name = Convert.ToString(reader.GetValue(company_NameColumnIndex));
                    if (!reader.IsDBNull(addressColumnIndex))
                    {
                        record.Address = Convert.ToString(reader.GetValue(addressColumnIndex));
                    }
                    if (!reader.IsDBNull(contact_PersonColumnIndex))
                    {
                        record.Contact_Person = Convert.ToString(reader.GetValue(contact_PersonColumnIndex));
                    }
                    if (!reader.IsDBNull(contact_NoColumnIndex))
                    {
                        record.Contact_No = Convert.ToString(reader.GetValue(contact_NoColumnIndex));
                    }
                    if (!reader.IsDBNull(emailColumnIndex))
                    {
                        record.Email = Convert.ToString(reader.GetValue(emailColumnIndex));
                    }
                    record.Status    = Convert.ToBoolean(reader.GetValue(statusColumnIndex));
                    record.IsDeleted = Convert.ToBoolean(reader.GetValue(isDeletedColumnIndex));

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

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((tblcompanyRow[])(recordList.ToArray(typeof(tblcompanyRow))));
        }
コード例 #5
0
 /// <summary>
 /// Deletes the specified object from the <c>tblcompany</c> table.
 /// </summary>
 /// <param name="value">The <see cref="tblcompanyRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(tblcompanyRow value)
 {
     return(DeleteByPrimaryKey(value.Company_Id));
 }