170 lines
5.2 KiB
C#
Executable File
170 lines
5.2 KiB
C#
Executable File
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
|
|
using BeWo.Controls;
|
|
using BeWo.Core;
|
|
using BeWo.ServiceProxy;
|
|
using BeWo.Validation;
|
|
using BeWo.View.Search;
|
|
using BeWo.ViewModel;
|
|
using BeWo.ViewModel.ListViewModel;
|
|
using BeWo.Core.Service;
|
|
|
|
using BS.Shared;
|
|
using BS.Shared.Extensions;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Services;
|
|
using BS.Shared.Translation;
|
|
using DevExpress.Xpf.RichEdit;
|
|
using SupportConceptService = BeWo.Core.Service.SupportConceptService;
|
|
using System.Linq;
|
|
using DevExpress.Xpf.Grid;
|
|
using System.Windows.Media.Imaging;
|
|
using DevExpress.Utils;
|
|
using System.Windows.Markup;
|
|
using DevExpress.Xpf.Editors;
|
|
|
|
namespace BeWo.View.Detail
|
|
{
|
|
public partial class UrlaubskontoView
|
|
{
|
|
public EmployeeDC DataContract { get; set; }
|
|
|
|
public UrlaubskontoView(EmployeeDC DataContract)
|
|
{
|
|
this.DataContract = DataContract;
|
|
InitializeComponent();
|
|
InitDateComboBox();
|
|
|
|
}
|
|
|
|
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 (_YearPicker.SelectedItem != null)
|
|
{
|
|
if (_GridLeaveDays == null)
|
|
{
|
|
_GridLeaveDays = rootGrid.Resources["datagrid_leavedays"] as GridControl;
|
|
|
|
WPFGridLeaveDays.Children.Add(_GridLeaveDays);
|
|
}
|
|
|
|
var urlaubskonto = ServiceFacade.DoEmployeeServiceSync(s => s.ErstelleUrlaubskontoDarstellung(DataContract, (int)_YearPicker.SelectedItem));
|
|
|
|
if (urlaubskonto == null)
|
|
{
|
|
urlaubskonto = new List<UrlaubskontoDarstellungDC>();
|
|
urlaubskonto.Add(new UrlaubskontoDarstellungDC()
|
|
{
|
|
Erlaeuterung = "Es existiert kein Vertrag für das ausgewählte 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)DataContract.EmployeeOid,
|
|
GeschenkterUrlaubstagNotice = erlaeuterung
|
|
};
|
|
ServiceFacade.DoEmployeeServiceSync(s => s.InsertGeschenkterUrlaubstag(dc));
|
|
|
|
var urlaubskonto = ServiceFacade.DoEmployeeServiceSync(s => s.ErstelleUrlaubskontoDarstellung(DataContract, (int)_YearPicker.SelectedItem));
|
|
|
|
popup_giftLeaveday.IsOpen = false;
|
|
|
|
_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(DataContract, (int)_YearPicker.SelectedItem));
|
|
|
|
_GridLeaveDays.ItemsSource = urlaubskonto;
|
|
}
|
|
}
|
|
|
|
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 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;
|
|
}
|
|
}
|
|
} |