private void client_status_search_btn_Click(object sender, RoutedEventArgs e) { string caseOwnerFilterValue = clients_status_filter_case_owner.SelectedValue.ToString(); string caseTypeFilterValue = clients_status_filter_case_type.SelectedValue.ToString(); IClientDAO clientDAO = new ClientFileDAO(new ConfigMgr()); List <Client> clients = clientDAO.GetClients(); Predicate <object> searchClientsPredicate = new Predicate <object>(x => (((Client)x).ContactForm.Person_1.FullName.Contains(clients_statuses_search.Text) || ((Client)x).ContactForm.Person_2.FullName.Contains(clients_statuses_search.Text) || ((Client)x).ContactForm.Person_1.Id.Contains(clients_statuses_search.Text) || ((Client)x).ContactForm.Person_2.Id.Contains(clients_statuses_search.Text)) && ((caseOwnerFilterValue == "הכל" || ((Client)x).ContactForm.CaseOwnerValue.Contains(caseOwnerFilterValue)) && (caseTypeFilterValue == "הכל" || ((Client)x).ContactForm.CaseInfo.CaseTypeValue == caseTypeFilterValue)) && (!clients_status_filter_min_date.SelectedDate.HasValue || clients_status_filter_min_date.SelectedDate.Value <= ((Client)x).ContactForm.CreationDate) && (!clients_status_filter_max_date.SelectedDate.HasValue || clients_status_filter_max_date.SelectedDate.Value >= ((Client)x).ContactForm.CreationDate)); List <string> groupbyProperties = new List <string>(); foreach (ListBoxItem item in clients_status_group_by.SelectedItems) { groupbyProperties.Add(item.DataContext.ToString()); } UpdateDataGridItems <Client>(clients_status_DataGrid, clients, searchClientsPredicate, groupbyProperties.ToArray()); }
private void clients_working_grid_search_btn_Click(object sender, RoutedEventArgs e) { double tmp; if ((clients_working_grid_search_time.Text != string.Empty && !double.TryParse(clients_working_grid_search_time.Text, out tmp)) || (clients_working_grid_search_total_time.Text != string.Empty && !double.TryParse(clients_working_grid_search_total_time.Text, out tmp))) { DisplaySnackbar("סינון לפי מספר שעות חייב להיות מספר"); return; } string caseOwnerFilterValue = clients_working_grid_search_case_owner.SelectedValue.ToString(); IClientDAO clientDAO = new ClientFileDAO(new ConfigMgr()); IEnumerable <Client> clients = clientDAO.GetClients(); IEnumerable <dynamic> worksDataGridClients = getWorkPropertiesDatagrid(clients); IEnumerable <dynamic> filteredWorksDataGrid = worksDataGridClients.Where(x => (caseOwnerFilterValue == "הכל" || ((WorkProperties)x.workPropsRow).Owner == caseOwnerFilterValue) && (clients_working_grid_search_total_time.Text == string.Empty || ((Client)x.client).WorkingScheduleTime.TotalWorkingTime >= double.Parse(clients_working_grid_search_total_time.Text)) && (clients_working_grid_search_time.Text == string.Empty || ((WorkProperties)x.workPropsRow).WorkingTime >= double.Parse(clients_working_grid_search_time.Text)) && (!clients_working_grid_filter_min_date.SelectedDate.HasValue || ((WorkProperties)x.workPropsRow).StartTime >= clients_working_grid_filter_min_date.SelectedDate.Value) && (!clients_working_grid_filter_max_date.SelectedDate.HasValue || ((WorkProperties)x.workPropsRow).EndTime <= clients_working_grid_filter_max_date.SelectedDate.Value)); if (clients_working_grid_group_by.SelectedItems.Count > 0) { UpdateDataGridItems(clients_working_data_grid, filteredWorksDataGrid, new Predicate <object>(x => true), "clientsNames"); } else { UpdateDataGridItems(clients_working_data_grid, filteredWorksDataGrid, new Predicate <object>(x => true)); } }
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { if (new_form_tab != null && new_form_tab.IsSelected && isSourceFromOtherTab) { isSourceFromOtherTab = false; } else if (new_form_tab != null && new_form_tab.IsSelected && e.Source.GetType() == typeof(TabControl)) { ClearNewClientFormTab(); case_owner.ItemsSource = Enums.CaseOwners; case_type.ItemsSource = CaseDetails.CaseTypes; court_name.ItemsSource = Enums.CourtsNames; } else if (check_list_tab != null && check_list_tab.IsSelected && e.Source.GetType() == typeof(TabControl)) { // TODO: on select tab } else if (clients_status_tab != null && clients_status_tab.IsSelected && e.Source.GetType() == typeof(TabControl)) { IClientDAO clientDAO = new ClientFileDAO(new ConfigMgr()); List <Client> clients = clientDAO.GetClients(); Predicate <object> allClientDefaultFilter = new Predicate <object>(item => (true)); UpdateDataGridItems <Client>(clients_status_DataGrid, clients, allClientDefaultFilter); clients_status_cell.ItemsSource = Enums.CaseStatuses; clients_status_filter_case_owner.ItemsSource = new string[] { "הכל" }.Concat(Enums.CaseOwners); clients_status_filter_case_type.ItemsSource = new string[] { "הכל" }.Concat(CaseDetails.CaseTypes); } else if (working_schedule_search_grid_tab != null && working_schedule_search_grid_tab.IsSelected && e.Source.GetType() == typeof(TabControl)) { IClientDAO clientDAO = new ClientFileDAO(new ConfigMgr()); List <Client> clients = clientDAO.GetClients(); IEnumerable <dynamic> clientsWorkingReportDataGrid = getWorkPropertiesDatagrid(clients); UpdateDataGridItems(clients_working_data_grid, clientsWorkingReportDataGrid, new Predicate <object>(x => true)); clients_working_grid_search_case_owner.ItemsSource = new string[] { "הכל" }.Concat(Enums.CaseOwners); } else if (dashboard_tab != null && dashboard_tab.IsSelected && e.Source.GetType() == typeof(TabControl)) { IClientDAO clientDAO = new ClientFileDAO(new ConfigMgr()); List <Client> clients = clientDAO.GetClients(); dashboard_chart_by_owner.ItemsSource = clients.GroupBy(client => client.ContactForm.CaseOwnerValue) .Select(group => new { Metric = group.Key, Count = group.Count() }); dashboard_chart_by_status.ItemsSource = clients.GroupBy(client => client.StatusValue) .Select(group => new { Metric = group.Key, Count = group.Count() }); dashboard_chart_by_create_time.ItemsSource = clients.Where(client => client.ContactForm.CreationDate.Year == DateTime.Now.Year).GroupBy(client => $"{client.ContactForm.CreationDate:MM/yyyy}") .Select(group => new { Metric = group.Key, Count = group.Count() }).OrderBy((group) => { CultureInfo provider = CultureInfo.InvariantCulture; return(DateTime.ParseExact(group.Metric, "MM/yyyy", CultureInfo.InvariantCulture)); }); dashboard_chart_by_case_type.ItemsSource = clients.GroupBy(client => client.ContactForm.CaseInfo.CaseTypeValue) .Select(group => new { Metric = group.Key, Count = group.Count() }); } else if (settings_tab != null && settings_tab.IsSelected && e.Source.GetType() == typeof(TabControl)) { ConfigMgr configMgr = new ConfigMgr(); destenation_folder.Text = configMgr.GetDestenationPath(); clients_archive_file_path.Text = configMgr.GetClientArchivePathPath(); system_version_name.Text = $"גרסת מערכת: {configMgr.GetSystemVersionName()}"; case_owners_edit_list.Text = string.Join(',', Enums.CaseOwners); } } catch (FileNotFoundException) { DisplaySnackbar("הקובץ לקוחות לא נמצא, בדוק בהגדרות מערכת את ההגדרות שלך"); } catch (Exception ex) { DisplaySnackbar("שגיאה כללית במערכת, אנא נסה שוב"); Logger log = new Logger(new ConfigMgr()); log.Error("general error on load tab", ex); } }