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 check_list_DataGrid_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { try { IClientDAO clientDAO = new ClientFileDAO(new ConfigMgr()); if (e.EditAction == DataGridEditAction.Commit && this.checkListSearchedClient != null) { this.checkListSearchedClient.CheckListRows[e.Row.GetIndex()] = e.Row.DataContext as CheckListRow; Type checkListRowType = typeof(CheckListRow); checkListRowType.GetProperty(e.Column.SortMemberPath).SetValue(this.checkListSearchedClient.CheckListRows[e.Row.GetIndex()], ((TextBox)e.EditingElement).Text); clientDAO.UpdateClient(this.checkListSearchedClient); } DisplaySnackbar("הנתונים נשמרו בהצלחה"); } catch (FileNotFoundException) { DisplaySnackbar("הקובץ לקוחות לא נמצא, בדוק בהגדרות מערכת את ההגדרות שלך"); } catch (Exception ex) { DisplaySnackbar("שגיאה כללית במערכת, אנא נסה שוב"); Logger log = new Logger(new ConfigMgr()); log.Error("general error on load tab", ex); } }
private void check_list_search_btn_Click(object sender, RoutedEventArgs e) { try { IClientDAO clientDAO = new ClientFileDAO(new ConfigMgr()); Client client = clientDAO.SearchClientByText(check_list_search.Text); if (client != null) { check_list_owner_name.Text = $"התיק בטיפולו של:{client.ContactForm.CaseOwnerValue}"; check_list_partner_1.Text = $"ת.ז: {client.ContactForm.Person_1.Id}, שם: {client.ContactForm.Person_1.FullName}"; check_list_partner_2.Text = $"ת.ז: {client.ContactForm.Person_2.Id}, שם: {client.ContactForm.Person_2.FullName}"; check_list_DataGrid.ItemsSource = client.CheckListRows; this.checkListSearchedClient = client; } else { DisplaySnackbar("לקוח לא נמצא"); } } catch (FileNotFoundException) { DisplaySnackbar("הקובץ לקוחות לא נמצא, בדוק בהגדרות מערכת את ההגדרות שלך"); } catch (Exception ex) { DisplaySnackbar("שגיאה כללית במערכת, אנא נסה שוב"); Logger log = new Logger(new ConfigMgr()); log.Error("general error on load tab", ex); } }
private void working_toggle_click(object sender, RoutedEventArgs e) { IClientDAO clientDAO = new ClientFileDAO(new ConfigMgr()); Client currentClient = clientDAO.GetClientById(currentClientInWorkScheduleTab.ContactForm.Person_1.Id, currentClientInWorkScheduleTab.ContactForm.Person_2.Id); try { if (currentClient.WorkingScheduleTime == null || currentClient.WorkingScheduleTime.WorkProperties == null) { currentClient.WorkingScheduleTime = new WorkingSchedule() { IsWorkingNow = false, WorkProperties = new List <WorkProperties>(), TotalWorkingTime = 0 }; } currentClient.WorkingScheduleTime.IsWorkingNow = !currentClient.WorkingScheduleTime.IsWorkingNow; if (currentClient.WorkingScheduleTime.IsWorkingNow) { currentClient.WorkingScheduleTime.LastWorkingStartTime = DateTime.Now; currentClient.WorkingScheduleTime.WorkProperties.Add(new WorkProperties() { StartTime = currentClient.WorkingScheduleTime.LastWorkingStartTime, EndTime = DateTime.Now, Comment = string.Empty, Owner = currentClient.ContactForm.CaseOwnerValue.Split(',')[0], PropIndex = currentClient.WorkingScheduleTime.WorkProperties.Count + 1 }); working_toggle.Content = "הפסקת עבודה על התיק"; } else { currentClient.WorkingScheduleTime.WorkProperties.Last().EndTime = DateTime.Now; double totalHours = currentClient.WorkingScheduleTime.WorkProperties.Aggregate(0.0, (acc, workTime) => acc + (workTime.EndTime - workTime.StartTime).TotalHours); currentClient.WorkingScheduleTime.TotalWorkingTime = Math.Round(totalHours, 3); total_working_schedule.Text = $"סך הכל זמן עבודה: {currentClient.WorkingScheduleTime.TotalWorkingTime}"; working_toggle.Content = "התחלת עבודה על התיק"; } working_schedule_data_grid.ItemsSource = currentClient.WorkingScheduleTime.WorkProperties; clientDAO.UpdateClient(currentClient); DisplaySnackbar("הנתונים נשמרו בהצלחה"); } catch (FileNotFoundException) { DisplaySnackbar("הקובץ לקוחות לא נמצא, בדוק בהגדרות מערכת את ההגדרות שלך"); } catch (Exception ex) { DisplaySnackbar("שגיאה כללית במערכת, אנא נסה שוב"); Logger log = new Logger(new ConfigMgr()); log.Error("general error on load tab", ex); } }
private void AddNewClient(ContactFormPerson contactFormDetails, List <CheckListRow> checkListRows) { Client client = new Client() { StatusValue = Enums.CaseStatuses[Client.YET_TO_BEGIN_STATUS_INDEX], ContactForm = contactFormDetails, CheckListRows = checkListRows }; client.CheckListRows[0].Person_1_value = client.ContactForm.Person_1.FullName; client.CheckListRows[0].Person_2_value = client.ContactForm.Person_2.FullName; IClientDAO clientDAO = new ClientFileDAO(new ConfigMgr()); clientDAO.AddNewClient(client); }
private void save_working_schedule_data_grid_Click(object sender, RoutedEventArgs e) { IClientDAO clientDAO = new ClientFileDAO(new ConfigMgr()); Client currentClient = clientDAO.GetClientById(currentClientInWorkScheduleTab.ContactForm.Person_1.Id, currentClientInWorkScheduleTab.ContactForm.Person_2.Id); List <WorkProperties> works = working_schedule_data_grid.ItemsSource as List <WorkProperties>; currentClient.WorkingScheduleTime.WorkProperties = works; double totalHours = currentClient.WorkingScheduleTime.WorkProperties.Aggregate(0.0, (acc, workTime) => acc + (workTime.EndTime - workTime.StartTime).TotalHours); currentClient.WorkingScheduleTime.TotalWorkingTime = Math.Round(totalHours, 3); total_working_schedule.Text = $"סך הכל זמן עבודה: {currentClient.WorkingScheduleTime.TotalWorkingTime}"; clientDAO.UpdateClient(currentClient); DisplaySnackbar("הנתונים נשמרו בהצלחה"); save_working_schedule_data_grid.IsEnabled = false; }
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 status_DataGrid_CellEditEnding(object sender, System.Windows.Controls.DataGridCellEditEndingEventArgs e) { try { IClientDAO clientDAO = new ClientFileDAO(new ConfigMgr()); if (e.EditAction == DataGridEditAction.Commit) { Client client = e.Row.DataContext as Client; var comboBox = e.EditingElement as ComboBox; client.StatusValue = comboBox.SelectedValue.ToString(); if (!Enums.CaseStatuses.Any(x => x == client.StatusValue)) { throw new ArgumentException("not valid status"); } clientDAO.UpdateClient(client); } DisplaySnackbar("הנתונים נשמרו בהצלחה"); } catch (FileNotFoundException) { DisplaySnackbar("הקובץ לקוחות לא נמצא, בדוק בהגדרות מערכת את ההגדרות שלך"); } catch (ArgumentException) { DisplaySnackbar("סטטוס לא קיים במערכת, השינוי לא נשמר אנא נסה סטטוס אחר"); } catch (Exception ex) { DisplaySnackbar("שגיאה כללית במערכת, אנא נסה שוב"); Logger log = new Logger(new ConfigMgr()); log.Error("general error on load tab", ex); } }
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); } }