private void Confirm_Click(object sender, RoutedEventArgs e) { int newEmployeeID = EmployeeRepository.GetEmployeeID(EmployeeCB.SelectedValue.ToString()); int oldEmployeeID = EmployeeRepository.GetEmployeeID(DutyLabel.Content.ToString().Substring(16)); int dutyID = DutyRepository.GetDuty(DutyLabel.Content.ToString().Substring(0, 10), DutyLabel.Content.ToString().Substring(16)).DutyID; DBDutyController.UpdateDuty(newEmployeeID, DutyID); DBDutyExchangeController.DeleteDutyExchange(dutyID, oldEmployeeID); DutyExchangeRepository.RemoveDutyExchange(dutyID, oldEmployeeID); ExchangeDutyWindow.Close(); this.Close(); }
private void DutyList2_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (DutyList2.SelectedIndex != -1) { string date = DutyList2.SelectedItem.ToString().Substring(0, 10); string firstName = DutyList2.SelectedValue.ToString().Substring(16); string dutyList2selected = DutyList2.SelectedValue.ToString(); Duty duty = DutyRepository.GetDuty(date, firstName); PopupExchangeDutyWindow popupExchangeDutyWindow = new PopupExchangeDutyWindow(EmployeesProp, dutyList2selected, duty.DutyID, this); popupExchangeDutyWindow.Show(); } }
public void UpdateDutyExchangeList() { List <DutyExchange> dutyExchanges = DutyExchangeRepository.GetDutyExchanges(); List <DutyListView> dutyExchangeListViews = new List <DutyListView>(); foreach (DutyExchange dutyExchange in dutyExchanges) { dutyExchangeListViews.Add(new DutyListView { Duty = DutyRepository.GetDuty(dutyExchange.DutyID), EmployeeName = EmployeeRepository.GetEmployeeName(dutyExchange.EmployeeID) }); } DutyExchangeListView.ItemsSource = dutyExchangeListViews; DutyExchangeListView.SelectedIndex = -1; }
public void UpdateDutyList2() { List <DutyExchange> dutyExchanges = DutyExchangeRepository.GetDutyExchanges(); List <string> newDutyExchanges = new List <string>(); if (dutyExchanges.Count > 0) { foreach (DutyExchange dutyExchange in dutyExchanges) { string newDutyExchange = DateRepository.GetDate(DutyRepository.GetDuty(dutyExchange.DutyID).DateID).Date.ToString().Substring(0, 10) + " <--> " + EmployeeRepository.GetEmployee(dutyExchange.EmployeeID).FirstName; newDutyExchanges.Add(newDutyExchange); } DutyList2.ItemsSource = newDutyExchanges; } else { DutyList2.ItemsSource = null; } }
public void UpdateDutyList() { List <Duty> duties = DutyRepository.GetDuties(EmployeeCB.SelectedItem.ToString()); List <string> dutiesS = new List <string>(); if (duties.Count > 0) { foreach (Duty duty in duties) { string dutyS = DateRepository.GetDate(DutyRepository.GetDuty(duty.DutyID).DateID).Date.ToString().Substring(0, 10) + " <--> " + EmployeeRepository.GetEmployee(duty.EmployeeID).FirstName; dutiesS.Add(dutyS); } DutyList.ItemsSource = dutiesS; } else { DutyList.ItemsSource = null; } }
private void DutyList_SelectionChanged(object sender, SelectionChangedEventArgs e) { string date = null; if (DutyList.SelectedItem != null) { date = DutyList.SelectedItem.ToString().Substring(0, 10); string employeeName = EmployeeCB.SelectedValue.ToString(); MessageBoxButton btn = MessageBoxButton.YesNo; MessageBoxImage image = MessageBoxImage.Exclamation; MessageBoxResult result = MessageBox.Show("Er du sikker på at du vil bytte denne vagt.", "Vagt bytte", btn, image); if (result == MessageBoxResult.Yes) { DutyExchange dutyExchange = new DutyExchange(DutyRepository.GetDuty(date, employeeName).DutyID, EmployeeRepository.GetEmployeeID(employeeName)); DBDutyExchangeController.CreateDutyExchange(dutyExchange); UpdateDutyList2(); UpdateDutyList(); } } }