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

            // Column "DoctorIDD"
            dataColumn = dataTable.Columns["DoctorIDD"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.DoctorIDD = (int)row[dataColumn];
            }
            // Column "Name"
            dataColumn = dataTable.Columns["Name"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Name = (string)row[dataColumn];
            }
            // Column "Address"
            dataColumn = dataTable.Columns["Address"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Address = (string)row[dataColumn];
            }
            // Column "Phone"
            dataColumn = dataTable.Columns["Phone"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Phone = (string)row[dataColumn];
            }
            return(mappedObject);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a new record into the <c>DoctorInfo</c> table.
        /// </summary>
        /// <param name="value">The <see cref="DoctorInfoRow"/> object to be inserted.</param>
        public virtual void Insert(DoctorInfoRow value)
        {
            SqlCommand cmd = _db.CreateCommand("dbo._DoctorInfo_Insert", true);

            AddParameter(cmd, "Name", value.Name);
            AddParameter(cmd, "Address", value.Address);
            AddParameter(cmd, "Phone", value.Phone);
            value.DoctorIDD = Convert.ToInt32(cmd.ExecuteScalar());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Updates a record in the <c>DoctorInfo</c> table.
        /// </summary>
        /// <param name="value">The <see cref="DoctorInfoRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(DoctorInfoRow value)
        {
            SqlCommand cmd = _db.CreateCommand("dbo._DoctorInfo_Update", true);

            AddParameter(cmd, "Name", value.Name);
            AddParameter(cmd, "Address", value.Address);
            AddParameter(cmd, "Phone", value.Phone);
            AddParameter(cmd, "DoctorIDD", value.DoctorIDD);
            return(0 != cmd.ExecuteNonQuery());
        }
Exemplo n.º 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.SqlDataReader"/> 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="DoctorInfoRow"/> objects.</returns>
        protected virtual DoctorInfoRow[] MapRecords(SqlDataReader 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 doctorIDDColumnIndex = reader.GetOrdinal("DoctorIDD");
            int nameColumnIndex      = reader.GetOrdinal("Name");
            int addressColumnIndex   = reader.GetOrdinal("Address");
            int phoneColumnIndex     = reader.GetOrdinal("Phone");

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

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

                    record.DoctorIDD = Convert.ToInt32(reader.GetValue(doctorIDDColumnIndex));
                    record.Name      = Convert.ToString(reader.GetValue(nameColumnIndex));
                    if (!reader.IsDBNull(addressColumnIndex))
                    {
                        record.Address = Convert.ToString(reader.GetValue(addressColumnIndex));
                    }
                    if (!reader.IsDBNull(phoneColumnIndex))
                    {
                        record.Phone = Convert.ToString(reader.GetValue(phoneColumnIndex));
                    }

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

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