public EditTaskPage() { InitializeComponent(); txtName.Text = Board.CurrentlySelectedTask.Name; txtDescription.Text = Board.CurrentlySelectedTask.Description; pickerDateEnd.SelectedDate = Board.CurrentlySelectedTask.TaskEndDate; foreach (var s in Board.Estimates) { cbEstimation.Items.Add(s.Value); } foreach (var s in Board.Columns) { cbColumn.Items.Add(s.Value); } foreach (var employ in BoardDB.GetEmployees()) { cbAssignee.Items.Add(employ); } cbEstimation.Text = Board.CurrentlySelectedTask.Estimation; cbColumn.Text = Board.Columns[Board.CurrentlySelectedTask.task.columnId].ToString(); cbAssignee.Text = Board.CurrentlySelectedTask.Assign; }
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; } }
/// <summary> /// returns employees with position from BD /// <example> /// <code> /// IQueryable<EmployAndPosition> t = BoardDB.GetEmployeesAndPosition(); /// </code> /// </example> /// </summary> public static IQueryable <EmployAndPosition> GetEmployeesAndPosition() { var positions = BoardDB.GetPositions(); var employees = BoardDB.GetEmployees(); return(employees .Join(positions, employ => employ.positionId, position => position.positionId, (e, p) => new EmployAndPosition(e, p))); }
/// <summary> /// returns tasks with employees from BD /// <example> /// <code> /// long openColumnId = GetKeyForValue("Open", Columns).columnId;<para/> /// IQueryable<TaskAndEmploy> t = BoardDB.GetTasksAndEmployeesFromColumn(openColumnId); /// </code> /// </example> /// </summary> public static IQueryable <TaskAndEmploy> GetTasksAndEmployeesFromColumn(long columnId) { var tasks = BoardDB.GetTasks(); var employees = BoardDB.GetEmployees(); return(tasks .Where(t => t.columnId == columnId) .Join(employees, task => task.employId, employ => employ.employId, (t, e) => new TaskAndEmploy(t, e))); }
public AddNewCardPage() { InitializeComponent(); foreach (var s in Board.Estimates) { cbEstimation.Items.Add(s.Value); } foreach (var employ in BoardDB.GetEmployees()) { cbAssignee.Items.Add(employ); if (employ.employId == 0) { cbAssignee.Text = employ.ToString(); } } cbEstimation.Text = Board.Estimates.First().Value.Name; pickerDateEnd.SelectedDate = DateTime.Now.AddDays(7); }
private void btnAdd_Click(object sender, RoutedEventArgs e) { try { string name = txtName.Text; string description = txtDescription.Text; long employId = BoardDB.GetEmployees().ToList().First(employ => employ.ToString() == cbAssignee.Text).employId; long openColumnId = Board.GetKeyForValue("Open", Board.Columns).columnId; Estimate estimation = Board.GetKeyForValue <Estimate>(cbEstimation.Text, Board.Estimates); DateTime endDate = (DateTime)pickerDateEnd.SelectedDate; Task newTask = new Task(name, description, estimation, endDate, openColumnId, employId); Board.AddNewTaskToBoard(newTask); this.NavigationService.GoBack(); } 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 employ with given id /// <example> /// <code> /// BoardDB.GetEmploy(employId); /// </code> /// </example> /// </summary> public static Employ GetEmploy(long employId) => BoardDB.GetEmployees().FirstOrDefault(p => p.employId == employId);