Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Setting Default Value on New
Message
De
29/04/2013 10:28:27
 
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01572104
Message ID:
01572156
Vues:
36
>Frank,
>
>>I have a Receipt BO which has code to set the default date of the BO to the current date. Works fine. The client has now asked me to default the Receipt date to the last Receipt date entered on my form.
>>
>>I've created a property of the window called lastDate and set it initially to the current date.
>>
>>Then in my New button's click method I:
>>
>>this.Receipt.Entity.rct_date = lastDate;
>>
>>In my window's HookPostSave I do this:
>>
>>lastDate = this.Receipt.Entity.rct_date;
>>
>>But whenever I add a new Receipt it still shows up as today's date.
>>
>>Any ideas where I am going wrong?
>
>I recommend setting a breakpoint on the entity property that triggers whenever the value has changed. Either the current date value is not getting set initially or you are overwriting the current date with today's date later on in the cycle.
>
>Best Regards,

Hi Kevin,

I've never worked out how to set a breakpoint on when a value changes like we do in VFP. Any instructions?

For now, I've set a breakpoint in the Entity property's set code. Interestingly, this never runs during the save or when I've changed the date on the screen. Maybe there is something wrong with my binding?

I have the datacontext of the window set like this:

this.DataContext = this.Receipt.DataSet.Tables[this.Receipt.TableName].DefaultView;

and the xaml for this is:
<DatePicker 
Grid.Column="1" 
Grid.Row="1" 
Grid.RowSpan="1" 
Height="25" 
HorizontalAlignment="Left" 
Margin="0" 
Name="dtpRct_Date" 
VerticalAlignment="Center" 
Text="{Binding rct_date, StringFormat=d, Mode=Default}" 
SelectedDateFormat="Short" />
Maybe I should not be referring to this.Receipt.Entity.rct_date but to the the column of the dataset table?

But then again, I have this code in my New Button Click():
        private void btnNew_Click(object sender, RoutedEventArgs e)
        {
            this.IgnoreNavigation = true;

            if (this.grdReceipts.Items.Count == 0)
            {
                this.DataContext = this.Receipt.EntityList;
            }
            this.grdReceipts.SelectedItem = this.Receipt.Entity;
            this.Receipt.Entity.rct_date = lastDate;

            this.IgnoreNavigation = false;
            this.txtRct_Number.Visibility = Visibility.Collapsed;
        }
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform