Files
BeWoPlaner/BeWo/View/Detail/EmployeeView.xaml.cs

845 lines
35 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
2019-12-19 14:27:03 +01:00
using System.ComponentModel;
2016-06-27 01:45:38 +02:00
using System.Linq;
2019-12-19 14:27:03 +01:00
using System.Runtime.CompilerServices;
2016-06-27 01:45:38 +02:00
using System.ServiceModel;
using System.Windows;
2018-10-08 11:57:16 +02:00
using System.Windows.Controls;
2016-11-18 17:05:52 +01:00
using System.Windows.Input;
2016-06-27 01:45:38 +02:00
using System.Windows.Media;
2016-07-18 09:15:00 +02:00
using System.Windows.Media.Imaging;
2022-02-22 11:58:42 +01:00
using System.Windows.Navigation;
2019-12-19 14:27:03 +01:00
using BeWo.Annotations;
2016-06-27 01:45:38 +02:00
using BeWo.Core;
using BeWo.Core.Service;
using BeWo.ownChat;
using BeWo.SchulbegleitenderDienst;
2016-06-27 01:45:38 +02:00
using BeWo.ServiceProxy;
using BeWo.Validation;
using BeWo.ViewModel;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
2022-02-22 11:58:42 +01:00
using BS.Shared.Translation;
using DevExpress.Xpf.Editors;
2016-06-27 01:45:38 +02:00
using DevExpress.Xpf.Editors.Settings;
using DevExpress.Xpf.Grid;
2016-11-18 17:05:52 +01:00
using Button = System.Windows.Controls.Button;
using MessageBox = System.Windows.MessageBox;
2016-06-27 01:45:38 +02:00
namespace BeWo.View.Detail
{
public partial class EmployeeView : INotifyPropertyChanged
{
private EmployeeVM _ViewModel;
2016-06-27 01:45:38 +02:00
private GridControl _GridAbsenceTimes;
private GridControl _GridOvertimes;
private GridControl _GridCustomers;
private GridControl _GridLeaveDays;
private bool _InitTabIndex;
2019-12-19 14:27:03 +01:00
private readonly ObservableSortCollection<ValueListEntryDC> _EintragKategorien;
2016-06-27 01:45:38 +02:00
public EmployeeView(EmployeeVM pEmployeeDC)
{
InitializeComponent();
2016-06-27 01:45:38 +02:00
combobox_brush.ItemTemplateSelector = new ComboBoxTemplateSelector(combobox_brush);
ViewModel = pEmployeeDC;
2016-06-27 01:45:38 +02:00
var extendedPropsVisible = false;
if (BeWoApp.Mandator.BeWoClientType == 3)
{
//Köln Ring
extendedPropsVisible = true;
}
2016-06-27 01:45:38 +02:00
2019-12-19 14:27:03 +01:00
if (!extendedPropsVisible)
2019-12-19 14:27:03 +01:00
{
extendedPropertyGroup.Visibility = Visibility.Collapsed;
}
2016-06-27 01:45:38 +02:00
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.ChatSettings) || !BeWoApp.AppSettings.ShowOwnChat)
{
tabitem_chatservice.Visibility = Visibility.Collapsed;
}
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.Employee_AllowEditContracts))
2019-12-19 14:27:03 +01:00
{
tabitem_contract.Visibility = Visibility.Collapsed;
}
2016-06-27 01:45:38 +02:00
OvertimeTabItem.Visibility = BeWoApp.LoggedOnUser.HasRight(UserRightType.OvertimeView) ? Visibility.Visible : Visibility.Collapsed;
2016-06-27 01:45:38 +02:00
2020-11-10 02:25:15 +01:00
tabitem_arbeitszeit.Visibility = Visibility.Visible;
if (pEmployeeDC.VarFields == null || pEmployeeDC.VarFields.VMList.Count == 0)
{
tabitem_varFields.Visibility = Visibility.Collapsed;
}
if (BeWoApp.Mandator != null && BeWoApp.Mandator.AllowSbd)
{
tabitem_schuldienst.Visibility = Visibility.Visible;
}
else
{
tabitem_schuldienst.Visibility = Visibility.Collapsed;
}
2017-06-11 15:50:31 +02:00
// HACK: Force the devexpress grid to end editing when the mouse is over savebutton
// by setting the focus to another element.
MouseMove += (s, e) =>
{
if ((_GridAbsenceTimes == null || !_GridAbsenceTimes.IsVisible) &&
(_GridCustomers == null || !_GridCustomers.IsVisible) && (_GridOvertimes == null || !_GridOvertimes.IsVisible))
{
return;
}
var p = e.GetPosition(BtnSave);
if (p.X >= 0 && p.X < BtnSave.ActualWidth && p.Y >= 0 && p.Y < BtnSave.ActualHeight)
{
root.Focus();
}
};
tabcontrol_contracts.Loaded += tabcontrol_contracts_Loaded;
chkArchiviert.IsChecked = ViewModel.IsArchived;
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.Employee_AllowArchiving))
{
lblArchiviert.Visibility = Visibility.Hidden;
chkArchiviert.Visibility = Visibility.Hidden;
}
tabitem_documents.Visibility = Visibility.Collapsed;
if (BeWoApp.LoggedOnUser.HasRight(UserRightType.DocumentsAllowViewAll) || BeWoApp.LoggedOnUser.HasRight(UserRightType.DokumenteMitarbeiter) && BeWoApp.LoggedOnEmployee.EmployeeOid == pEmployeeDC.DataContract.EmployeeOid)
{
tabitem_documents.Visibility = Visibility.Visible;
}
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.Employee_ViewNotizen))
{
tabitem_notizen.Visibility = Visibility.Collapsed;
}
if (BeWoApp.AppSettings.ShowUrlaubsplanung)
{
LeaveDaysTabItem.Visibility = Visibility.Visible;
}
else
{
LeaveDaysTabItem.Visibility = Visibility.Collapsed;
}
2021-07-07 15:05:45 +02:00
//Employee Image
if (_ViewModel.EmployeeImage != null)
2016-07-18 09:15:00 +02:00
{
2017-03-28 16:11:01 +02:00
using (var ms = new System.IO.MemoryStream(_ViewModel.EmployeeImage))
{
var image = new BitmapImage();
image.BeginInit();
image.CacheOption = BitmapCacheOption.OnLoad; // here
image.StreamSource = ms;
image.EndInit();
Img.Source = image;
}
2016-07-18 09:15:00 +02:00
}
2016-07-25 09:26:56 +02:00
Img.EditValueChanged += Image_EditValueChanged;
_EintragKategorien = pEmployeeDC.EintragKategorien;
}
2016-07-18 09:15:00 +02:00
public void Image_EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e)
2016-07-18 09:15:00 +02:00
{
2016-07-25 09:26:56 +02:00
_ViewModel.EmployeeImage = Img.EditValue as byte[];
2016-07-18 09:15:00 +02:00
}
public override bool IsDirty => ViewModel != null && ViewModel.IsDirty;
2016-06-27 01:45:38 +02:00
2019-12-19 14:27:03 +01:00
public override string Title => "Mitarbeiter";
2016-06-27 01:45:38 +02:00
2019-12-19 14:27:03 +01:00
internal override DependencyObject ValidationOnSaveRootElement => grid_details;
2016-06-27 01:45:38 +02:00
2019-12-19 14:27:03 +01:00
public EmployeeVM ViewModel
{
get => _ViewModel;
2016-06-27 01:45:38 +02:00
2019-12-19 14:27:03 +01:00
set
{
_ViewModel = value;
DataContext = value;
2022-02-22 11:58:42 +01:00
UpdateReportUrl();
OnPropertyChanged(nameof(ViewModel));
2019-12-19 14:27:03 +01:00
if (tabcontrol_contracts.Items.Count == 0 && _ViewModel.Contracts.VMList.Count > 0)
2019-12-19 14:27:03 +01:00
{
_InitTabIndex = true;
}
else
2019-12-19 14:27:03 +01:00
{
SetTabIndexToLastContract();
}
if (tabitem_arbeitszeit.Content != null)
{
2019-12-19 14:27:03 +01:00
if (tabitem_arbeitszeit.Content is EmployeeArbeitszeitView view)
{
view.ViewModel = value;
view.RefreshView();
}
}
}
}
2016-06-27 01:45:38 +02:00
private void tabcontrol_contracts_Loaded(object sender, RoutedEventArgs e)
{
if (_InitTabIndex)
{
SetTabIndexToLastContract();
_InitTabIndex = false;
}
}
2016-06-27 01:45:38 +02:00
private void SetTabIndexToLastContract()
{
if (tabcontrol_contracts.Items.Count > 0)
2019-12-19 14:27:03 +01:00
{
tabcontrol_contracts.SelectedIndex = tabcontrol_contracts.Items.Count - 1;
//var contract = tabcontrol_contracts.SelectedItem as ContractVM;
//if (contract != null && contract.EmploymentType != null)
//{
// ViewModel.LastContract.EmploymentTypeLeaveDaysVisibility =
// (contract.EmploymentType.LeaveDays != null) ? Visibility.Visible : Visibility.Collapsed;
// ViewModel.LastContract.LeaveDaysVisibility = (contract.EmploymentType.LeaveDays != null) ? Visibility.Collapsed : Visibility.Visible;
//}
//else
//{
// ViewModel.LastContract.EmploymentTypeLeaveDaysVisibility = Visibility.Collapsed;
// ViewModel.LastContract.LeaveDaysVisibility = Visibility.Visible;
//}
2019-12-19 14:27:03 +01:00
}
}
2016-06-27 01:45:38 +02:00
protected override UserRightType[] GetSaveDemands()
{
if (ViewModel.IsNew)
2019-12-19 14:27:03 +01:00
{
return new[] { UserRightType.CreateAll, UserRightType.EmployeeView_Create };
2019-12-19 14:27:03 +01:00
}
return ViewModel.DataContract.EmployeeOid == BeWoApp.LoggedOnEmployee.EmployeeOid ?
new[] { UserRightType.EditAll, UserRightType.EmployeeView_Edit, UserRightType.Employee_AllowEditOwnEmployees } :
new[] { UserRightType.EditAll, UserRightType.EmployeeView_Edit };
2019-12-19 14:27:03 +01:00
}
protected override void Save()
{
if (!ValidateContracts())
{
return;
}
var lDataContract = ViewModel.CommitToDataContract();
try
{
// if (ViewModel.LastContract != null && ViewModel.LastContract.EmploymentType != null)
// {
// if (ViewModel.LastContract.EmploymentType.LeaveDays != null) // EmploymentType hat feste Urlaubstage
// {
// var originalEmploymentType = ServiceFacade.DoEmployeeServiceSync(s => s.GetEmploymentType((long)ViewModel.LastContract.EmploymentType.EmploymentTypeOid));
// if (originalEmploymentType.LeaveDays == ViewModel.LastContract.EmploymentType.LeaveDays)
// {
// int arbeitstage = ViewModel.LastContract.WeeklyDays != null ? (int)ViewModel.LastContract.WeeklyDays : 0;
// decimal? urlaubstage = ViewModel.LastContract.EmploymentType.LeaveDays;
// ViewModel.LastContract.LeaveDays = urlaubstage;
// if (ViewModel.LastContract.ContractEndDate.Value.Date >= new DateTime(ViewModel.LastContract.EntryDate.Value.Year, 12, 31))
// {
// int restlicheTageImJahr = Convert.ToInt32((new DateTime(ViewModel.LastContract.EntryDate.Value.Year, 12, 31) - ViewModel.LastContract.EntryDate.Value.Date).TotalDays);
// urlaubstage = CalculateUrlaubstage((DateTime)ViewModel.LastContract.EntryDate, null, arbeitstage, restlicheTageImJahr, urlaubstage);
// }
// else // Wenn Ende des Vertrags im gleichen Jahr vor Ende des Jahres ist
// {
// int restlicheTageImJahr = Convert.ToInt32((ViewModel.LastContract.ContractEndDate.Value.Date - ViewModel.LastContract.EntryDate.Value.Date).TotalDays);
// urlaubstage = CalculateUrlaubstage((DateTime)ViewModel.LastContract.EntryDate, ViewModel.LastContract.ContractEndDate.Value.Date, arbeitstage, restlicheTageImJahr, urlaubstage);
// }
// }
// }
// else // Beschäftigungsart sind keine festen Urlaubstage zugeordnet
// {
// int arbeitstage = ViewModel.LastContract.WeeklyDays != null ? (int)ViewModel.LastContract.WeeklyDays : 0;
// decimal? urlaubstage = ViewModel.LastContract.LeaveDays;
// if (ViewModel.LastContract.ContractEndDate.Value.Date >= new DateTime(ViewModel.LastContract.EntryDate.Value.Year, 12, 31))
// {
// int restlicheTageImJahr = Convert.ToInt32((new DateTime(ViewModel.LastContract.EntryDate.Value.Year, 12, 31) - ViewModel.LastContract.EntryDate.Value.Date).TotalDays);
// urlaubstage = CalculateUrlaubstage((DateTime)ViewModel.LastContract.EntryDate, null, arbeitstage, restlicheTageImJahr, urlaubstage);
// }
// else // Wenn Ende des Vertrags im gleichen Jahr vor Ende des Jahres ist
// {
// int restlicheTageImJahr = Convert.ToInt32((ViewModel.LastContract.ContractEndDate.Value.Date - ViewModel.LastContract.EntryDate.Value.Date).TotalDays);
// urlaubstage = CalculateUrlaubstage((DateTime)ViewModel.LastContract.EntryDate, ViewModel.LastContract.ContractEndDate.Value.Date, arbeitstage, restlicheTageImJahr, urlaubstage);
// }
// // Urlaubskonto: Verbleibende Tage hier auf Urlaubstage setzen..
// }
//}
if (ViewModel.IsNew)
{
IsDoneWithInsertOrUpdate = false;
ServiceFacade.DoEmployeeServiceAsync(s => s.InsertNewEmployee(lDataContract), ReloadViewModel);
}
else
{
IsDoneWithInsertOrUpdate = false;
ServiceFacade.DoEmployeeServiceAsync(s => s.UpdateEmployee(lDataContract), ReloadViewModel);
}
Cache.GetInstance().ClearEmployees();
BeWoApp.MainControl.ResetView(UIContext.Employee);
}
catch (FaultException<BeWoFault>)
{
MessageBox.Show("Dieser Datensatz wurde in der Zwischenzeit von einem anderen Benutzer geändert. Klicken Sie Ok, um den Datansatz erneut zu laden. Ihre Änderungen gehen dabei leider verloren.");
ReloadViewModel(lDataContract.EmployeeOid.Value);
}
}
private decimal CalculateUrlaubstage(DateTime entryDate, DateTime? endDate, int anzahlArbeitstage, int restlicheTageImJahr, decimal? urlaubstage)
{
return ServiceFacade.DoEmployeeServiceSync(s => s.CalculateUrlaubstage(entryDate, endDate, anzahlArbeitstage, restlicheTageImJahr, urlaubstage));
//return 0;
}
private bool ValidateContracts()
{
var count = ViewModel.Contracts.VMList.Count(c => !c.ContractEndDate.HasValue);
if (count > 1)
{
MessageBox.Show("Es darf nur ein unbefristeter Vetrag angelegt werden. Bitte überprüfen Sie das \"Befristet bis\" Datum der angelegten Verträge.", "Ungültiger Vetrag", MessageBoxButton.OK);
return false;
}
foreach (var contract in ViewModel.Contracts.VMList)
{
if (contract.EntryDate.HasValue && contract.ContractEndDate.HasValue && contract.EntryDate.Value > contract.ContractEndDate.Value)
{
MessageBox.Show("Das Startdatum eines Vertrags ist größer als das Enddatum. Bitte überprüfen Sie die angelegten Verträge.", "Ungültiger Vetrag", MessageBoxButton.OK);
return false;
}
}
return true;
}
private void CustomerSearchView_CustomerSelected(object sender, EventArgs<CompactCustomerDC> e)
{
PopupCustomer.IsOpen = false;
ViewModel.CustomerRelations.NewVM.Customer = e.Data;
popupedit_customerRelations.Focus();
}
private void ReloadViewModel(long pOid)
{
if (pOid == -1)
{
this.Dispatch(
delegate
{
MessageBox.Show("Leider besitzen Sie nicht genügend Lizenzen, um einen neuen Benutzer anzulegen!", "Benutzer anlegen", MessageBoxButton.OK, MessageBoxImage.Information);
});
}
else
{
VMFactory.CreateEmployeeVMAsync(pOid, cb => this.Dispatch(delegate
{
var list = cb.Arbeitszeiten;
ViewModel = cb;
if (tabitem_schuldienst.Content != null)
{
2019-12-19 14:27:03 +01:00
if (tabitem_schuldienst.Content is SchulbegleitenderDienstEmployeeView view)
{
view.ViewModel = cb;
}
}
2016-06-27 01:45:38 +02:00
2018-10-08 11:57:16 +02:00
ModalEditViewUpdateCallback?.Invoke();
2016-06-27 01:45:38 +02:00
PreselectEmployeeBrush();
}));
}
2016-06-27 01:45:38 +02:00
IsDoneWithInsertOrUpdate = true;
}
2016-06-27 01:45:38 +02:00
private void PreselectEmployeeBrush()
{
2016-06-27 01:45:38 +02:00
if (ViewModel.EmployeeBrush == null)
{
return;
}
var element118 = ((List<SolidColorBrush>)combobox_brush.ItemsSource).FirstOrDefault(f => f.Color.Equals(ViewModel.EmployeeBrush.Color));
combobox_brush.SelectedItem = element118;
}
2016-06-27 01:45:38 +02:00
public void ReloadViewModel()
{
ReloadViewModel(ViewModel.DataContract.EmployeeOid.Value);
}
2016-06-27 01:45:38 +02:00
2019-12-19 14:27:03 +01:00
private void TabItemCustomers_Selected(object sender, RoutedEventArgs e)
{
if (_GridCustomers == null)
{
_GridCustomers = rootGrid.Resources["grid_CustomerRelation"] as GridControl;
2016-06-27 01:45:38 +02:00
GroupBoxCustomers.Content = _GridCustomers;
if (ViewModel.CustomerRelations != null && _GridCustomers != null)
2019-12-19 14:27:03 +01:00
{
_GridCustomers.Columns["Role"].EditSettings = new ComboBoxEditSettings
{
ItemsSource = ViewModel.CustomerRelations.PossibleRoles
};
}
}
}
private void UserControl_GotFocus(object sender, RoutedEventArgs e)
{
if (e.OriginalSource.Equals(this))
{
textbox_first.Focus();
}
}
private void button_addCustomerRelation_Click(object sender, RoutedEventArgs e)
{
if (ValidationTrigger.Validate(groupbox_newCustomerRel))
{
ViewModel.CustomerRelations.AddNewVMToList();
}
}
private void button_addFocus_Click(object sender, RoutedEventArgs e)
{
var lFocus = listbox_possibleFocuses.SelectedItem as ValueListEntryDC;
ViewModel.PossibleFocuses.Remove(lFocus);
ViewModel.Focuses.Add(lFocus);
ViewModel.Focuses.Sort();
}
private void button_addQualification_Click(object sender, RoutedEventArgs e)
{
var lQualification = listbox_possibleQualification.SelectedItem as ValueListEntryDC;
ViewModel.PossibleQualifications.Remove(lQualification);
ViewModel.Qualifications.Add(lQualification);
ViewModel.Qualifications.Sort();
}
private void button_removeCustomerRelation_Click(object sender, RoutedEventArgs e)
{
ViewModel.CustomerRelations.VMList.Remove(_GridCustomers.GetCurrentValue<CustomerEmployeeRelationVM>());
BeWoWpfUtils.RefreshDXGrid(_GridCustomers);
}
private void button_removeFocus_Click(object sender, RoutedEventArgs e)
{
var lFocus = listbox_focuses.SelectedItem as ValueListEntryDC;
ViewModel.Focuses.Remove(lFocus);
ViewModel.PossibleFocuses.Add(lFocus);
ViewModel.PossibleFocuses.Sort();
}
private void button_removeQualificeation_Click(object sender, RoutedEventArgs e)
{
var lQualification = listbox_qualifications.SelectedItem as ValueListEntryDC;
ViewModel.Qualifications.Remove(lQualification);
ViewModel.PossibleQualifications.Add(lQualification);
ViewModel.PossibleQualifications.Sort();
}
private void popupedit_customerRelations_PopUpClick(object sender, RoutedEventArgs e)
{
PopupCustomer.IsOpen = true;
}
private void tabitem_documents_Selected(object sender, RoutedEventArgs e)
{
if (ViewModel.IsNew)
{
MessageBox.Show("Bevor zu einem Datensatz Dokumente hinterlegt werden können, muss dieser gespeichert werden.", "Erst speichern bitte", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
if (tabitem_documents.Content == null)
{
tabitem_documents.Content = new BeWoFileView(TableID.Employee, ViewModel.DataContract.EmployeeOid.Value);
}
}
private void tabitem_arbeitszeit_Selected(object sender, RoutedEventArgs e)
{
if (ViewModel.IsNew)
{
MessageBox.Show("Bevor Sie Arbeitszeiten eintragen können, muss dieser Datensatz zuerst gespeichert werden.", "Erst speichern bitte", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
if (tabitem_arbeitszeit.Content == null)
{
2017-05-17 08:28:12 +02:00
tabitem_arbeitszeit.Content = new EmployeeArbeitszeitView(_ViewModel, ViewModel.DataContract.EmployeeOid.Value);
}
}
2016-06-27 01:45:38 +02:00
private void tabitem_chatservice_Selected(object sender, RoutedEventArgs e)
{
if (tabitem_chatservice.Content == null)
{
tabitem_chatservice.Content = new ChatServiceEmployee(ViewModel.DataContract.EmployeeOid.Value, ViewModel.DataContract.PersonOid);
}
}
2016-06-27 01:45:38 +02:00
2017-06-30 13:33:49 +02:00
private void tabitem_SchulDienst_Selected(object sender, RoutedEventArgs e)
{
2018-10-08 11:57:16 +02:00
if (ViewModel.IsNew)
{
MessageBox.Show("Bevor Sie Angaben zum Schulbegleitenden Dienst hinterlegen können, muss dieser Datensatz zuerst gespeichert werden.", "Erst speichern bitte", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
2017-06-30 13:33:49 +02:00
if (tabitem_schuldienst.Content == null)
{
2018-10-08 11:57:16 +02:00
tabitem_schuldienst.Content = new SchulbegleitenderDienstEmployeeView(ViewModel);
2017-06-30 13:33:49 +02:00
}
}
private void button_addContract_Click(object sender, RoutedEventArgs e)
{
ViewModel.Contracts.AddNewVMToList();
tabcontrol_contracts.SelectedIndex = tabcontrol_contracts.Items.Count - 1;
}
2016-06-27 01:45:38 +02:00
private void btn_deleteContract_Click(object sender, RoutedEventArgs e)
{
var contract = tabcontrol_contracts.SelectedItem as ContractVM;
2016-06-27 01:45:38 +02:00
ViewModel.Contracts.VMList.Remove(contract);
}
2016-06-27 01:45:38 +02:00
private void tabitem_notizen_Selected(object sender, RoutedEventArgs e)
{
if (ViewModel.IsNew)
{
MessageBox.Show("Bevor Sie Notizen anlegen können, muss dieser Datensatz zuerst gespeichert werden.", "Erst speichern bitte", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
if (tabitem_notizen.Content == null)
{
tabitem_notizen.Content = new NotizenView(TableID.Employee, ViewModel.DataContract.EmployeeOid.Value, _EintragKategorien);
}
}
2018-10-08 11:57:16 +02:00
private void TableView_OnRowDoubleClick(object sender, RowDoubleClickEventArgs e)
{
var grid_CustomerRelation = (GridControl)rootGrid.Resources["grid_CustomerRelation"];
var selectedCustomerEmployeeRelationVM =
grid_CustomerRelation.GetRow(e.HitInfo.RowHandle) as CustomerEmployeeRelationVM;
if (selectedCustomerEmployeeRelationVM == null || !BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View))
return;
VMFactory.CreateCustomerVMAsync(selectedCustomerEmployeeRelationVM.Customer.CustomerOid,
cb => this.Dispatch(
() => BeWoUtils.OpenModalViewWindow<CustomerVM, CustomerDC, EmployeeView>(cb, this, () => this.Dispatch(
delegate
{
CompactCustomerDC customerToUpdate = selectedCustomerEmployeeRelationVM.Customer;
//ServiceFacade.DoCustomerServiceSync(
// s => customerToUpdate = s.GetCompactCustomerDC(customerToUpdate.CustomerOid));
//foreach (var item in((BindingList<CustomerEmployeeRelationVM>) grid_CustomerRelation.ItemsSource).Where(item => item.Customer.Equals(customerToUpdate)))
//{
// item.Customer = null;
// item.Customer = customerToUpdate;
//}
//grid_CustomerRelation.RefreshData();
BeWoUtils.UpdateAllViews(customerToUpdate);
}))));
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
string emailAddress = (sender as Button).Name.Equals("EMailSendBtn") ? ViewModel.EMail : ViewModel.PrivateEMail;
BeWoUtils.OpenMailClient(emailAddress);
}
private void TabItemOvertimes_Selected(object sender, RoutedEventArgs e)
{
if (_GridOvertimes == null)
{
_GridOvertimes = rootGrid.Resources["datagrid_overtimes"] as GridControl;
GroupBoxOvertimes.Content = _GridOvertimes;
if (ViewModel.AbsenceTimes != null && _GridOvertimes != null)
{
_GridOvertimes.Columns["Auszahlungsart"].EditSettings = new ComboBoxEditSettings
{
ItemsSource = ViewModel.PossibleAuszahlungsarten
};
}
}
}
private void button_addOvertime_Click(object sender, RoutedEventArgs e)
{
if (ValidationTrigger.Validate(groupbox_newOvertime))
{
ViewModel.Overtimes.AddNewVMToList();
}
}
private void button_removeOvertime_Click(object sender, RoutedEventArgs e)
{
ViewModel.Overtimes.VMList.Remove(_GridOvertimes.GetCurrentValue<OvertimeVM>());
BeWoWpfUtils.RefreshDXGrid(_GridOvertimes);
}
private void ChkArchiviert_OnChecked(object sender, RoutedEventArgs e)
{
ViewModel.IsArchived = true;
}
private void ChkArchiviert_OnUnchecked(object sender, RoutedEventArgs e)
{
if (ViewModel.DataContract.ActivationType == ActivationTypeId.Archived)
{
var licenseInfo = ServiceFacade.DoOperationsServiceSync(s => s.GetLicenseInfo());
if (licenseInfo.EmployeeCount >= licenseInfo.MaxEmployeeCount)
{
MessageBox.Show("Leider verfügen Sie nicht über genügend Lizenzen, um diese/n Mitarbeiter/in aus dem Archiv zu holen.\n\n" +
string.Format("Sie verfügen derzeit über {0} kostenpflichtige Benutzerlizenzen, somit können Sie maximal {1} Mitarbeiter anlegen.\n({0} Benutzer + {2} % = {1} Mitarbeiterlizenzen).", licenseInfo.MaxLicenseCount, licenseInfo.MaxEmployeeCount, licenseInfo.PercentFreeEmployee) +
"\n\nSie können nun entweder Mitarbeiter archivieren oder im Modul \"Benutzer\" neue Benutzerlizenzen bestellen. Bitte beachten Sie, dass hierfür das Recht \"Neue Lizenz bestellen\" erforderlich ist.", "Mitarbeiter anlegen", MessageBoxButton.OK,
MessageBoxImage.Information);
chkArchiviert.IsChecked = true;
}
else
{
ViewModel.IsArchived = false;
}
}
}
private void Combobox_brush_OnLoaded(object sender, RoutedEventArgs e)
{
PreselectEmployeeBrush();
}
private void Img_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
BeWoUtils.ShowImageForm(Img.Source);
}
private void PrintContract(object sender, MouseButtonEventArgs e)
{
var textBlock = (TextBlock)sender;
var contract = ((ContractVM)textBlock.Tag).CommitToDataContract();
2018-10-08 11:57:16 +02:00
2019-12-19 14:27:03 +01:00
var url = BeWoApp.SiteOfOrigin + "/ReportView.aspx?cOid=" + contract.ContractOid + "&type=" + Utils.EnumName(ReportTypes.Contract);
2018-10-08 11:57:16 +02:00
BeWoUtils.NavigateToReportUri(url, "Druckvorschau");
2018-10-08 11:57:16 +02:00
}
2019-12-19 14:27:03 +01:00
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private void combobox_employmenttype_EditValueChanged(object sender, EditValueChangedEventArgs e)
{
//var contract = tabcontrol_contracts.SelectedItem as ContractVM;
// if (contract.EmploymentType != null && contract.EmploymentType.LeaveDays != null)
// {
// contract.EmploymentTypeLeaveDaysVisibility = Visibility.Visible;
// contract.LeaveDaysVisibility = Visibility.Collapsed;
// }
// else
// {
// contract.EmploymentTypeLeaveDaysVisibility = Visibility.Collapsed;
// contract.LeaveDaysVisibility = Visibility.Visible;
// }
//var index = tabcontrol_contracts.SelectedIndex;
//if(index == tabcontrol_contracts.Items.Count - 1)
// {
// Cache.GetInstance().ClearEmployees();
// BeWoApp.MainControl.ResetView(UIContext.Employee);
//}
//else
// {
// tabcontrol_contracts.SelectedIndex = tabcontrol_contracts.Items.Count - 1;
// tabcontrol_contracts.SelectedIndex = index;
//}
}
private void LeaveDaysTabItem_Selected(object sender, RoutedEventArgs e)
{
if (ViewModel.IsNew)
{
MessageBox.Show("Bevor Sie das Urlaubskonto einsehen können, muss dieser Datensatz zuerst gespeichert werden.",
"Erst speichern bitte", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
LeaveDaysTabItem.Content = new UrlaubskontoView(ViewModel.DataContract);
}
2022-02-22 11:58:42 +01:00
private void UpdateReportUrl()
{
var url = BeWoWpfUtils.GetHTMLEncodedURL(string.Format("{0}/ReportView.aspx?eOid={1}&type={2}", BeWoApp.SiteOfOrigin, ViewModel.DataContract.EmployeeOid ?? 0, Utils.EnumName(ReportTypes.MitarbeiterKlientenReport)));
linkPdfExport.NavigateUri = new Uri(url);
}
private void LinkPdfExport_OnRequestNavigate(object sender, RequestNavigateEventArgs e)
{
BeWoUtils.NavigateToReportUri((sender as System.Windows.Documents.Hyperlink).NavigateUri.ToString(), Translator.Translate("Zugeordnete Klient:innen"));
}
#region Nur relevant, wenn Urlaubskonto keine eigene View mehr ist
/*
private void InitDateComboBox()
{
var year = new List<int>();
for (int i = DateTime.Today.Year + 1; i > DateTime.Today.Year - 20; i--)
{
year.Add(i);
}
_YearPicker.ItemsSource = year;
_YearPicker.SelectedItem = DateTime.Today.Year;
}
private void _YearPicker_EditValueChanged(object sender, EditValueChangedEventArgs e)
{
if (_GridLeaveDays == null)
{
_GridLeaveDays = rootGrid.Resources["datagrid_leavedays"] as GridControl;
WPFGridLeaveDays.Children.Add(_GridLeaveDays);
}
var urlaubskonto = ServiceFacade.DoEmployeeServiceSync(s => s.ErstelleUrlaubskontoDarstellung(ViewModel.DataContract, (int)_YearPicker.SelectedItem));
if (urlaubskonto == null)
{
urlaubskonto = new List<UrlaubskontoDarstellungDC>();
urlaubskonto.Add(new UrlaubskontoDarstellungDC()
{
Erlaeuterung = "Es existiert kein Vertrag für ausgewähltes Jahr",
});
button_openLeaveDayDialogue.Visibility = Visibility.Collapsed;
}
else
button_openLeaveDayDialogue.Visibility = Visibility.Visible;
_GridLeaveDays.ItemsSource = urlaubskonto;
}
private void button_addLeaveDay_Click(object sender, RoutedEventArgs e)
{
var anzahlTage = Convert.ToDecimal(addLeaveDays_anzahlTage.Value);
var erlaeuterung = addLeaveDays_erlaeuterung.Text;
var datum = addLeaveDays_datum.EditValue;
if (datum == null)
{
addLeaveDays_datumswarnung.Visibility = Visibility.Visible;
return;
}
else
addLeaveDays_datumswarnung.Visibility = Visibility.Collapsed;
GeschenkterUrlaubstagDC dc = new GeschenkterUrlaubstagDC()
{
AnzahlTage = anzahlTage,
Date = (DateTime)datum,
Employee = (long)ViewModel.DataContract.EmployeeOid,
GeschenkterUrlaubstagNotice = erlaeuterung
};
ServiceFacade.DoEmployeeServiceSync(s => s.InsertGeschenkterUrlaubstag(dc));
var urlaubskonto = ServiceFacade.DoEmployeeServiceSync(s => s.ErstelleUrlaubskontoDarstellung(ViewModel.DataContract, (int)_YearPicker.SelectedItem));
popup_giftLeaveday.IsOpen = false;
ViewModel.UrlaubskontoDarstellungDCs = urlaubskonto;
_GridLeaveDays.ItemsSource = urlaubskonto;
}
private void button_removeLeaveDay_Click(object sender, RoutedEventArgs e)
{
// Auf geschenkte Urlaubstage umprogrammieren
var dc = _GridLeaveDays.GetCurrentValue<UrlaubskontoDarstellungDC>();
var herkunftarray = dc.Herkunft.Split(':');
if (herkunftarray.Length == 2 && herkunftarray[0] == "GeschenkterUrlaubstagOid")
{
long oid = Convert.ToInt64(herkunftarray[1]);
ServiceFacade.DoEmployeeServiceSync(s => s.DeleteGeschenkterUrlaubstag(oid));
var urlaubskonto = ServiceFacade.DoEmployeeServiceSync(s => s.ErstelleUrlaubskontoDarstellung(ViewModel.DataContract, (int)_YearPicker.SelectedItem));
ViewModel.UrlaubskontoDarstellungDCs = urlaubskonto;
_GridLeaveDays.ItemsSource = urlaubskonto;
}
}
private void button_openLeaveDayDialogue_Click(object sender, RoutedEventArgs e)
{
popup_giftLeaveday.IsOpen = true;
}
private void button_cancel_Click(object sender, RoutedEventArgs e)
{
popup_giftLeaveday.IsOpen = false;
addLeaveDays_anzahlTage.EditValue = string.Format("{0:0.00}", 1.00);
addLeaveDays_erlaeuterung.Text = "";
addLeaveDays_datum.EditValue = null;
}
*/
#endregion
}
2016-06-27 01:45:38 +02:00
}