Files
BeWoPlaner/BeWo/View/Detail/Report/SupportConceptsAnalysisView.xaml.cs
Christian 6fdeeff3d6 cb
2017-02-10 11:08:38 +01:00

216 lines
8.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using BeWo.Core;
using BeWo.ServiceProxy;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
namespace BeWo.View.Detail.Report
{
public partial class SupportConceptsAnalysisView : BeWoView
{
private Dictionary<string, List<SupportConceptOverviewDC>> _UnfilteredSupportConcept2Overviews;
private CompactEmployeeDC _SelectedEmployee;
private CompactTeamDC _SelectedTeam;
public SupportConceptsAnalysisView(Dictionary<string, List<SupportConceptOverviewDC>> pSupportConcept2Overviews)
{
this.InitializeComponent();
this.datepicker_appointeddate.AllowNullInput = true;
this.datepicker_appointeddate.EditValue = null;
this.chkShowOnlyMySupportConcepts.IsChecked = true;
_SelectedEmployee = BeWoApp.LoggedOnUser.Employee;
if (_SelectedEmployee != null)
{
popupedit_employee.Text = _SelectedEmployee.ToString();
}
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.SupportConcept_ViewAllSupportConcepts) && !BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll))
{
this.chkShowOnlyMySupportConcepts.IsEnabled = false;
checkbox_allEmployees.IsEnabled = false;
}
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.Analysis_EmployeeOverviewAll_View))
{
popupedit_employee.IsEnabled = false;
checkbox_allEmployees.IsEnabled = false;
}
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.Analysis_AllowFLSOverviewForAllTeams))
{
popupedit_team.IsEnabled = false;
checkbox_all_teams.IsEnabled = false;
}
ChkHpDieAuslaufen.Content =
String.Format("Nur Hilfepläne anzeigen, die innerhalb der nächsten {0} Monate auslaufen",
BeWoApp.AppSettings.HilfeplanAuslaufAuswahl);
// if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.Analysis_SupportConceptOverview_View))
// {
// Dictionary<string, List<SupportConceptOverviewDC>> filteredList = new Dictionary<string, List<SupportConceptOverviewDC>>();
// foreach (var item in pSupportConcept2Overviews)
// {
// (item.Value[0].
// }
// _UnfilteredSupportConcept2Overviews = filteredList;
// }
// else
// {
this._UnfilteredSupportConcept2Overviews = pSupportConcept2Overviews;
// }
this.DataContext = this._UnfilteredSupportConcept2Overviews;
this.Loaded += this.SupportConceptsAnalysisView_Loaded;
this.UpdateReportUrl();
}
private void SupportConceptsAnalysisView_Loaded(object sender, RoutedEventArgs e)
{
this.textbox_search.Focus();
}
private void UpdateReportUrl()
{
string url;
long showOnlyMySupportConcepts = this.chkShowOnlyMySupportConcepts.IsChecked.Value ? 1 : 0;
long showOnlySCsExpiringNextThreeMonths = this.ChkHpDieAuslaufen.IsChecked.Value ? 1 : 0;
long showArchived = this.chkShowArchived.IsChecked.Value ? 1 : 0;
long eOid = 0;
long tOid = 0;
if (_SelectedEmployee != null && checkbox_allEmployees.IsChecked == false)
{
eOid = _SelectedEmployee.EmployeeOid;
}
if (_SelectedTeam != null && checkbox_all_teams.IsChecked == false)
{
tOid = _SelectedTeam.TeamOid;
}
// if (ViewModel != null && ViewModel.ServiceRecordsForSelectedCustomer != null && ViewModel.ServiceRecordsForSelectedCustomer.Count > 0)
// {
url = BeWoApp.SiteOfOrigin + "/ReportView.aspx"
//+ "?tenant=" + BeWoApp.Tenant
//+ "&username=" + BeWoApp.UserName
//+ "&token=" + BeWoApp.LoggedOnUser.RC2Password
+ "?my=" + showOnlyMySupportConcepts
+ "&exp=" + showOnlySCsExpiringNextThreeMonths
+ "&arc=" + showArchived
+ "&eOid=" + eOid
+ "&tOid=" + tOid
+ "&type=" + Utils.EnumName(ReportTypes.SupportConceptReport);
if (datepicker_appointeddate.EditValue != null)
url += "&date=" + String.Format("{0:d}", datepicker_appointeddate.DateTime);
url = BeWoWpfUtils.GetHTMLEncodedURL(url);
this.linkPdfExport.NavigateUri = new Uri(url);
// }
}
private void buttonRefresh_Click(object sender, RoutedEventArgs e)
{
bool showOnlyRelated = this.chkShowOnlyMySupportConcepts.IsChecked.Value;
bool showOnlyArchivedSCs = this.chkShowArchived.IsChecked.Value;
this.UpdateReportUrl();
DateTime? dt = null;
if (this.datepicker_appointeddate.EditValue != null)
dt = this.datepicker_appointeddate.DateTime;
ServiceFacade.DoAnalysisServiceAsync(
s => s.GetSupportConceptAnalysis(BeWoApp.LoggedOnUser.Employee.EmployeeOid, showOnlyRelated, showOnlyArchivedSCs, dt),
r =>
{
this.Dispatch(
delegate
{
this._UnfilteredSupportConcept2Overviews = r.OrderBy(o => o.CustomerLastName + ", " + o.CustomerFirstName).GroupBy(so => so.CustomerLastName + ", " + so.CustomerFirstName).ToDictionary(g => g.Key, g => g.ToList());
this.DataContext = this._UnfilteredSupportConcept2Overviews;
});
});
}
private void listview_list_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (this.listview_list.SelectedItem != null)
{
(this.listview_list.ItemContainerGenerator.ContainerFromItem(this.listview_list.SelectedItem) as ListViewItem).IsSelected = false;
}
}
private void textbox_searchVisible_TextChanged(object sender, TextChangedEventArgs e)
{
String test = textbox_searchVisible.Text;
textbox_search.Text = test;
}
private void LinkPdfExport_OnRequestNavigate(object sender, RequestNavigateEventArgs e)
{
BeWoUtils.NavigateToReportUri((sender as System.Windows.Documents.Hyperlink).NavigateUri.ToString(), "Hilfeplanübersicht");
//System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo((sender as System.Windows.Documents.Hyperlink).NavigateUri.ToString()));
}
private void CheckBoxAllEmployees_Checked(object sender, RoutedEventArgs e)
{
if (popupedit_employee != null)
{
popupedit_employee.Text = string.Empty;
_SelectedEmployee = null;
}
}
private void popupedit_employee_PopUpClick(object sender, RoutedEventArgs e)
{
this.popup_employee.IsOpen = true;
}
private void CheckBoxAllTeams_Checked(object sender, RoutedEventArgs e)
{
if (popupedit_team != null)
{
popupedit_team.Text = string.Empty;
_SelectedTeam = null;
}
}
private void popupedit_team_PopUpClick(object sender, RoutedEventArgs e)
{
this.popup_team.IsOpen = true;
}
private void EmployeeSearchView_ItemSelected(object sender, EventArgs<CompactEmployeeDC> e)
{
_SelectedEmployee = e.Data;
popupedit_employee.Text = _SelectedEmployee.ToString();
popup_employee.IsOpen = false;
}
private void TeamSearchView_ItemSelected(object sender, EventArgs<CompactTeamDC> e)
{
_SelectedTeam = e.Data;
popupedit_team.Text = _SelectedTeam.ToString();
popup_team.IsOpen = false;
}
}
}