private VoucherEditDto FetchVoucherEdit(SafeDataReader dr)
        {
            var voucherEdit = new VoucherEditDto();
            // Value properties
            voucherEdit.Id = dr.GetInt32("tran_id");
            voucherEdit.Amount = (Decimal?)dr.GetValue("tran_amount");
            voucherEdit.PersonId = !dr.IsDBNull("person_id") ? dr.GetString("person_id") : null;
            voucherEdit.NamePrefix = !dr.IsDBNull("name_prefix") ? dr.GetString("name_prefix") : null;
            voucherEdit.First = !dr.IsDBNull("first_name") ? dr.GetString("first_name") : null;
            voucherEdit.Middle = !dr.IsDBNull("middle_name") ? dr.GetString("middle_name") : null;
            voucherEdit.Last = !dr.IsDBNull("last_name") ? dr.GetString("last_name") : null;
            voucherEdit.Suffix = !dr.IsDBNull("name_suffix") ? dr.GetString("name_suffix") : null;
            voucherEdit.Title = !dr.IsDBNull("title") ? dr.GetString("title") : null;
            voucherEdit.Company = !dr.IsDBNull("company") ? dr.GetString("company") : null;
            voucherEdit.AddressLine1 = !dr.IsDBNull("address_1") ? dr.GetString("address_1") : null;
            voucherEdit.AddressLine2 = !dr.IsDBNull("address_2") ? dr.GetString("address_2") : null;
            voucherEdit.Municipality = !dr.IsDBNull("municipality") ? dr.GetString("municipality") : null;
            voucherEdit.Region = !dr.IsDBNull("region") ? dr.GetString("region") : null;
            voucherEdit.PostalCode = !dr.IsDBNull("postal_code") ? dr.GetString("postal_code") : null;
            voucherEdit.Country = !dr.IsDBNull("country") ? dr.GetString("country") : null;
            voucherEdit.PhoneNumber = !dr.IsDBNull("phone_number") ? dr.GetString("phone_number") : null;
            voucherEdit.EmailAddress = !dr.IsDBNull("email") ? dr.GetString("email") : null;
            voucherEdit.Updated = !dr.IsDBNull("updated") ? dr.GetSmartDate("updated", true) : null;

            return voucherEdit;
        }
 /// <summary>
 /// Updates in the database all changes made to the VoucherEdit object.
 /// </summary>
 /// <param name="voucherEdit">The Voucher Edit DTO.</param>
 /// <returns>The updated <see cref="VoucherEditDto"/>.</returns>
 public VoucherEditDto Update(VoucherEditDto voucherEdit)
 {
     using (var ctx = ConnectionManager<SqlConnection>.GetManager("MyDatabase"))
     {
         using (var cmd = new SqlCommand("dbo.UpdateVoucherEdit", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@tran_id", voucherEdit.Id).DbType = DbType.Int32;
             cmd.Parameters.AddWithValue("@tran_amount", voucherEdit.Amount == null ? (object)DBNull.Value : voucherEdit.Amount.Value).DbType = DbType.Decimal;
             cmd.Parameters.AddWithValue("@person_id", voucherEdit.PersonId == null ? (object)DBNull.Value : voucherEdit.PersonId).DbType = DbType.String;
             cmd.Parameters.AddWithValue("@name_prefix", voucherEdit.NamePrefix == null ? (object)DBNull.Value : voucherEdit.NamePrefix).DbType = DbType.String;
             cmd.Parameters.AddWithValue("@first_name", voucherEdit.First == null ? (object)DBNull.Value : voucherEdit.First).DbType = DbType.String;
             cmd.Parameters.AddWithValue("@middle_name", voucherEdit.Middle == null ? (object)DBNull.Value : voucherEdit.Middle).DbType = DbType.String;
             cmd.Parameters.AddWithValue("@last_name", voucherEdit.Last == null ? (object)DBNull.Value : voucherEdit.Last).DbType = DbType.String;
             cmd.Parameters.AddWithValue("@name_suffix", voucherEdit.Suffix == null ? (object)DBNull.Value : voucherEdit.Suffix).DbType = DbType.String;
             cmd.Parameters.AddWithValue("@title", voucherEdit.Title == null ? (object)DBNull.Value : voucherEdit.Title).DbType = DbType.String;
             cmd.Parameters.AddWithValue("@company", voucherEdit.Company == null ? (object)DBNull.Value : voucherEdit.Company).DbType = DbType.String;
             cmd.Parameters.AddWithValue("@address_1", voucherEdit.AddressLine1 == null ? (object)DBNull.Value : voucherEdit.AddressLine1).DbType = DbType.String;
             cmd.Parameters.AddWithValue("@address_2", voucherEdit.AddressLine2 == null ? (object)DBNull.Value : voucherEdit.AddressLine2).DbType = DbType.String;
             cmd.Parameters.AddWithValue("@municipality", voucherEdit.Municipality == null ? (object)DBNull.Value : voucherEdit.Municipality).DbType = DbType.String;
             cmd.Parameters.AddWithValue("@region", voucherEdit.Region == null ? (object)DBNull.Value : voucherEdit.Region).DbType = DbType.String;
             cmd.Parameters.AddWithValue("@postal_code", voucherEdit.PostalCode == null ? (object)DBNull.Value : voucherEdit.PostalCode).DbType = DbType.String;
             cmd.Parameters.AddWithValue("@country", voucherEdit.Country == null ? (object)DBNull.Value : voucherEdit.Country).DbType = DbType.StringFixedLength;
             cmd.Parameters.AddWithValue("@phone_number", voucherEdit.PhoneNumber == null ? (object)DBNull.Value : voucherEdit.PhoneNumber).DbType = DbType.String;
             cmd.Parameters.AddWithValue("@email", voucherEdit.EmailAddress == null ? (object)DBNull.Value : voucherEdit.EmailAddress).DbType = DbType.String;
             cmd.Parameters.AddWithValue("@updated", voucherEdit.Updated.DBValue).DbType = DbType.DateTime;
             var rowsAffected = cmd.ExecuteNonQuery();
             if (rowsAffected == 0)
                 throw new DataNotFoundException("VoucherEdit");
         }
     }
     return voucherEdit;
 }