Filed under: Programming
Author: Michael Earls

I was working on a report for a client and I had the need to provide a checkbox in a .NET report for some bit fields. I decided that the best way was to use the Wingdings font and create a custom expression for the output.

Here is the expression:

=IIF(Fields!IntlDues.Value,"x","o")

The value you use needs to be a bit field or you’ll have to convert it to boolean before you can run this check.

Then, simply set the font of the cell to Wingdings and that should do it. It’s not the best looking checkbox, but it works and looks OK.


Filed under: Computing,Programming
Author: Michael Earls

I have been working with .NET Entity Framework for a while now, but this has never come up before.  Basically, I want to show a data grid view with data in it from a view that contains a DISTINCT statement – like the following:

SELECT DISTINCT SSN,PayRate, CommodityType from MyTable

The problem with this is that I’m not using the table’s primary key, so EF won’t create an entity for me. It gives me an error about it not being able to infer the key. The problem here is that if I include the key in the output, I’ll blow the whole purpose of using DISTINCT.

Here’s how I solved it…

I changed my view to join on another related table based on the SSN…

SELECT DISTINCT MT.SSN, MT.PayRate, MT.CommodityType, MM.MemberId 
from MyTable as MT

INNER JOIN MembershipMaster as MM on MT.SSN = MM.SSN

MM.MemberId is the primary key for the MembershipMaster table, thereby giving EF a key to work with. It now will create an entity for this view.

But wait, there’s more.

When using this entity, it’s not going to fetch the correct data…

Let’s say that your view returned a set of data that contains 3 distinct records for an SSN that you’re looking for.

123456789 - 12.75 - C
123456789 - 13.50 - B

123456789 - 17.00 - C

When you do a Where on the entity set as follows:

IQueryable(myView) mve = entities.myViews.Where(mv => mv.SSN == "123456789");

mve contains three records (as expected), but they’re all a copy of the first result set:

123456789 - 12.75 - C

123456789 - 12.75 - C

123456789 - 12.75 - C

Oops. This is because the key that the entity is using is actually not unique in your view.

So, to solve this, we need to create a new output field that we can use as a key. I just concatenated thethree return values together and gave it a column name like so:

SELECT DISTINCT convert(nvarchar(9),MT.SSN) + convert(nvarchar(7), MT.PayRate) 
+ MT.CommodityType as RowKey, 
MT.SSN, MT.PayRate, MT.CommodityType, MM.MemberId 
from MyTable as MT

INNER JOIN MembershipMaster as MM on MT.SSN = MM.SSN

(PayRate is a numeric(5,2) and SSN is numeric(9,0), so they have to be converted)

Now, I simply updated my entity model from the database, and now I have a new Field on the Entity called “RowKey”. Simply right-click on the original key and deselect “Entity Key” and then right-click on RowKey and select “Entity Key”.

This will give you the desired results in your set:

IQueryable(myView) mve = entities.myViews.Where(mv => mv.SSN == "123456789");

Here are the results in the grid:

123456789 - 12.75 - C

123456789 - 13.50 - B

123456789 - 17.00 - C

There’s a bit more going on here because I have object datasources for each of these view entities so that they can be more easily worked with in the DataGridView UI form in the editor, but I think this gets the general point across.


Author: Michael Earls

Screenshot_2012-04-24_12_48_53_558911

 

I have a problem. It seems I can’t get through video games any more. I used to play games and beat them. Now, I’m lucky if I can get a few hours of enjoyment from them. I’ve had to restart Halo 3 three times because of various technical problems and I’m probably only about a third of the way through the game. In Star Wars: The Old Republic, I can’t seem to get past level 24 on my Jedi Consular character, and in World of Warcraft, I think I’m stuck at level 25 for my Mage. I’m at level 13 on Skyrim, but that one seems to be a bit easier than the others.

Maybe I’m just old or something, but I think games have gotten too hard to play these days.

 


Filed under: Opinion
Author: Michael Earls

I’m frightened at this new breed of zealot who is shifting the blame from the acts of a single human being to an entire sub-population of people. While this type of zealotry is not new, this specific breed is beginning to show extreme prejudice against the human rights of a large number of people who have done nothing wrong. This behavior has historically led to lynch mobs, civil wars, and genocide.

We must protect the innocent and stop this trend toward blaming others for the actions of a single person.


Author: Michael Earls

Star_Wars_Logo_svg

First, let me start off by saying how excited I am that Disney now owns Star Wars. I’m looking forward to what they do with the whole thing. It’s already licensed like crazy, so we shouldn’t see a big change there.

Now, on to their selection of JJ Abrams. I don’t have a problem with the fact that Star Wars and Star Trek will be directed by the same guy. It’s all good in my book. I have nothing against Star Trek, but I’m probably a bigger Star Wars fan (I own multiple Star Wars T-Shirts and not a single Star Trek shirt). Abrams kept me interested through an entire run of “Lost”, even if much of the story made no sense when you look back on it as a whole. It was still good entertainment, and that’s what I want Star Wars to be. I don’t want “true to canon”, I want entertainment in the Star Wars universe with Jedis(TM), Lightsabers(TM), Wookies(TM), Jawas(TM), Hutts(TM), Wampas(TM), Droids(TM), and all the other creatures we’ve come to expect from Star Wars(TM).

Update: It seems that Lawrence Kasdan will be writing a new film, as well. http://starwars.com/news/new-spinoff-films-set-to-expand-the-star-wars-galaxy.html

 


Filed under: Website
Author: Michael Earls
New site theme.

New site theme.

I’ve decided to move away from the magazine format due to the sheer amount of work it takes just to create a single post (each post required a post image of a specific size). I pulled out an old theme that I created back in 2010 and decided to use that instead. Check it out if you’re reading this on RSS. http://cerkit.com/blog/


Filed under: 3D Scultping
Author: Michael Earls

sculptris

After playing around with Blender, I realized that I’m just looking for a quick way to be creative with my computer. While browsing around, I found a software package named “Sculptris” (http://www.pixologic.com/sculptris/ ). It allows you to do digital sculpting. I plugged in my Wacom tablet and started making something. Not sure what it is, really, but it was fun to make.

Here is a video showing what a real sculptor can make with it:

http://www.youtube.com/watch?v=KrViiOLTWTM

I like using this program because it is pure art. There are some great videos on YouTube of people making digital sculptures.

 


Filed under: 3D Rendering
Author: Michael Earls

blender

I’ve been playing around with the GPL’d Blender 3D rendering software. After a few minutes, I was able to throw together a simple animation. I think I’d like to explore blender by creating a starship model.  I might start with a soda can first, though.

Anyway, here’s my movie…

Plane Slicing Cube 1


Filed under: Computing
Author: Michael Earls

I had originally posted an entry on my blog that was self-hosted on a server that I built in the Amazon EC2 cloud, but I decided to host the site with a hosting service instead. I decided this because the cloud service had already racked up $2.68 for the first 3 days of December. When I originally set up the server, I thought that the service would be free for the first year. I must have already used up my first free year, though.