Files
BeWoPlaner/BeWo/ViewModel/ServiceRecordVM.cs
2019-10-10 22:07:42 +02:00

2858 lines
100 KiB
C#

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using BeWo.Core;
using BeWo.Core.Service;
using BeWo.Validation;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.ClientPartials;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
using Brush = System.Windows.Media.Brush;
using Brushes = System.Windows.Media.Brushes;
using Color = System.Windows.Media.Color;
namespace BeWo.ViewModel
{
public class ServiceRecordVM : AbstractDCMapperVM<ServiceRecordDC>
{
#region Constants and Fields
public static string PropertyName_Category = "Category";
public static string PropertyName_Category2Services = "Category2Services";
public static string PropertyName_SortedCategories = "SortedCategories";
public static string PropertyName_CostBearer = "CostBearer";
public static string PropertyName_Customer = "Customer";
public static string PropertyName_Date = "Date";
public static string PropertyName_EditableEndDate = "EditableEndDate";
public static string PropertyName_Duration = "Duration";
public static string PropertyName_Employee = "Employee";
public static string PropertyName_EndTime = "EndTimeEditString";
public static string PropertyName_GoalTree = "GoalTree";
public static string PropertyName_GroupEmployeeCount = "GroupEmployeeCount";
public static string PropertyName_GroupPersonCount = "GroupPersonCount";
public static string PropertyName_GroupRoundedDuration = "GroupRoundedDuration";
public static string PropertyName_IsGoalTreeVisible = "IsGoalTreeVisible";
public static string PropertyName_Notice = "Notice";
public static string PropertyName_Notice2 = "Notice2";
public static string PropertyName_Notice3 = "Notice3";
public static string PropertyName_Notice4 = "Notice4";
public static string PropertyName_Notice5 = "Notice5";
public static string PropertyName_RTFNotice = "RTFNotice";
public static string PropertyName_RTFNotice2 = "RTFNotice2";
public static string PropertyName_RTFNotice3 = "RTFNotice3";
public static string PropertyName_RTFNotice4 = "RTFNotice4";
public static string PropertyName_RTFNotice5 = "RTFNotice5";
public static string PropertyName_PossibleCostBearers = "PossibleCostBearers";
public static string PropertyName_PossibleCustomers = "PossibleCustomers";
public static string PropertyName_PossibleServiceDescriptions = "PossibleServiceDescriptions";
public static string PropertyName_PossibleSupportConcepts = "PossibleSupportConcepts";
public static string PropertyName_RoundedDuration = "RoundedDuration";
public static string PropertyName_SelectedGoals = "SelectedGoals";
public static string PropertyName_ServiceDescription = "ServiceDescription";
public static string PropertyName_StartTime = "StartTimeEditString";
public static string PropertyName_SupportConcept = "SupportConcept";
public static string PropertyName_ServiceRecordType = "ServiceRecordType";
public static string PropertyName_IsServiceRecordTypeDefaultActivity = "IsServiceRecordTypeDefaultActivity";
public static string PropertyName_IsServiceRecordTypeContent = "IsServiceRecordTypeContent";
public static string PropertyName_DistanceInMeter = "DistanceInMeter";
public static string PropertyName_DurationInStunden = "DurationInStunden";
public static string PropertyName_ServiceRecordFormat = "ServiceRecordFormat";
public static string PropertyName_OnlyMonth = "OnlyMonth";
public static string PropertyName_OnlyYear = "OnlyYear";
public static string PropertyName_DurationSTD = "DurationSTD";
public static string PropertyName_EndDate = "EndDate";
public static string PropertyName_DurationMonthYearGes = "DurationMonthYearGes";
private static readonly DateTime NULL_TIME = new DateTime(2000, 1, 1, 0, 0, 1);
private static BitmapImage haekchenBitmapImage = null;
private Dictionary<ServiceCategoryDC, List<ServiceDescriptionDC>> _Category2Services;
//private readonly List<SupportConceptTreeNodeDC> _Tree;
private List<ValueListEntryDC> _AllGoalCategories;
private List<ValueListEntryDC> _AllGoals;
private ServiceCategoryDC _Category;
private FlatSupportConceptTreeNodeDC _ChoosenNode;
private CompactOrganisationDC _CostBearer;
private CompactCustomerDC _Customer;
private DateTime? _Date;
private DateTime? _EndDate;
private bool _DeleteAllowed = true;
private decimal? _Duration;
private decimal? _DurationSTD;
private bool _EditAllowed = true;
private CompactEmployeeDC _Employee;
private DateTime? _EndTime;
private DateTime? _EditableEndDate;
private List<SupportConceptGoalDC> _GoalTree;
private int? _GroupEmployeeCount;
private long? _GroupOid;
private long? _SignatureOid;
private int? _GroupPersonCount;
private decimal? _GroupRoundedDuration;
private string _InsUser;
private DateTime? _InsertedOn;
private string _Notice;
private string _Notice2;
private string _Notice3;
private string _Notice4;
private string _Notice5;
private string _RTFNotice;
private string _RTFNotice2;
private string _RTFNotice3;
private string _RTFNotice4;
private string _RTFNotice5;
private decimal _RoundedDuration;
private ObservableSortCollection<ValueListEntryDC> _SelectedGoals;
private ServiceDescriptionDC _ServiceDescription;
private DateTime? _StartTime;
private CompactSupportConceptDC _SupportConcept;
private ServiceRecordTypeId _ServiceRecordType = ServiceRecordTypeId.DefaultActivity;
public List<ServiceAccountingDC> _ServiceAccountings;
private int? _DistanceInMeter;
private ZeiterfassungsDauer? _DurationInStunden;
private ServiceRecordFormate? _ServiceRecordFormat;
private string _OnlyMonth;
private string _OnlyYear;
private decimal? _DurationMonthYearGes;
private bool _isUnterschrift;
private string _IsFloatGesetzt = "False";
private string[] _MonateBinden = {"Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"};
#endregion
#region Constructors and Destructors
public ServiceRecordVM()
{
DataContract = new ServiceRecordDC {Notice = ""};
if (_DurationSTD == null)
_DurationSTD = 0;
if (_Duration == null)
_Duration = 0;
}
public ServiceRecordVM(
ServiceRecordDC pDC,
Dictionary<ServiceCategoryDC, List<ServiceDescriptionDC>> pCategory2Services,
List<ValueListEntryDC> pAllGoalCategories,
List<ValueListEntryDC> pAllGoals)
: base(pDC, pDC.ServiceRecordOid == null)
{
//_DurationInStunden = BeWoApp.AppSettings.LetzteZeiterfassungsDauer;
_Category2Services = pCategory2Services;
ChangeGoalTree(pAllGoalCategories, pAllGoals);
if (_DurationSTD == null)
_DurationSTD = 0;
if (_Duration == null)
_Duration = 0;
}
#endregion
#region Properties
public override bool IsDirty
{
get { return base.IsDirty || !SameRatingChecked(SelectedGoals, this.DataContract.Goals); }
}
public int? DistanceInMeter
{
get { return _DistanceInMeter; }
set
{
if (AreDifferent(_DistanceInMeter, value))
{
_DistanceInMeter = value;
StoreDirtyInformation(AreDifferent(DataContract.DistanceInMeter, value), PropertyName_DistanceInMeter);
FirePropertyChanged(PropertyName_DistanceInMeter);
}
}
}
public decimal AssistanceDuration
{
get
{
if (GroupOid != null)
{
return RoundedDuration;
}
if (_Duration != null)
{
return Duration.Value;
}
return 0;
}
}
public Brush BackgroundBrush
{
get
{
Brush brush = null;
if (_GroupOid != null)
{
brush = Application.Current.FindResource("GroupBookingBackgroundBrush") as Brush;
}
return brush ?? Brushes.White;
}
}
public String CategoryString
{
get { return _Category != null ? _Category.ToString() : null; }
}
public String ServiceDescriptionString
{
get { return _ServiceDescription != null ? _ServiceDescription.ToString() : null; }
}
public List<ValueListEntryDC> AllGoalCategories
{
get { return _AllGoalCategories; }
set { _AllGoalCategories = value; }
}
public List<ValueListEntryDC> AllGoals
{
get { return _AllGoals; }
set { _AllGoals = value; }
}
public ServiceCategoryDC Category
{
get { return _Category; }
set
{
if (AreDifferent(_Category, value))
{
_Category = value;
ServiceDescription = null;
FirePropertyChanged(PropertyName_Category);
FirePropertyChanged(PropertyName_PossibleServiceDescriptions);
}
}
}
public Dictionary<ServiceCategoryDC, List<ServiceDescriptionDC>> Category2Services
{
get { return _Category2Services; }
set
{
_Category2Services = value;
FirePropertyChanged(PropertyName_Category2Services);
FirePropertyChanged(PropertyName_SortedCategories);
FirePropertyChanged(PropertyName_PossibleServiceDescriptions);
}
}
public IList<ServiceCategoryDC> SortedCategories
{
get
{
return Category2Services != null ? Category2Services.Keys.OrderBy(cat => cat.Position).ToList() : null;
}
}
public FlatSupportConceptTreeNodeDC ChoosenNode
{
get { return _ChoosenNode; }
set
{
_ChoosenNode = value;
if (value != null)
{
if (value.SupportConceptTreeNodeDC != null)
{
if (Employee == null)
{
Employee = value.SupportConceptTreeNodeDC.Employee;
}
Customer = value.SupportConceptTreeNodeDC.Customer;
SupportConcept = value.SupportConceptTreeNodeDC.SupportConcept;
CostBearer = value.SupportConceptTreeNodeDC.CostBearer;
}
}
else
{
Employee = null;
Customer = null;
SupportConcept = null;
CostBearer = null;
}
}
}
public CompactOrganisationDC CostBearer
{
get { return _CostBearer; }
set
{
if (AreDifferent(_CostBearer, value))
{
_CostBearer = value;
StoreDirtyInformation(!AreEqual(DataContract.CostBearer, value), PropertyName_CostBearer);
FirePropertyChanged(PropertyName_CostBearer);
FirePropertyChanged(PropertyName_RoundedDuration);
}
}
}
[Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
public CompactCustomerDC Customer
{
get { return _Customer; }
set
{
if (AreDifferent(_Customer, value))
{
_Customer = value;
StoreDirtyInformation(!AreEqual(DataContract.Customer, value), PropertyName_Customer);
FirePropertyChanged(PropertyName_Customer);
}
}
}
[Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
public DateTime? Date
{
get { return _Date; }
set
{
if (AreDifferent(_Date, value))
{
_Date = value;
if (BeWoApp.AppSettings.IsEndDateVisible && ServiceRecordFormat == null || ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitEndDatum)
{
if (value.HasValue && EditableEndDate.HasValue)
{
if (value.Value.Date > EditableEndDate.Value.Date)
{
_EditableEndDate = new DateTime(value.Value.Year, value.Value.Month, value.Value.Day, EditableEndDate.Value.Hour, EditableEndDate.Value.Minute, EditableEndDate.Value.Second);
//_EditableEndDate = Date;
}
}
var realDate = value;
if (!StartTime.HasValue)
{
if (realDate.Value.Second == 0)
{
realDate = realDate.Value.AddSeconds(1);
}
}
var x = _EditableEndDate.Value.Subtract(realDate.Value);
if (_DurationInStunden == ZeiterfassungsDauer.Minuten)
{
_DurationSTD = (decimal)x.TotalMinutes;
}else{
_DurationSTD = (decimal)x.TotalHours;
}
FirePropertyChanged(PropertyName_DurationSTD);
TimeCheckForDurationSTD();
}
else
{
TimeCheck();
}
FirePropertyChanged(PropertyName_Date);
}
}
}
public DateTime? DateAndTime
{
get
{
var date = _Date;
var time = _StartTime;
// beim addend er zeit / dadurch das dateTime und Startime gleich sind werden diese zusammen gerechnet und das löst den fehler aus.
//also inprinzip nur date zurück geben und kuken was danach passiert
// dadurch das eine neuentwicklung stattgefunden hat, scheint dieser bereich nicht mehr nötig zu sein
if (date != null && time != null)
{
if(date.Value.Second != time.Value.Second)
date = date.Value.AddSeconds(time.Value.Second);
time = new DateTime(date.Value.Year,date.Value.Month,date.Value.Day,time.Value.Hour,time.Value.Minute,time.Value.Second);
}
return time; // date
}
}
public DateTime? StartDate
{
get { return DateAndTime; }
}
public DateTime? StartMinutes
{
get { return StartDate.HasValue && StartDate.Value.Second == 0 ? StartDate : null; }
}
public DateTime? EndMinutes
{
get { return EndDate.HasValue && EndDate.Value.Second == 0 ? EndDate : null; }
}
public DateTime? EndDate
{
get
{
if(_EndDate == null){
var dt = DateAndTime;
if (dt.HasValue)
{
if (_StartTime != null)
{
var timeDt = _StartTime.Value;
if (_DurationInStunden == ZeiterfassungsDauer.Minuten)
{
if (GroupOid != null && GroupRoundedDuration != null)
{
dt = timeDt.AddMinutes((double)GroupRoundedDuration);
}
else
{
dt = timeDt.AddMinutes((double)RoundedDuration);
}
}
else
{
if (GroupOid != null && GroupRoundedDuration != null)
{
var x = GroupRoundedDuration/60;
dt = timeDt.AddHours((double)x /*(double)GroupRoundedDuration*/);
}
else
{
var x = RoundedDuration / 60;
dt = timeDt.AddHours((double)x /*(double)RoundedDuration*/);
}
}
}
}
return dt;
}
else
{
return _EndDate;
}
}
set
{
if (AreDifferent(_EndDate, value))
{
_EndDate = value;
FirePropertyChanged(PropertyName_EndDate);
}
}
}
public String Id
{
get { return String.Format("{0}", DataContract.ServiceRecordOid); }
}
[Validation(ValidationRule = ValidationRules.GreaterThanOrEqualZero)]
public decimal? Duration
{
get
{
if (_Duration == null )
{
return 0;
}else{
return _Duration;
}
}
set
{
if (AreDifferent(_Duration, value))
{
_Duration = value;
TimeCheck();
FirePropertyChanged(PropertyName_Duration);
FirePropertyChanged(PropertyName_RoundedDuration);
}
}
}
public string DurationAndRoundedDuration
{
get
{
var rd = BeWoWpfUtils.GetDecimalValueWithMaxDecimal(RoundedDuration, 2);
if (Category != null && Category.Percentage > 0 && Category.Percentage < 100)
{
rd = rd * Category.Percentage / 100;
}
//if(_ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitEndDatum) {
// var strResult = _GroupOid != null ? string.Format("{0} ({0})", rd) : $"{DurationSTD} ({rd})";
// return strResult;
//}
if (_ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitMonatJahr)
{
var strResult = _GroupOid != null ? string.Format("{0:0.##} ({0:0.##})", rd) : $"{DurationMonthYearGes} ({rd})";
return strResult;
}
if (DurationInStunden.HasValue && DurationInStunden.Value == ZeiterfassungsDauer.Stunden)
{
return _GroupOid != null ? string.Format("{0:0.##} ({0:0.##})", rd / 60) : $"{DurationSTD:0.##} ({rd / 60:0.##})";
}
return _GroupOid != null ? $"{rd} ({rd})" : $"{Duration} ({rd})";
}
}
public bool EditAllowed
{
get
{
var allowed = false;
if (BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecordView_Edit))
{
allowed = true;
}
else if (BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecord_AllowChangeWithin24Hours))
{
if (_InsertedOn != null)
{
if (DateTime.Now < _InsertedOn.Value.AddDays(1))
{
allowed = true;
}
}
}
if (allowed && BeWoApp.AppSettings.MaxDaysEditServiceRecordsAllowed > 0)
{
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecord_AllowEditAfterMaxDaysInNextMonth))
{
if (Date != null)
{
var dt = new DateTime(Date.Value.Year, Date.Value.Month, 1);
dt = dt.AddMonths(1);
dt = dt.AddDays(BeWoApp.AppSettings.MaxDaysEditServiceRecordsAllowed);
if (DateTime.Now >= dt)
{
allowed = false;
}
}
}
}
if (allowed && !BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecord_AllowEditForOtherEmployees))
{
if (BeWoApp.LoggedOnEmployee.EmployeeOid != Employee.EmployeeOid)
allowed = false;
}
if (allowed && GroupOid.HasValue)
{
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecord_AllowCreatingGroupBooking))
{
allowed = false;
}
}
if (allowed && BeWoApp.AppSettings.AnzTageZeiterfassErfolgt > 0)
{
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecordAllowEditAfterMindays))
{
if (Date != null)
{
var dt = new DateTime(Date.Value.Year, Date.Value.Month, Date.Value.Day);
dt = dt.AddDays(BeWoApp.AppSettings.AnzTageZeiterfassErfolgt + 1);
if (DateTime.Now >= dt)
{
allowed = false;
}
}
}
}
return _EditAllowed && allowed;
}
set { _EditAllowed = value; }
}
public bool DeleteAllowed
{
get
{
var allowed = false;
if (BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecordView_Delete))
{
allowed = true;
}
else if (BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecord_AllowChangeWithin24Hours))
{
if (_InsertedOn != null)
{
if (DateTime.Now < _InsertedOn.Value.AddDays(1))
{
allowed = true;
}
}
}
if (allowed && BeWoApp.AppSettings.MaxDaysEditServiceRecordsAllowed > 0)
{
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecord_AllowEditAfterMaxDaysInNextMonth))
{
if (Date != null)
{
var dt = new DateTime(Date.Value.Year, Date.Value.Month, 1);
dt = dt.AddMonths(1);
dt = dt.AddDays(BeWoApp.AppSettings.MaxDaysEditServiceRecordsAllowed);
if (DateTime.Now >= dt)
{
allowed = false;
}
}
}
}
if (allowed && BeWoApp.AppSettings.AnzTageZeiterfassErfolgt > 0)
{
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecordAllowEditAfterMindays))
{
if (Date != null)
{
var dt = new DateTime(Date.Value.Year, Date.Value.Month, Date.Value.Day);
dt = dt.AddDays(BeWoApp.AppSettings.AnzTageZeiterfassErfolgt + 1);
if (DateTime.Now >= dt)
{
allowed = false;
}
}
}
}
if (allowed && !BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecord_AllowEditForOtherEmployees))
{
if (BeWoApp.LoggedOnEmployee.EmployeeOid != Employee.EmployeeOid)
allowed = false;
}
if (allowed && GroupOid.HasValue)
{
if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecord_AllowCreatingGroupBooking))
{
allowed = false;
}
}
return _DeleteAllowed && allowed;
}
set { _DeleteAllowed = value; }
}
public static bool IsHistoryAllowed
{
get { return BeWoApp.LoggedOnUser.HasRight(UserRightType.ServiceRecord_ShowHistory); }
}
[Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
public CompactEmployeeDC Employee
{
get { return _Employee; }
set
{
if (AreDifferent(_Employee, value))
{
_Employee = value;
StoreDirtyInformation(!AreEqual(DataContract.Employee, value), PropertyName_Employee);
FirePropertyChanged(PropertyName_Employee);
}
}
}
public string EmployeeName
{
get
{
if (_Employee != null)
{
return _Employee.FirstName + " " + _Employee.LastName;
}
return string.Empty;
}
}
public String EndTimeEditString
{
get
{
if (_EndTime == null || _EndTime.Value.Second != 0)
{
return null;
}
return String.Format("{0:HH:mm}", _EndTime);
}
set
{
if (String.IsNullOrEmpty(value))
EndTime = null;
else
{
if (BeWoApp.AppSettings.IsEndDateVisible && ServiceRecordFormat == null || ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitEndDatum)
{
DateTime? endTime = EditableEndDate;
String dtStr = String.Format("{0:dd.MM.yyyy} {1}", endTime, value);
DateTime dt;
if (DateTime.TryParse(dtStr, out dt))
EndTime = dt;
else
EndTime = null;
}
else
{
DateTime? endTime = EndTime;
if (!endTime.HasValue)
endTime = EndDate;
if (!endTime.HasValue)
endTime = DateTime.Now;
String dtStr = String.Format("{0:dd.MM.yyyy} {1}", endTime, value);
DateTime dt;
if (DateTime.TryParse(dtStr, out dt))
EndTime = dt;
else
EndTime = null;
}
}
}
}
public DateTime? EditableEndDate
{
get {
if (BeWoApp.AppSettings.IsEndDateVisible && ServiceRecordFormat == null || ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitEndDatum)
{
//var x = new DateTime(_EditableEndDate.Value.Year, _EditableEndDate.Value.Month, _EditableEndDate.Value.Day, _EditableEndDate.Value.Hour, _EditableEndDate.Value.Minute,0);
return _EditableEndDate;
// return x;
}else{
return null;
}
}
set
{
if (BeWoApp.AppSettings.IsEndDateVisible && ServiceRecordFormat == null || ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitEndDatum)
{
if (AreDifferent(_EditableEndDate, value))
{
if (value.HasValue && DateAndTime.HasValue)
{
if (value.Value.Date < DateAndTime.Value.Date)
{
_Date = new DateTime(value.Value.Year, value.Value.Month, value.Value.Day, DateAndTime.Value.Hour, DateAndTime.Value.Minute, DateAndTime.Value.Second);
//_EditableEndDate = Date;
}
_EditableEndDate = value;
}
if (DateAndTime.HasValue)
{
var x = _EditableEndDate.Value.Subtract(DateAndTime.Value);
if (_DurationInStunden == ZeiterfassungsDauer.Minuten)
{
_DurationSTD = (decimal) x.TotalMinutes;
}
else
{
_DurationSTD = (decimal) x.TotalHours;
}
}
TimeCheckForDurationSTD();
FirePropertyChanged(PropertyName_EditableEndDate);
FirePropertyChanged(PropertyName_DurationSTD);
}
}
}
}
public DateTime? EndTime
{
get {
if (BeWoApp.AppSettings.IsEndDateVisible && ServiceRecordFormat == null || ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitEndDatum)
{
if (!_EndTime.HasValue )
return DateTime.Now.Date;
else
return _EndTime;
}
else
return _EndTime;
}
set
{
bool cont = (_EndTime == null && value != null) || (_EndTime != null && value == null) || (_EndTime != null && _EndTime.Value.TimeOfDay != value.Value.TimeOfDay);
if (cont)
{
if (value != null)
{
Console.WriteLine("Change EndTime " + value.Value.ToShortTimeString());
}
_EndTime = value;
if (_EndTime != null)
{
if (BeWoApp.AppSettings.IsEndDateVisible && ServiceRecordFormat == null || ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitEndDatum)
{
//if (_StartTime.Value.Date == null)
//{
// StartTime = new DateTime(StartTime.Value.Year, StartTime.Value.Month, StartTime.Value.Day, StartTime.Value.Hour, 0, 0);
//}
if (StartTime != null)
{
_StartTime = new DateTime(Date.Value.Year, Date.Value.Month, Date.Value.Day, StartTime.Value.Hour,
StartTime.Value.Minute, StartTime.Value.Second);
}
else
{
_StartTime = new DateTime(Date.Value.Year, Date.Value.Month, Date.Value.Day, 0, 0, 1);
}
var diff = _EndTime.Value.Subtract(_StartTime.Value);
if (_DurationInStunden == ZeiterfassungsDauer.Stunden)
{
_DurationSTD = (decimal)diff.TotalHours;
}
else
{
_DurationSTD = (decimal)diff.TotalMinutes;
}
TimeCheckForDurationSTD();
FirePropertyChanged(PropertyName_DurationSTD);
}
else
{
if (_StartTime.Value.Second != 0)
{
StartTime = new DateTime(_EndTime.Value.Year, _EndTime.Value.Month, _EndTime.Value.Day, _EndTime.Value.Hour, 0, 0);
}
var start = new DateTime(_EndTime.Value.Year, _EndTime.Value.Month, _EndTime.Value.Day, StartTime.Value.Hour, StartTime.Value.Minute, 0);
if (start.TimeOfDay > _EndTime.Value.TimeOfDay)
{
_EndTime = _EndTime.Value.AddDays(1);
}
var diff = _EndTime.Value.Subtract(start);
if (_DurationInStunden == ZeiterfassungsDauer.Stunden)
{
_Duration = (decimal)diff.TotalHours;
}
else
{
_Duration = (decimal)diff.TotalMinutes;
}
TimeCheck();
FirePropertyChanged(PropertyName_Duration);
}
}
FirePropertyChanged(PropertyName_EndTime);
}
}
}
public List<SupportConceptGoalDC> GoalTree
{
get { return _GoalTree; }
set
{
_GoalTree = value;
FirePropertyChanged(PropertyName_GoalTree);
FirePropertyChanged(PropertyName_IsGoalTreeVisible);
}
}
public int? GroupEmployeeCount
{
get { return _GroupEmployeeCount; }
set
{
if (AreDifferent(_GroupEmployeeCount, value))
{
_GroupEmployeeCount = value;
StoreDirtyInformation(AreDifferent(DataContract.GroupEmployeeCount, value), PropertyName_GroupEmployeeCount);
FirePropertyChanged(PropertyName_GroupEmployeeCount);
}
}
}
public long? GroupOid
{
get { return _GroupOid; }
set { _GroupOid = value; }
}
public long? SignatureOid
{
get { return _SignatureOid; }
set { _SignatureOid = value; }
}
public ImageSource IsUnterschrift
{
get
{
if(_SignatureOid != null) {
if (haekchenBitmapImage == null)
{
haekchenBitmapImage = CreateImage("pack://application:,,,/BeWoPlaner;component/Ressources/Icons/Haeckchen.png");
}
return haekchenBitmapImage;
}
else
{
return null;
}
}
//set { _isUnterschrift = value; }
}
private BitmapImage CreateImage(String path)
{
BitmapImage bix = new BitmapImage();
bix.BeginInit();
bix.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
bix.CacheOption = BitmapCacheOption.OnLoad;
bix.UriSource = new Uri(path);
bix.EndInit();
return bix;
}
public int? GroupPersonCount
{
get { return _GroupPersonCount; }
set
{
if (AreDifferent(_GroupPersonCount, value))
{
_GroupPersonCount = value;
StoreDirtyInformation(AreDifferent(DataContract.GroupPersonCount, value), PropertyName_GroupPersonCount);
FirePropertyChanged(PropertyName_GroupPersonCount);
}
}
}
public decimal? GroupRoundedDuration
{
get { return _GroupRoundedDuration; }
set
{
if (AreDifferent(_GroupRoundedDuration, value))
{
_GroupRoundedDuration = value;
StoreDirtyInformation(AreDifferent(DataContract.GroupRoundedDuration, value), PropertyName_GroupRoundedDuration);
FirePropertyChanged(PropertyName_GroupRoundedDuration);
}
}
}
public int Index { get; set; }
public string InsUser
{
get { return _InsUser; }
set { _InsUser = value; }
}
public string InsertedOn
{
get
{
if (_InsertedOn != null)
{
return _InsertedOn.Value.ToShortDateString() + " " + _InsertedOn.Value.ToShortTimeString();
}
return null;
}
}
public DateTime? InsertedOnDateTime
{
get { return _InsertedOn; }
}
public bool IsGoalTreeVisible
{
get { return _GoalTree != null && _GoalTree.Count > 0; }
}
public string LongDateString
{
get
{
var date = string.Empty;
string time = string.Empty;
string endtime = string.Empty;
if (_StartTime != null)
{
var timeDt = _StartTime.Value;
if (timeDt.Second == 0)
{
time = timeDt.ToShortTimeString();
if (_DurationInStunden == ZeiterfassungsDauer.Stunden)
{
if (GroupOid != null && GroupRoundedDuration != null)
{
timeDt = timeDt.AddMinutes((double)GroupRoundedDuration);
}
else
{
timeDt = timeDt.AddMinutes((double)RoundedDuration);
}
}
else
{
if (GroupOid != null && GroupRoundedDuration != null)
{
timeDt = timeDt.AddMinutes((double)GroupRoundedDuration);
}
else
{
timeDt = timeDt.AddMinutes((double)RoundedDuration);
}
}
endtime = timeDt.ToShortTimeString();
//time = time + " - " + timeDt.ToShortTimeString();
}
}
if (_Date != null)
{
if (endtime.Equals("") && time.Equals(""))
{
date = DateTimeFormatInfo.CurrentInfo.GetAbbreviatedDayName(_Date.Value.DayOfWeek) + ", " + _Date.Value.ToShortDateString();
}
else {
if (_EditableEndDate.HasValue) {
if (_EditableEndDate.Value.Date != _Date.Value.Date)
{
time = StartTime.Value.TimeOfDay.ToString();
endtime = _EditableEndDate.Value.TimeOfDay.ToString();
date = DateTimeFormatInfo.CurrentInfo.GetAbbreviatedDayName(_Date.Value.DayOfWeek) + ", " + _Date.Value.ToShortDateString() + " " + time + " - " + _EditableEndDate.Value.ToShortDateString() + " " + endtime;
}
else
{
time = time + " - " + endtime;
date = DateTimeFormatInfo.CurrentInfo.GetAbbreviatedDayName(_Date.Value.DayOfWeek) + ", " + _Date.Value.ToShortDateString() + " " + time;
}
}
else
{
time = time + " - " + endtime;
date = DateTimeFormatInfo.CurrentInfo.GetAbbreviatedDayName(_Date.Value.DayOfWeek) + ", " + _Date.Value.ToShortDateString() + " " + time;
}
}
}
//date += " " + time;
if (GroupOid != null && GroupPersonCount != null && GroupRoundedDuration != null)
{
if (_DurationInStunden == ZeiterfassungsDauer.Stunden)
{
date += " Gruppe (" + GroupPersonCount.Value + " Teilnehmer, " + GroupEmployeeCount.Value +
" Betreuer). Dauer: " +
BeWoWpfUtils.GetDecimalValueWithMaxDecimal(GroupRoundedDuration.Value / 60, 2) + " Stunden.";
}
else
{
date += " Gruppe (" + GroupPersonCount.Value + " Teilnehmer, " + GroupEmployeeCount.Value +
" Betreuer). Dauer: " +
BeWoWpfUtils.GetDecimalValueWithMaxDecimal(GroupRoundedDuration.Value, 2) + " Minuten.";
}
}
return date;
}
}
public Brush MouseOverBackgroundBrush
{
get
{
Brush brush = null;
if (_GroupOid != null)
{
brush = Application.Current.FindResource("GroupBookingMouseOverBackgroundBrush") as Brush;
}
return brush ?? new SolidColorBrush(Color.FromArgb(0xFF, 0xCC, 0xE0, 0xFF));
}
}
[Validation(ValidationRule = ValidationRules.EmptyNoticeInNewServiceRecordsAllowed)]
public string Notice
{
get { return _Notice; }
set
{
if (AreDifferent(_Notice, value))
{
_Notice = value;
StoreDirtyInformation(AreDifferent(DataContract.Notice, value), PropertyName_Notice);
FirePropertyChanged(PropertyName_Notice);
}
}
}
public string Notice2
{
get { return _Notice2; }
set
{
if (AreDifferent(_Notice2, value))
{
_Notice2 = value;
StoreDirtyInformation(AreDifferent(DataContract.Notice2, value), PropertyName_Notice2);
FirePropertyChanged(PropertyName_Notice2);
}
}
}
public string Notice3
{
get { return _Notice3; }
set
{
if (AreDifferent(_Notice3, value))
{
_Notice3 = value;
StoreDirtyInformation(AreDifferent(DataContract.Notice3, value), PropertyName_Notice3);
FirePropertyChanged(PropertyName_Notice3);
}
}
}
public string Notice4
{
get { return _Notice4; }
set
{
if (AreDifferent(_Notice4, value))
{
_Notice4 = value;
StoreDirtyInformation(AreDifferent(DataContract.Notice4, value), PropertyName_Notice4);
FirePropertyChanged(PropertyName_Notice4);
}
}
}
public string Notice5
{
get { return _Notice5; }
set
{
if (AreDifferent(_Notice5, value))
{
_Notice5 = value;
StoreDirtyInformation(AreDifferent(DataContract.Notice5, value), PropertyName_Notice5);
FirePropertyChanged(PropertyName_Notice5);
}
}
}
public string RTFNotice
{
get { return _RTFNotice; }
set
{
if (AreDifferent(_RTFNotice, value))
{
_RTFNotice = value;
StoreDirtyInformation(AreDifferent(DataContract.RTFNotice1, value), PropertyName_RTFNotice);
FirePropertyChanged(PropertyName_RTFNotice);
}
}
}
public string RTFNotice2
{
get { return _RTFNotice2; }
set
{
if (AreDifferent(_RTFNotice2, value))
{
_RTFNotice2 = value;
StoreDirtyInformation(AreDifferent(DataContract.RTFNotice2, value), PropertyName_RTFNotice2);
FirePropertyChanged(PropertyName_RTFNotice2);
}
}
}
public string RTFNotice3
{
get { return _RTFNotice3; }
set
{
if (AreDifferent(_RTFNotice3, value))
{
_RTFNotice3 = value;
StoreDirtyInformation(AreDifferent(DataContract.RTFNotice3, value), PropertyName_RTFNotice3);
FirePropertyChanged(PropertyName_RTFNotice3);
}
}
}
public string RTFNotice4
{
get { return _RTFNotice4; }
set
{
if (AreDifferent(_RTFNotice4, value))
{
_RTFNotice4 = value;
StoreDirtyInformation(AreDifferent(DataContract.RTFNotice4, value), PropertyName_RTFNotice4);
FirePropertyChanged(PropertyName_RTFNotice4);
}
}
}
public string RTFNotice5
{
get { return _RTFNotice5; }
set
{
if (AreDifferent(_RTFNotice5, value))
{
_RTFNotice5 = value;
StoreDirtyInformation(AreDifferent(DataContract.RTFNotice5, value), PropertyName_RTFNotice5);
FirePropertyChanged(PropertyName_RTFNotice5);
}
}
}
public List<ServiceDescriptionDC> PossibleServiceDescriptions
{
get
{
if (_Category == null)
{
return null;
}
return _Category2Services.ContainsKey(_Category) ? _Category2Services[_Category] : null;
}
}
public decimal RoundedDurationAnzeige
{
get
{
if (_ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitMonatJahr || (DurationInStunden.HasValue && DurationInStunden.Value == ZeiterfassungsDauer.Stunden))
{
return _RoundedDuration/60;
}
else
{
return _RoundedDuration;
}
}
}
public decimal RoundedDuration
{
get { return _RoundedDuration; }
set { _RoundedDuration = value; }
}
public Brush SelectedBackgroundBrush
{
get
{
Brush brush = null;
if (_GroupOid != null)
{
brush = Application.Current.FindResource("GroupBookingSelectedBackgroundBrush") as Brush;
}
return brush ?? new SolidColorBrush(Color.FromArgb(0xFF, 0x93, 0xBC, 0xFF));
}
}
public bool HasGoals
{
get { return SelectedGoals.Count > 0; }
}
public String GoalString
{
get
{
var goals = "";
foreach (var goal in SelectedGoals)
{
if (goals.Length > 0)
goals += ", ";
goals += CreateGoalString(goal);
}
return goals;
}
}
private string CreateGoalString(ValueListEntryDC goal)
{
String name = goal.TypeDescription;
if (!String.IsNullOrWhiteSpace(goal.Abbreviation))
{
String code = goal.Abbreviation;
if (goal.Rating.HasValue && goal.Rating.Value >= 0)
{
code = String.Format("{0}.{1}", code, goal.Rating.Value);
}
name = String.Format("{0}: {1}", code, name);
}
return name;
}
public ObservableSortCollection<ValueListEntryDC> SelectedGoals
{
get
{
return _SelectedGoals ?? (_SelectedGoals = new ObservableSortCollection<ValueListEntryDC>(Comparer.ValueListEntryDCComparer));
}
}
[Validation(ValidationRule = ValidationRules.NotNullOrStringEmpty)]
public ServiceDescriptionDC ServiceDescription
{
get { return _ServiceDescription; }
set
{
if (AreDifferent(_ServiceDescription, value))
{
_ServiceDescription = value;
StoreDirtyInformation(!AreEqual(DataContract.ServiceDescription, value), PropertyName_ServiceDescription);
FirePropertyChanged(PropertyName_ServiceDescription);
}
}
}
public string ShortDateString
{
get
{
var date = string.Empty;
if (_Date != null)
{
date = _Date.Value.ToShortDateString();
}
return date;
}
}
public string ShortNotice
{
get
{
var desc = Notice;
if (desc.IndexOf("\r\n") > 0)
{
desc = desc.Substring(0, desc.IndexOf("\r\n"));
}
return desc;
}
}
public string ShortTimeString
{
get
{
var str = string.Empty;
if (_StartTime != null && _StartTime.Value.Second == 0)
{
str = _StartTime.Value.ToShortTimeString();
}
return str;
}
}
public String StartTimeEditString
{
get
{
if (_StartTime == null || _StartTime.Value.Second != 0)
{
return null;
}
return String.Format("{0:HH:mm}", _StartTime);
}
set
{
if (String.IsNullOrEmpty(value))
StartTime = null;
else
{
var startTime = StartTime;
if (!startTime.HasValue)
{
startTime = StartDate;
}
if (!startTime.HasValue)
{
startTime = DateTime.Now;
}
var dtStr = String.Format("{0:dd.MM.yyyy} {1}", startTime, value);
DateTime dt;
if (DateTime.TryParse(dtStr, out dt))
{
StartTime = dt;
}
else
{
StartTime = null;
}
}
}
}
public DateTime? StartTime
{
get
{
if(_StartTime != null)
return _StartTime.Value.Second != 0 ? null : _StartTime;
else
{
return new DateTime();
}
}
set
{
DateTime? newStartTime = value ?? NULL_TIME;
Console.WriteLine("Change StartTime " + newStartTime.Value.ToShortTimeString());
if ((_StartTime == null && newStartTime != NULL_TIME) ||
(_StartTime != null && _StartTime.Value.TimeOfDay != newStartTime.Value.TimeOfDay))
{
_StartTime = newStartTime;
if (_StartTime.Value.Second == 0)
{
if (_EndTime == null && Duration.HasValue)
{
if (_DurationInStunden == ZeiterfassungsDauer.Stunden)
{
_EndTime = _StartTime.Value.AddHours((int)Duration.Value);
}
else
{
_EndTime = _StartTime.Value.AddMinutes((int)Duration.Value);
}
}
if (_EndTime != null)
{
var end = new DateTime(_StartTime.Value.Year, _StartTime.Value.Month, _StartTime.Value.Day,
_EndTime.Value.Hour, _EndTime.Value.Minute, 0);
if (_EndTime.Value.Second > 0 && Duration.HasValue)
{
end = new DateTime(_StartTime.Value.Year, _StartTime.Value.Month, _StartTime.Value.Day,
_StartTime.Value.Hour, _StartTime.Value.Minute, 0);
if (_DurationInStunden == ZeiterfassungsDauer.Stunden)
{
end = end.AddHours((int)Duration.Value);
}
else
{
end = end.AddMinutes((int)Duration.Value);
}
}
var diff = end.Subtract(_StartTime.Value);
if (diff.TotalSeconds < 0)
{
EndTime = _StartTime;
end = EndTime.Value;
}
diff = end.Subtract(_StartTime.Value);
if (BeWoApp.AppSettings.IsEndDateVisible && ServiceRecordFormat == null || ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitEndDatum)
{
EditableEndDate = end;
var x = _EditableEndDate.Value.Subtract(_StartTime.Value);
if (_DurationInStunden == ZeiterfassungsDauer.Stunden)
{
DurationSTD = (decimal) x.TotalHours;
}
else
{
DurationSTD = (decimal) x.TotalMinutes;
}
FirePropertyChanged(PropertyName_DurationSTD);
TimeCheckForDurationSTD();
}
else
{
if (_DurationInStunden == ZeiterfassungsDauer.Stunden)
{
Duration = (decimal) diff.TotalHours;
}
else
{
Duration = (decimal)diff.TotalMinutes;
}
FirePropertyChanged(PropertyName_Duration);
TimeCheck();
}
}
//else
//{
// if (BeWoApp.AppSettings.IsEndDateVisible)
// {
// if (_DurationInStunden == ZeiterfassungsDauer.Stunden)
// {
// EndTime = _StartTime.Value.AddHours(DurationSTD.Value);
// }else{
// EndTime = _StartTime.Value.AddMinutes(DurationSTD.Value);
// }
// }else{
// if (_DurationInStunden == ZeiterfassungsDauer.Stunden)
// {
// EndTime = _StartTime.Value.AddHours(Duration.Value);
// }else{
// EndTime = _StartTime.Value.AddMinutes(Duration.Value);
// }
// }
//}
}
else
{
TimeCheck();
}
StoreDirtyInformation(true, PropertyName_SupportConcept);
FirePropertyChanged(PropertyName_StartTime);
var test = this.IsDirty;
}
}
}
public CompactSupportConceptDC SupportConcept
{
get { return _SupportConcept; }
set
{
if (AreDifferent(_SupportConcept, value))
{
_SupportConcept = value;
CostBearer = null;
StoreDirtyInformation(!AreEqual(DataContract.SupportConcept, value), PropertyName_SupportConcept);
FirePropertyChanged(PropertyName_SupportConcept);
FirePropertyChanged(PropertyName_PossibleCostBearers);
}
}
}
public ServiceRecordTypeId ServiceRecordType
{
get { return _ServiceRecordType; }
set
{
if (AreDifferent(_ServiceRecordType, value))
{
_ServiceRecordType = value;
StoreDirtyInformation(!AreEqual(DataContract.ServiceRecordType, value), PropertyName_ServiceRecordType);
FirePropertyChanged(PropertyName_ServiceRecordType);
FirePropertyChanged(PropertyName_IsServiceRecordTypeContent);
FirePropertyChanged(PropertyName_IsServiceRecordTypeDefaultActivity);
}
}
}
public bool IsServiceRecordTypeContent
{
get { return ServiceRecordType == ServiceRecordTypeId.Content; }
set { ServiceRecordType = value ? ServiceRecordTypeId.Content : ServiceRecordTypeId.DefaultActivity; }
}
public bool IsServiceRecordTypeDefaultActivity
{
get { return ServiceRecordType == ServiceRecordTypeId.DefaultActivity; }
set { ServiceRecordType = value ? ServiceRecordTypeId.DefaultActivity : ServiceRecordTypeId.Content; }
}
public ZeiterfassungsDauer? DurationInStunden
{
get
{
if(_DurationInStunden == null)
{
_DurationInStunden = ZeiterfassungsDauer.Minuten;
return _DurationInStunden;
}
else
{
return _DurationInStunden;
}
}
set
{
if (value == ZeiterfassungsDauer.Minuten && _DurationInStunden == ZeiterfassungsDauer.Stunden )
{
if (BeWoApp.AppSettings.IsZeiterfassDateNormal && ServiceRecordFormat == null || ServiceRecordFormat == ServiceRecordFormate.OriginaleZeiterfassung )
{
if (_Duration.HasValue)
{
var x = _Duration.Value * 60;
_Duration = x; //Math.Round(x,2);
}
}
if (BeWoApp.AppSettings.IsEndDateVisible && ServiceRecordFormat == null || ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitEndDatum)
{
if (_DurationSTD.HasValue)
{
var x = _DurationSTD.Value * 60;
_DurationSTD = x; //Math.Round(x, 2);
}
}
}
else if (value == ZeiterfassungsDauer.Stunden && _DurationInStunden == ZeiterfassungsDauer.Minuten )
{
if (BeWoApp.AppSettings.IsZeiterfassDateNormal && ServiceRecordFormat == null|| ServiceRecordFormat == ServiceRecordFormate.OriginaleZeiterfassung)
{
if (_Duration.HasValue)
{
var x = _Duration.Value / 60;
_Duration = x;// Math.Round(x, 2);
}
}
if (BeWoApp.AppSettings.IsEndDateVisible && ServiceRecordFormat == null || ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitEndDatum)
{
if (_DurationSTD.HasValue)
{
var x = _DurationSTD.Value / 60;
_DurationSTD = x; /* Math.Round(x, 2);*/
}
}
}
if (AreDifferent(_DurationInStunden, value))
{
_DurationInStunden = value;
StoreDirtyInformation(AreDifferent(DataContract.DurationInStunden, value), PropertyName_DurationInStunden);
FirePropertyChanged(PropertyName_DurationInStunden);
if (BeWoApp.AppSettings.IsEndDateVisible && ServiceRecordFormat == null|| ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitEndDatum)
{
TimeCheckForDurationSTD();
FirePropertyChanged(PropertyName_DurationSTD);
}else
if (BeWoApp.AppSettings.IsZeiterfassDateNormal && ServiceRecordFormat == null || ServiceRecordFormat == ServiceRecordFormate.OriginaleZeiterfassung)
{
TimeCheck();
FirePropertyChanged(PropertyName_Duration);
}
}
}
}
public ServiceRecordFormate? ServiceRecordFormat
{
get{ return _ServiceRecordFormat; }
set
{
if (AreDifferent(_ServiceRecordFormat, value))
{
_ServiceRecordFormat = value;
StoreDirtyInformation(AreDifferent(DataContract.ServiceRecordFormat, value), PropertyName_ServiceRecordFormat);
FirePropertyChanged(PropertyName_ServiceRecordFormat);
}
}
}
public string OnlyMonth
{
get
{
if (_OnlyMonth.IsNullOrEmpty())
{
_OnlyMonth = DateTime.Now.ToString("MMMM");
}
return _OnlyMonth;
}
set
{
if (AreDifferent(_OnlyMonth, value))
{
_OnlyMonth = value;
FirePropertyChanged(PropertyName_OnlyMonth);
}
}
}
public string[] MonateBinden
{
get { return _MonateBinden; }
}
public string[] JahreBind()
{
string[] s = new string[11];
int x = -5;
for (int i = 0; i < 11; i++)
{
var a = DateTime.Now.Year + x;
s[i] = a.ToString();
x++;
}
return s;
}
public string[] JahreBinden
{
get { return JahreBind(); }
}
public string OnlyYear
{
get
{
if (_OnlyYear.IsNullOrEmpty())
{
_OnlyYear = DateTime.Now.Year.ToString();
}
return _OnlyYear;
}
set
{
if (AreDifferent(_OnlyYear, value))
{
_OnlyYear = value;
FirePropertyChanged(PropertyName_OnlyYear);
}
}
}
[Validation(ValidationRule = ValidationRules.GreaterThanOrEqualZero)]
public decimal? DurationSTD
{
get
{
if (_DurationSTD == null )
{
return 0;
}else{
return _DurationSTD;
}
}
set
{
//if (BeWoApp.AppSettings.IsZeiterfassungInStdMin)
//{
if (AreDifferent(_DurationSTD, value))
{
_DurationSTD = value;
StoreDirtyInformation(AreDifferent(DataContract.RoundedDuration, value),
PropertyName_DurationSTD);
FirePropertyChanged(PropertyName_DurationSTD);
FirePropertyChanged(PropertyName_RoundedDuration);
TimeCheckForDurationSTD();
}
//}
//else if (BeWoApp.AppSettings.IsEndDateVisible)
//{
// Duration = val
//}
}
}
[Validation(ValidationRule = ValidationRules.GreaterThanOrEqualZero)]
public decimal? DurationMonthYearGes
{
get
{
if (_DurationMonthYearGes == null)
{
return 0;
}
else
{
return _DurationMonthYearGes;
}
}
set
{
if (AreDifferent(_DurationMonthYearGes, value))
{
_DurationMonthYearGes = value;
StoreDirtyInformation(AreDifferent(DataContract.RoundedDuration, value),
PropertyName_DurationMonthYearGes);
FirePropertyChanged(PropertyName_DurationMonthYearGes);
FirePropertyChanged(PropertyName_RoundedDuration);
TimeCheckMonatJahr();
}
}
}
//public string IsFloatGesetzt
//{
// get { return _IsFloatGesetzt; }
// set
// {
// if (AreDifferent(_IsFloatGesetzt, value))
// {
// _IsFloatGesetzt = value;
// FirePropertyChanged(PropertyName_DurationSTD);
// FirePropertyChanged(PropertyName_Duration);
// }
// }
//}
#endregion
#region Public Methods
public void ChangeGoalTree(List<ValueListEntryDC> goalCats, List<ValueListEntryDC> goals) //, List<ValueListEntryDC> goalsAndCats)
{
//if (!MussGoalTreeAktualisieren(goalCats, goals))
//{
//ValueListEntryDC kopieren?
_AllGoalCategories = goalCats;
_AllGoals = goals;
var newList = new List<ValueListEntryDC>();
if (_AllGoalCategories != null)
{
newList.AddRange(_AllGoalCategories);
}
if (_AllGoals != null)
{
newList.AddRange(_AllGoals);
}
GoalTree = SupportConceptService.CreateGoalTree(newList, SelectedGoals);
//}
}
//private bool MussGoalTreeAktualisieren(List<ValueListEntryDC> goalCats, List<ValueListEntryDC> goals)
//{
// if (IstGleich(goalCats, _AllGoalCategories) && IstGleich(_AllGoals, goals))
// {
// }
// return false;
//}
public void UpdateServiceAccountings(List<ServiceAccountingDC> serviceAccountings, Dictionary<ServiceCategoryDC, List<ServiceDescriptionDC>> allDict, bool hilfeplanAusgewaehlt)
{
_ServiceAccountings = serviceAccountings;
var newCategoryDict = new Dictionary<ServiceCategoryDC, List<ServiceDescriptionDC>>();
foreach (var cat in allDict.Keys)
{
bool add = true;
if (hilfeplanAusgewaehlt && cat.OhneHilfeplan.HasValue && cat.OhneHilfeplan.Value == AccountingvisibilityType.NichtKlientenbezogen)
{
add = false;
}
else if (!hilfeplanAusgewaehlt && cat.OhneHilfeplan.HasValue && cat.OhneHilfeplan.Value == AccountingvisibilityType.NurKlientenbezogen)
{
add = false;
}
if (add)
{
newCategoryDict.Add(cat, allDict[cat]);
}
}
ServiceCategoryDC firstCat = null;
if (_ServiceAccountings != null && allDict != null)
{
var globalServices = _ServiceAccountings.FindAll(sa => sa.ServiceDescription.ScopeType == ScopeTypeId.Global);
var individualServices = _ServiceAccountings.FindAll(sa => sa.ServiceDescription.ScopeType == ScopeTypeId.Individual);
if (globalServices.Count > 0)
{
newCategoryDict = new Dictionary<ServiceCategoryDC, List<ServiceDescriptionDC>>();
foreach (var cat in allDict.Keys)
{
var sdList = allDict[cat];
var newSdList = sdList.Where(sd => globalServices.Exists(sa => sa.ServiceDescription.Equals(sd))).ToList();
if (newSdList.Count > 0)
{
if (firstCat == null || cat.Position < firstCat.Position)
firstCat = cat;
newCategoryDict.Add(cat, newSdList);
}
}
}
if (individualServices.Count > 0)
{
newCategoryDict.Add(individualServices[0].ServiceDescription.Category,
individualServices.Select(sa => sa.ServiceDescription).ToList());
}
}
Category2Services = newCategoryDict;
if (Category == null)
Category = firstCat;
}
public ServiceRecordVM Clone()
{
var dc = new ServiceRecordDC();
return new ServiceRecordVM(CopyToDataContract(dc), _Category2Services, _AllGoalCategories, _AllGoals);
}
public void CopyTo(ServiceRecordVM copy)
{
copy.Notice = Notice;
copy.Notice2 = Notice2;
copy.Notice3 = Notice3;
copy.Notice4 = Notice4;
copy.Notice5 = Notice5;
copy.RTFNotice = RTFNotice;
copy.RTFNotice2 = RTFNotice2;
copy.RTFNotice3 = RTFNotice3;
copy.RTFNotice4 = RTFNotice4;
copy.RTFNotice5 = RTFNotice5;
copy.StartTime = StartTime;
copy.EndTime = EndTime;
copy.Date = Date;
copy.Duration = Duration;
copy.RoundedDuration = RoundedDuration;
copy.ServiceRecordType = ServiceRecordType;
copy.DistanceInMeter = DistanceInMeter;
copy.Employee = Employee;
copy.Customer = Customer;
copy.SupportConcept = SupportConcept;
copy.CostBearer = CostBearer;
copy.Category = Category;
copy.ServiceDescription = ServiceDescription;
copy.GroupEmployeeCount = GroupEmployeeCount;
copy.GroupPersonCount = GroupPersonCount;
copy.GroupOid = GroupOid;
copy.GroupRoundedDuration = GroupRoundedDuration;
copy.SignatureOid = SignatureOid;
copy.DurationInStunden = DurationInStunden;
copy.ServiceRecordFormat = ServiceRecordFormat;
copy.SelectedGoals.Clear();
foreach (var item in SelectedGoals)
{
copy.SelectedGoals.Add(item);
}
copy.GoalTree = GoalTree;
}
public void SetInsertedOn(DateTime dt)
{
_InsertedOn = dt;
}
public override string ToString()
{
return _Customer + ": " + _Date.Value.ToLongDateString() + string.Format("- Dauer: {0:0.00} min", RoundedDuration);
}
#endregion
#region Methods
protected override void InitByDataContract(ServiceRecordDC pDataContract)
{
if (pDataContract.ServiceDescription != null)
{
if (pDataContract.ServiceRecordFormat == ServiceRecordFormate.OriginaleZeiterfassung || pDataContract.ServiceRecordFormat == null)
{
_Date = pDataContract.Start.Value;
_StartTime = pDataContract.Start.Value;
_EditableEndDate = pDataContract.End.Value;
_DurationInStunden = pDataContract.DurationInStunden;
if (pDataContract.DurationInStunden == ZeiterfassungsDauer.Stunden )
{
_DurationSTD = (decimal)(pDataContract.End.Value - pDataContract.Start.Value).TotalHours;
_Duration = _DurationSTD;
_EndTime = pDataContract.Start.Value.AddHours((double)_DurationSTD);
}
else
{
_Duration = (pDataContract.End.Value - pDataContract.Start.Value).GetTotalMinutes();
_EndTime = pDataContract.Start.Value.AddMinutes((double)_Duration.Value);
}
_DurationMonthYearGes = 0;
}
else
{
if (pDataContract.ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitEndDatum)
{
_Date = pDataContract.Start.Value.Date;
_StartTime = pDataContract.Start.Value;
_EndTime = pDataContract.End.Value;
_EditableEndDate = pDataContract.End.Value;
if(pDataContract.DurationInStunden == ZeiterfassungsDauer.Stunden)
{
_DurationSTD = (decimal) (pDataContract.End.Value - pDataContract.Start.Value).TotalHours;
_Duration = _DurationSTD;
}
else
{
_DurationSTD = (pDataContract.End.Value - pDataContract.Start.Value).GetTotalMinutes();
_Duration = _DurationSTD;
}
//_Duration = _DurationSTD;
_DurationMonthYearGes = 0;
}
else if(pDataContract.ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitMonatJahr)
{
_Date = pDataContract.Start.Value.Date;
_StartTime = pDataContract.Start.Value;
_EndTime = pDataContract.End.Value;
_DurationMonthYearGes = (decimal)(pDataContract.End.Value - pDataContract.Start.Value).TotalHours;
_OnlyMonth = pDataContract.Start.Value.ToString("MMMM");
_OnlyYear = pDataContract.Start.Value.ToString("yyyy");
_Duration = 0;
_DurationSTD = 0;
}
}
_Notice = pDataContract.Notice;
_Notice2 = pDataContract.Notice2;
_Notice3 = pDataContract.Notice3;
_Notice4 = pDataContract.Notice4;
_Notice5 = pDataContract.Notice5;
_RTFNotice = pDataContract.RTFNotice1;
_RTFNotice2 = pDataContract.RTFNotice2;
_RTFNotice3 = pDataContract.RTFNotice3;
_RTFNotice4 = pDataContract.RTFNotice4;
_RTFNotice5 = pDataContract.RTFNotice5;
_ServiceDescription = pDataContract.ServiceDescription;
_Employee = pDataContract.Employee;
_Customer = pDataContract.Customer;
_SupportConcept = pDataContract.SupportConcept;
_CostBearer = pDataContract.CostBearer;
_ServiceDescription = pDataContract.ServiceDescription;
_Category = pDataContract.ServiceDescription.Category;
_RoundedDuration = pDataContract.RoundedDuration;
_InsertedOn = pDataContract.InsertedOn;
_InsUser = pDataContract.InsUser;
_GroupEmployeeCount = pDataContract.GroupEmployeeCount;
_GroupPersonCount = pDataContract.GroupPersonCount;
_GroupRoundedDuration = pDataContract.GroupRoundedDuration;
_GroupOid = pDataContract.GroupOid;
_ServiceRecordType = pDataContract.ServiceRecordType;
_DistanceInMeter = pDataContract.DistanceInMeter;
_DurationInStunden = pDataContract.DurationInStunden;
_ServiceRecordFormat = pDataContract.ServiceRecordFormat;
_SignatureOid = pDataContract.SignatureOid;
if (pDataContract.Goals != null)
{
_SelectedGoals = new ObservableSortCollection<ValueListEntryDC>(GoalService.CopyGoals(pDataContract.Goals, true), Comparer.ValueListEntryDCComparer);
}
SelectedGoals.CollectionChanged += (s, e) => StoreDirtyInformation(!SelectedGoals.ContainsSameItemsAs(pDataContract.Goals), PropertyName_SelectedGoals);
}
else
{
_Date = DateTime.Now.Date;
_EditableEndDate = DateTime.Now.Date;
_StartTime = NULL_TIME;
_Duration = null;
}
if (pDataContract.ServiceRecordType == ServiceRecordTypeId.Wohnheimbuchung)
{
_EditAllowed = _DeleteAllowed = false;
}
}
private bool SameRatingChecked(ObservableSortCollection<ValueListEntryDC> selectedGoals, List<ValueListEntryDC> goals)
{
if (goals != null)
{
foreach (var selectedGoal in selectedGoals)
{
foreach (var goalDc in goals)
{
if (selectedGoal.Equals(goalDc))
{
bool equalRating = true;
if (selectedGoal.Rating == null && goalDc.Rating == null)
{
equalRating = true;
}
else if (selectedGoal.Rating == null && goalDc.Rating != null)
{
equalRating = false;
}
else if (selectedGoal.Rating != null && goalDc.Rating == null)
{
equalRating = false;
}
else if (selectedGoal.Rating != null && goalDc.Rating != null &&
selectedGoal.Rating != goalDc.Rating)
{
equalRating = false;
}
if (!equalRating)
{
StoreDirtyInformation(true, "Rating");
return false;
}
}
}
}
}
StoreDirtyInformation(false, "Rating");
return true;
}
protected override ServiceRecordDC MapToDataContract(ServiceRecordDC pDataContract, bool doCommit)
{
return CopyToDataContract(pDataContract);
}
private ServiceRecordDC CopyToDataContract(ServiceRecordDC pDataContract)
{
var srf = ServiceRecordFormat;
if (BeWoApp.AppSettings.IsEndDateVisible && srf == null || ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitEndDatum)
{
var date = Date.Value;
DateTime time;
if (StartTime.HasValue)
time = StartTime.Value;
else
{
time = Date.Value;
if (time.Second == 0)
{
time = time.AddSeconds(1);
}
}
pDataContract.Start = new DateTime(date.Year, date.Month, date.Day, time.Hour, time.Minute, time.Second);
decimal endduration = 0;
//pDataContract.End = EditableEndDate;
if (_DurationSTD != null)
{
if (_DurationInStunden == ZeiterfassungsDauer.Stunden)
{
var dura = DurationSTD.Value * 60;
decimal roundedDuration = Math.Round(dura, MidpointRounding.AwayFromZero);
RoundedDuration = roundedDuration;
endduration = roundedDuration;
}
else
{
var dura = DurationSTD.Value;
decimal roundedDuration = Math.Round(dura, MidpointRounding.AwayFromZero);
RoundedDuration = roundedDuration;
endduration = roundedDuration;
}
}
pDataContract.End = pDataContract.Start.Value.AddMinutes((double)endduration);
_DurationMonthYearGes = 0;
_Duration = 0;
ServiceRecordFormat = ServiceRecordFormate.ZeiterfassungMitEndDatum;
}
else if (BeWoApp.AppSettings.IsOnlyYearMonthVisible && srf == null || ServiceRecordFormat == ServiceRecordFormate.ZeiterfassungMitMonatJahr)
{
var dates = DateTime.Parse("1." + OnlyMonth + OnlyYear);
var StartDatetime = new DateTime(dates.Year, dates.Month,1,0,0,1);
pDataContract.Start = StartDatetime;
pDataContract.End = StartDatetime.AddHours((double)DurationMonthYearGes);
if (_DurationMonthYearGes != 0)
{
var dura = DurationMonthYearGes.Value * 60;
decimal roundedDuration = Math.Round(dura, MidpointRounding.AwayFromZero);
RoundedDuration = roundedDuration;
}
Date = StartDatetime;
StartTime = StartDatetime;
_DurationSTD = 0;
_Duration = 0;
ServiceRecordFormat = ServiceRecordFormate.ZeiterfassungMitMonatJahr;
_DurationInStunden = ZeiterfassungsDauer.Stunden;
}
else
{
var date = Date.Value;
DateTime time;
if (StartTime.HasValue)
time = StartTime.Value;
else
{
time = Date.Value;
if (time.Second == 0)
{
time = time.AddSeconds(1);
}
}
pDataContract.Start = new DateTime(date.Year, date.Month, date.Day, time.Hour, time.Minute, time.Second);
decimal duration = 0;
if (Duration.HasValue)
{
duration = Duration.Value;
}
if (DurationInStunden == ZeiterfassungsDauer.Stunden)
{
var dura = duration * 60;
decimal roundedDuration = Math.Round(dura, MidpointRounding.AwayFromZero);
duration = roundedDuration;
}
else
{
var dura = duration;
decimal roundedDuration = Math.Round(dura, MidpointRounding.AwayFromZero);
duration = roundedDuration;
}
RoundedDuration = duration;
_DurationSTD = 0;
_DurationMonthYearGes = 0;
pDataContract.End = pDataContract.Start.Value.AddMinutes((double)duration);
ServiceRecordFormat = ServiceRecordFormate.OriginaleZeiterfassung;
}
pDataContract.Notice = _Notice;
pDataContract.Notice2 = _Notice2;
pDataContract.Notice3 = _Notice3;
pDataContract.Notice4 = _Notice4;
pDataContract.Notice5 = _Notice5;
pDataContract.RTFNotice1 = _RTFNotice;
pDataContract.RTFNotice2 = _RTFNotice2;
pDataContract.RTFNotice3 = _RTFNotice3;
pDataContract.RTFNotice4 = _RTFNotice4;
pDataContract.RTFNotice5 = _RTFNotice5;
pDataContract.ServiceRecordType = _ServiceRecordType;
pDataContract.DistanceInMeter = _DistanceInMeter;
pDataContract.DurationInStunden = _DurationInStunden;
pDataContract.ServiceRecordFormat = _ServiceRecordFormat;
pDataContract.Employee = _Employee;
pDataContract.Customer = _Customer;
pDataContract.SupportConcept = _SupportConcept;
pDataContract.CostBearer = _CostBearer;
pDataContract.RoundedDuration = RoundedDuration;
pDataContract.ServiceDescription = _ServiceDescription;
//Hack Story dirty information
SameRatingChecked(SelectedGoals, this.DataContract.Goals);
pDataContract.Goals = GetSelectedGoals();
#if DEBUG
if (pDataContract.Goals.Count == 0)
{
int test = 0;
}
#endif
pDataContract.GroupEmployeeCount = GroupEmployeeCount;
pDataContract.GroupPersonCount = GroupPersonCount;
pDataContract.GroupRoundedDuration = GroupRoundedDuration;
pDataContract.GroupOid = GroupOid;
return pDataContract;
}
private List<ValueListEntryDC> GetSelectedGoals()
{
var goals = new List<ValueListEntryDC>();
AddCheckedGoals(GoalTree, goals);
return goals;
}
private static void AddCheckedGoals(IEnumerable<SupportConceptGoalDC> goals, ICollection<ValueListEntryDC> selectedGoals)
{
foreach (var item in goals)
{
if (item.Children == null || item.Children.Count == 0)
{
if (item.IsChecked)
{
selectedGoals.Add(item.GoalEntryDC);
}
}
else
{
AddCheckedGoals(item.Children, selectedGoals);
}
}
}
private void TimeCheck()
{
decimal duration = 0;
if (BeWoApp.AppSettings.IsEndDateVisible)
{
if (_DurationSTD.HasValue)
{
duration = _DurationSTD.Value;
}
}
else
{
if (_Duration.HasValue)
{
duration = _Duration.Value;
}
}
StoreDirtyInformation(
AreDifferent(DataContract.End, (_Date.Value + _StartTime.Value.TimeOfDay).AddMinutes((double)duration)) ||
AreDifferent(DataContract.Start,_Date.Value + _StartTime.Value.TimeOfDay), "TIME");
if (_StartTime != null)
{
if (_DurationInStunden == ZeiterfassungsDauer.Minuten)
_EndTime = _StartTime.Value.AddMinutes((double) duration);
else
_EndTime = _StartTime.Value.AddHours((double) duration);
if (_EndTime.Value.Second > 1)
{
_EndTime = new DateTime(_EndTime.Value.Year, _EndTime.Value.Month, _EndTime.Value.Day,
_EndTime.Value.Hour, _EndTime.Value.Minute, 0);
}
FirePropertyChanged(PropertyName_EndTime);
}
}
private void TimeCheckMonatJahr()
{
//var duration = 0;
decimal duration = 0;
if (_DurationMonthYearGes.HasValue)
{
duration = _DurationMonthYearGes.Value;
}
var dates = DateTime.Parse("1." + _OnlyMonth + _OnlyYear);
var StartDatetime = new DateTime(dates.Year, dates.Month, 1, 0, 0, 1);
StoreDirtyInformation(
AreDifferent(DataContract.End, StartDatetime.AddHours((double)duration).AddSeconds(1)) ||
AreDifferent(DataContract.Start, StartDatetime), "TIME");
}
private void TimeCheckForDurationSTD()
{
double duration = 0;
if (_DurationSTD.HasValue) {
duration = (double)_DurationSTD.Value;
}
//####################### ich glaub das wars ##########################
if (_DurationInStunden == ZeiterfassungsDauer.Minuten)
{
if (_StartTime != null && _EndTime != null)
{
_StartTime = new DateTime(_Date.Value.Year, _Date.Value.Month, _Date.Value.Day,
_StartTime.Value.Hour, _StartTime.Value.Minute, _StartTime.Value.Second);
_EndTime = _StartTime.Value.AddMinutes(duration);
if (_EndTime.Value.Second > 1)
{
_EndTime = new DateTime(_EndTime.Value.Year, _EndTime.Value.Month, _EndTime.Value.Day, _EndTime.Value.Hour , _EndTime.Value.Minute, 0);
}
}
if (_StartTime == null && _EndTime != null && duration == 0)
{
_StartTime = new DateTime(_Date.Value.Year, _Date.Value.Month, _Date.Value.Day, _EndTime.Value.Hour, _EndTime.Value.Minute, _EndTime.Value.Second);
}
else if (_StartTime == null && _EndTime != null)
{
_StartTime = _EndTime.Value.AddMinutes(duration * -1);
}
if (_StartTime != null && _EndTime == null && duration == 0)
{
_EndTime = new DateTime(_EditableEndDate.Value.Year, _EditableEndDate.Value.Month, _EditableEndDate.Value.Day, _StartTime.Value.Hour, _StartTime.Value.Minute, _StartTime.Value.Second);
}
else if (_StartTime != null && _EndTime == null)
{
_StartTime = new DateTime(_Date.Value.Year, _Date.Value.Month, _Date.Value.Day,
_StartTime.Value.Hour, _StartTime.Value.Minute, _StartTime.Value.Second);
_EndTime = _StartTime.Value.AddMinutes(duration);
if (_EndTime.Value.Second > 1)
{
_EndTime = new DateTime(_EndTime.Value.Year, _EndTime.Value.Month, _EndTime.Value.Day, _EndTime.Value.Hour, _EndTime.Value.Minute, 0);
}
}
if (_StartTime == null && _EndTime == null && duration == 0)
{
_StartTime = new DateTime(_Date.Value.Year, _Date.Value.Month, _Date.Value.Day, 0, 0, 1);
_EndTime = new DateTime(_EditableEndDate.Value.Year, _EditableEndDate.Value.Month, _EditableEndDate.Value.Day, 0, 0, 1);
}
else if (_StartTime == null && _EndTime == null)
{
//start 1 sek und end duration + 1 sek
_StartTime = new DateTime(_Date.Value.Year, _Date.Value.Month, _Date.Value.Day, 0, 0, 1);
_EndTime = new DateTime(_EditableEndDate.Value.Year, _EditableEndDate.Value.Month, _EditableEndDate.Value.Day, 0, 0, 1);
_EndTime = _EndTime.Value.AddMinutes(duration);
}
_Date = new DateTime(_Date.Value.Year, _Date.Value.Month, _Date.Value.Day, _StartTime.Value.Hour, _StartTime.Value.Minute, _StartTime.Value.Second);
_EditableEndDate = new DateTime(_EndTime.Value.Year, _EndTime.Value.Month, _EndTime.Value.Day, _EndTime.Value.Hour, _EndTime.Value.Minute, _EndTime.Value.Second);
var diff = _EditableEndDate.Value.Subtract(_Date.Value);
duration = (double)diff.TotalMinutes;
_DurationSTD = (decimal)duration;
}
else if (_DurationInStunden == ZeiterfassungsDauer.Stunden)
{
if (_StartTime != null && _EndTime != null)
{
_StartTime = new DateTime(_Date.Value.Year, _Date.Value.Month, _Date.Value.Day,
_StartTime.Value.Hour, _StartTime.Value.Minute, _StartTime.Value.Second);
_EndTime = _StartTime.Value.AddHours(duration);
if (_EndTime.Value.Second > 1)
{
_EndTime = new DateTime(_EndTime.Value.Year, _EndTime.Value.Month, _EndTime.Value.Day, _EndTime.Value.Hour, _EndTime.Value.Minute, 0);
}
}
if (_StartTime == null && _EndTime != null && duration == 0)
{
_StartTime = new DateTime(_Date.Value.Year, _Date.Value.Month, _Date.Value.Day, _EndTime.Value.Hour, _EndTime.Value.Minute, _EndTime.Value.Second);
}
else if (_StartTime == null && _EndTime != null)
{
_StartTime = _EndTime.Value.AddHours(duration * -1);
}
if (_StartTime != null && _EndTime == null && duration == 0)
{
_EndTime = new DateTime(_EditableEndDate.Value.Year, _EditableEndDate.Value.Month, _EditableEndDate.Value.Day, _StartTime.Value.Hour, _StartTime.Value.Minute, _StartTime.Value.Second);
}
else if (_StartTime != null && _EndTime == null)
{
_StartTime = new DateTime(_Date.Value.Year, _Date.Value.Month, _Date.Value.Day,
_StartTime.Value.Hour, _StartTime.Value.Minute, _StartTime.Value.Second);
_EndTime = _StartTime.Value.AddHours(duration);
if (_EndTime.Value.Second > 1)
{
_EndTime = new DateTime(_EndTime.Value.Year, _EndTime.Value.Month, _EndTime.Value.Day, _EndTime.Value.Hour, _EndTime.Value.Minute, 0);
}
}
if (_StartTime == null && _EndTime == null && duration == 0)
{
_StartTime = new DateTime(_Date.Value.Year, _Date.Value.Month, _Date.Value.Day, 0, 0, 1);
_EndTime = new DateTime(_EditableEndDate.Value.Year, _EditableEndDate.Value.Month, _EditableEndDate.Value.Day, 0, 0, 1);
}
else if (_StartTime == null && _EndTime == null)
{
//start 1 sek und end duration + 1 sek
_StartTime = new DateTime(_Date.Value.Year, _Date.Value.Month, _Date.Value.Day, 0, 0, 1);
_EndTime = new DateTime(_EditableEndDate.Value.Year, _EditableEndDate.Value.Month, _EditableEndDate.Value.Day, 0, 0, 1);
_EndTime = _EndTime.Value.AddHours(duration);
}
_Date = new DateTime(_Date.Value.Year, _Date.Value.Month, _Date.Value.Day, _StartTime.Value.Hour, _StartTime.Value.Minute, _StartTime.Value.Second);
_EditableEndDate = new DateTime(_EndTime.Value.Year, _EndTime.Value.Month, _EndTime.Value.Day, _EndTime.Value.Hour, _EndTime.Value.Minute, _EndTime.Value.Second);
var diff = _EditableEndDate.Value.Subtract(_Date.Value);
duration = (double)diff.TotalHours;
_DurationSTD = (decimal)Math.Round(duration,2);
}
FirePropertyChanged(PropertyName_DurationSTD);
FirePropertyChanged(PropertyName_StartTime);
FirePropertyChanged(PropertyName_EndTime);
FirePropertyChanged(PropertyName_Date);
FirePropertyChanged(PropertyName_EditableEndDate);
}
#endregion
}
}