private void btnEdit_Click(object sender, RoutedEventArgs e) { try { string name = txtName.Text; string surname = txtSurname.Text; Position position = Board.PositionsList.First(p => p.ToString() == cbPosition.Text); Board.CurrentlySelectedEmploy.employ.Name = name; Board.CurrentlySelectedEmploy.employ.Surname = surname; Board.CurrentlySelectedEmploy.employ.positionId = position.positionId; Board.CurrentlySelectedEmploy.position = position; if (BoardDB.GetDB().SaveChanges() == 1) { CollectionViewSource.GetDefaultView(Board.EmployAndPositionList).Refresh(); Board.ClearListsAndRestoreFromDB(); this.NavigationService.GoBack(); } else { lblError.Content = "Błąd edycji"; } } catch (InvalidOperationException err) { lblError.Content = err.Message; } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { try { string name = txtName.Text; string surname = txtSurname.Text; Position position = Board.PositionsList.First(p => p.ToString() == cbPosition.Text); var employ = new Employ(name, surname, position.positionId); BoardDB.GetEmployees().Add(employ); if (BoardDB.GetDB().SaveChanges() == 1) { Board.EmployAndPositionList.Add(new EmployAndPosition(employ, position)); this.NavigationService.GoBack(); } else { lblError.Content = "Błąd dodawania"; } } catch (InvalidOperationException err) { lblError.Content = err.Message; } }
private void btnEdit_Click(object sender, RoutedEventArgs e) { try { string name = txtName.Text; string description = txtDescription.Text; Employ assignee = BoardDB.GetEmployees().ToList().FirstOrDefault(employ => employ.ToString() == cbAssignee.Text); DateTime endDate = (DateTime)pickerDateEnd.SelectedDate; Board.CurrentlySelectedTask.task.Name = name; Board.CurrentlySelectedTask.task.Description = description; Board.CurrentlySelectedTask.task.TaskEndDate = endDate; Board.CurrentlySelectedTask.task.LastModifyDate = DateTime.Now; Board.CurrentlySelectedTask.task.employId = assignee.employId; Board.CurrentlySelectedTask.task.Estimation = Board.GetKeyForValue(cbEstimation.Text, Board.Estimates).estimateId; Board.CurrentlySelectedTask.employ = assignee; Column newColumn = Board.GetKeyForValue(cbColumn.Text, Board.Columns); Board.CurrentlySelectedTask.task.columnId = newColumn.columnId; BoardDB.GetDB().SaveChanges(); Board.ClearListsAndRestoreFromDB(); MainBoardPage boardPage = new MainBoardPage(); this.NavigationService.Navigate(boardPage); } catch (InvalidOperationException err) { lblError.Content = err.Message; } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { try { string name = txtName.Text; var position = new Position(name); BoardDB.GetPositions().Add(position); if (BoardDB.GetDB().SaveChanges() == 1) { Board.PositionsList.Add(position); this.NavigationService.GoBack(); } else { lblError.Content = "Błąd dodawania"; } } catch (InvalidOperationException err) { lblError.Content = err.Message; } }
private void btnRemove_Click(object sender, RoutedEventArgs e) { int index = ListOfPositions.SelectedIndex; if (index >= 0) { var position = Board.PositionsList[index]; if (position.positionId != 0) { BoardDB.GetPositions().Remove(position); if (BoardDB.GetDB().SaveChanges() == 1) { Board.PositionsList.RemoveAt(index); } } else { lblError.Content = "Nie można usunąć"; } } }
private void btnEdit_Click(object sender, RoutedEventArgs e) { try { string name = txtName.Text; Board.CurrentlySelectedPosition.Name = name; if (BoardDB.GetDB().SaveChanges() == 1) { CollectionViewSource.GetDefaultView(Board.PositionsList).Refresh(); this.NavigationService.GoBack(); } else { lblError.Content = "Błąd edycji"; } } catch (InvalidOperationException err) { lblError.Content = err.Message; } }
private void btnRemove_Click(object sender, RoutedEventArgs e) { int index = ListOfEmployees.SelectedIndex; if (index >= 0) { var employ = Board.EmployAndPositionList[index].employ; if (employ.employId != 0) { BoardDB.GetEmployees().Remove(employ); if (BoardDB.GetDB().SaveChanges() == 1) { Board.EmployAndPositionList.RemoveAt(index); Board.ClearListsAndRestoreFromDB(); } } else { lblError.Content = "Nie można usunąć"; } } }
/// <summary> /// returns Employees table from DB /// <example> /// <code> /// BoardDB.GetEmployees(); /// </code> /// </example> /// </summary> public static DbSet <Employ> GetEmployees() => BoardDB.GetDB().Employees;
/// <summary> /// saves changes in DB /// <example> /// <code> /// BoardDB.SaveChanges(); /// </code> /// </example> /// </summary> public static int SaveChanges() => BoardDB.GetDB().SaveChanges();
/// <summary> /// returns Positions table from DB /// <example> /// <code> /// BoardDB.GetPositions(); /// </code> /// </example> /// </summary> public static DbSet <Position> GetPositions() => BoardDB.GetDB().Positions;
/// <summary> /// returns Estimates table from DB /// <example> /// <code> /// BoardDB.GetEstimations(); /// </code> /// </example> /// </summary> public static DbSet <Estimate> GetEstimations() => BoardDB.GetDB().Estimates;
/// <summary> /// returns Columns table from DB /// <example> /// <code> /// BoardDB.GetColumns(); /// </code> /// </example> /// </summary> public static DbSet <Column> GetColumns() => BoardDB.GetDB().Columns;
/// <summary> /// returns Tasks table from DB /// <example> /// <code> /// BoardDB.GetTasks(); /// </code> /// </example> /// </summary> public static DbSet <Task> GetTasks() => BoardDB.GetDB().Tasks;