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 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 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 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); } }