private void GetProfit_Click(object sender, RoutedEventArgs e) { var startDate = StartDateProfit.SelectedDate; var endDate = EndDateProfit.SelectedDate; if (startDate != null && endDate != null) { var sessions = pm.GetSessionsByDate(startDate, endDate); TotalProfitBox.Text = pm.TotalProfit(sessions).ToString(); } else { MessageBox.Show("Please enter both dates"); } }