mcalex
mcalex

Reputation: 6798

Populating a field in wpf

I have a database of finance info and i want to check that supplied totals 'add up'. I have added fields to the database for the check data and am using data binding via the Entity Framework. How do i populate these 'check' fields while the user is adding data to the record?

Eg The form contains SubtotalA, SubtotalB and TotalAB textboxes. The database has these fields plus CheckTotalAB. The user keys in SubtotalA, SubtotalB and TotalAB from a hard copy form. I want to populate CheckTotalAB with the sum of SubtotalA and SubtotalB to compare against the provided TotalAB.

I first tried getting the data from the textboxes. Unfortunately txtSubtotalA.Value doesn't exist.

I then thought I'd have to go to the entity itself. Unfortunately I don't know how to access the current record/entity being entered and if I did, how would I access the value of fields that haven't been saved yet.

Can someone point me in the right direction?

tia
mcalex

Upvotes: 0

Views: 134

Answers (1)

mcalex
mcalex

Reputation: 6798

Accessing the entity was the answer. This was accomplished through use of an entity property in the datacontext that i set to equal a class member i added to my form class.

After that getting to the entity's fields including my calculated fields was just a case of getting/setting the member's properties.

Upvotes: 1

Related Questions