<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-NZ link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='color:#1F497D'>TDatasource.OnDataChange will
fire each time there is an edit to one of the fields. However note with many
controls if the user changes the value it doesn’t send the new value to the
field immediately, this often only happens when the user tabs out or hits enter
(depends on the controls but tab should always do it). <o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>By if field is assigned I meant
the code:<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>If Assigned(Field) then begin<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> ...<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>Note that this is the same as:<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>If Field <> nil then begin<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'> ...<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>I can’t help feeling that your
total price won’t be affected directly by all 23 fields, instead it is probably
only affected by a few fields (eg maybe Quantity, Square Foot Price and
Discount). So you should only need to update total price when one of those
three changes. Note that TDataSource.OnDataChange will fire if a field value is
changed in code too so you CalculatePrice routine will trigger OnDataChange
with a parameter of SquareFootPrice.<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>David.<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>
<p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> delphi-bounces@delphi.org.nz
[mailto:delphi-bounces@delphi.org.nz] <b>On Behalf Of </b>Charlie<br>
<b>Sent:</b> Monday, 19 October 2009 3:07 a.m.<br>
<b>To:</b> 'NZ Borland Developers Group - Delphi List'<br>
<b>Subject:</b> Re: [DUG] Which event to use<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span lang=EN-US style='font-size:14.0pt;color:#1F497D'>Thanks
David for your help.<o:p></o:p></span></p>
<p class=MsoNormal><span style='color:#1F497D'>RE: If Field is assigned then
that is the field which just changed so you can check if Field is one of the
fields which should modify the price and if so call your routine for
recalculating the price.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:14.0pt;color:#1F497D'>There are 24
fields for each orderdetail record. 23 of these have an effect either on the
square foot price or the total for the record. Of course the square foot price
has an effect on the total since the square foot price is multiplied by the
quantity and the square feet of the box. To this is added the upcharges for
various options to arrive at the total for the box.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:14.0pt;color:#1F497D'>12 of the 24
fields are always used for each box.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:14.0pt;color:#1F497D'>Am I right in
understanding that the TDataSource.OnDataChange will fire each time there is an
edit to each of these 24 fields? By edit I’m thinking of a change in the
existing value in the control, deleting the value in the control, adding
a value to the control. If any of these things occur in one of the 23 fields
this could effect either the square foot price or the record total.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:14.0pt;color:#1F497D'>I’m not quite
sure what ‘If Field is Assigned’ really means. <o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:14.0pt;color:#1F497D'>There are two
fields that are used to set values for all boxes for the orders. The InfoPower
dbLookupCombo (which I use for these) has a OnCloseUp which I use for those two
fields. But these values can be overridden by corresponding fields for a
record. Again I use the InfoPower dbLookupCombo and it’s OnCloseUp event to
call the ‘calculate’ price method. It appears I wouldn’t have to do that if I
use the TDataSource.OnDataChange event.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:14.0pt;color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:14.0pt;color:#1F497D'>Appreciate your
help, David. Thanks to all.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:14.0pt;color:#1F497D'>Charlie <o:p></o:p></span></p>
</div>
</body>
</html>