private void page_Loaded(object sender, RoutedEventArgs e) { var source = DataManagement.RetrievePaymentDrafts(CurrentContract); if (CurrentContract != null) { dataGrid.ItemsSource = source; } Header.CurrentContract = CurrentContract; TotalPrice.Text = ((decimal)(DataManagement.ContractTotalAmount(CurrentContract))).ToString("N0"); try { Karkard.Text = ((decimal)(source.Max(s => s.CurrentSituationDraft))).ToString("N0"); PayableTotal.Text = ((decimal)(source.Sum(s => s.PayableAmount))).ToString("N0"); Progress.Text = ((decimal)((double)source.Max(s => s.CurrentSituationDraft) * 100 / DataManagement.ContractTotalAmount(CurrentContract))).ToString("F2"); } catch (System.Exception ex) { } }