2016-06-27 01:45:38 +02:00
using System ;
using System.Collections.Generic ;
2017-04-03 13:39:11 +02:00
using System.Drawing ;
2016-06-27 01:45:38 +02:00
using System.Globalization ;
using System.Linq ;
using System.Windows ;
using System.Windows.Media ;
2017-04-03 13:39:11 +02:00
using System.Windows.Media.Imaging ;
2016-06-27 01:45:38 +02:00
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 ;
2017-04-03 13:39:11 +02:00
using Brush = System . Windows . Media . Brush ;
using Brushes = System . Windows . Media . Brushes ;
using Color = System . Windows . Media . Color ;
2016-06-27 01:45:38 +02:00
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" ;
2017-07-27 09:58:04 +02:00
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" ;
2016-06-27 01:45:38 +02:00
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" ;
2017-01-11 11:02:58 +01:00
public static string PropertyName_DurationInStunden = "DurationInStunden" ;
2017-01-19 17:02:07 +01:00
public static string PropertyName_ServiceRecordFormat = "ServiceRecordFormat" ;
2017-01-16 16:13:19 +01:00
public static string PropertyName_OnlyMonth = "OnlyMonth" ;
2017-01-19 17:02:07 +01:00
public static string PropertyName_OnlyYear = "OnlyYear" ;
2017-01-11 11:02:58 +01:00
public static string PropertyName_DurationSTD = "DurationSTD" ;
public static string PropertyName_EndDate = "EndDate" ;
2017-01-24 13:43:59 +01:00
public static string PropertyName_DurationMonthYearGes = "DurationMonthYearGes" ;
2016-06-27 01:45:38 +02:00
private static readonly DateTime NULL_TIME = new DateTime ( 2000 , 1 , 1 , 0 , 0 , 1 ) ;
2017-04-03 13:39:11 +02:00
private static BitmapImage unterschriftVorhanden = null ;
2016-06-27 01:45:38 +02:00
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 ;
2017-01-11 11:02:58 +01:00
private DateTime ? _EndDate ;
2016-06-27 01:45:38 +02:00
private bool _DeleteAllowed = true ;
2017-03-15 15:16:06 +01:00
private decimal? _Duration ;
2016-06-27 01:45:38 +02:00
2017-02-21 11:05:27 +01:00
private decimal? _DurationSTD ;
2017-01-11 11:02:58 +01:00
2016-06-27 01:45:38 +02:00
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 ;
2017-07-27 09:58:04 +02:00
private string _RTFNotice ;
private string _RTFNotice2 ;
private string _RTFNotice3 ;
private string _RTFNotice4 ;
private string _RTFNotice5 ;
2016-06-27 01:45:38 +02:00
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 ;
2017-01-11 11:02:58 +01:00
private ZeiterfassungsDauer ? _DurationInStunden ;
2017-01-16 16:13:19 +01:00
2017-01-19 17:02:07 +01:00
private ServiceRecordFormate ? _ServiceRecordFormat ;
2017-01-16 16:13:19 +01:00
private string _OnlyMonth ;
2017-01-19 17:02:07 +01:00
private string _OnlyYear ;
2017-02-21 11:05:27 +01:00
private decimal? _DurationMonthYearGes ;
2017-01-24 13:43:59 +01:00
2017-02-09 10:05:55 +01:00
private bool _isUnterschrift ;
2017-03-15 15:16:06 +01:00
private string _IsFloatGesetzt = "False" ;
2017-01-19 17:02:07 +01:00
private string [ ] _MonateBinden = { "Januar" , "Februar" , "März" , "April" , "Mai" , "Juni" , "Juli" , "August" , "September" , "Oktober" , "November" , "Dezember" } ;
2017-01-11 11:02:58 +01:00
2016-06-27 01:45:38 +02:00
#endregion
#region Constructors and Destructors
public ServiceRecordVM ( )
{
DataContract = new ServiceRecordDC { Notice = "" } ;
2017-06-11 15:50:31 +02:00
if ( _DurationSTD = = null )
_DurationSTD = 0 ;
if ( _Duration = = null )
_Duration = 0 ;
2016-06-27 01:45:38 +02:00
}
public ServiceRecordVM (
ServiceRecordDC pDC ,
Dictionary < ServiceCategoryDC , List < ServiceDescriptionDC > > pCategory2Services ,
List < ValueListEntryDC > pAllGoalCategories ,
List < ValueListEntryDC > pAllGoals )
: base ( pDC , pDC . ServiceRecordOid = = null )
{
2017-06-11 15:50:31 +02:00
//_DurationInStunden = BeWoApp.AppSettings.LetzteZeiterfassungsDauer;
2016-06-27 01:45:38 +02:00
_Category2Services = pCategory2Services ;
ChangeGoalTree ( pAllGoalCategories , pAllGoals ) ;
2017-06-11 15:50:31 +02:00
if ( _DurationSTD = = null )
_DurationSTD = 0 ;
if ( _Duration = = null )
_Duration = 0 ;
2016-06-27 01:45:38 +02:00
}
#endregion
#region Properties
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 ;
2017-01-11 11:02:58 +01:00
2017-03-27 11:05:32 +02:00
if ( BeWoApp . AppSettings . IsEndDateVisible & & ServiceRecordFormat = = null | | ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitEndDatum )
2017-01-11 11:02:58 +01:00
{
2017-01-24 13:43:59 +01:00
var x = _EditableEndDate . Value . Subtract ( _Date . Value ) ;
if ( _DurationInStunden = = ZeiterfassungsDauer . Minuten )
2017-01-11 11:02:58 +01:00
{
2017-03-15 15:16:06 +01:00
_DurationSTD = ( decimal ) x . TotalMinutes ;
2017-01-24 13:43:59 +01:00
} else {
2017-03-15 15:16:06 +01:00
_DurationSTD = ( decimal ) x . TotalHours ;
2017-01-24 13:43:59 +01:00
}
2017-01-11 11:02:58 +01:00
2017-01-24 13:43:59 +01:00
FirePropertyChanged ( PropertyName_DurationSTD ) ;
TimeCheckForDurationSTD ( ) ;
}
else
2017-01-31 07:15:00 +01:00
{
TimeCheck ( ) ;
2017-01-24 13:43:59 +01:00
}
2017-01-11 11:02:58 +01:00
2017-02-01 09:24:33 +01:00
FirePropertyChanged ( PropertyName_Date ) ;
2016-06-27 01:45:38 +02:00
}
}
}
public DateTime ? DateAndTime
{
get
{
var date = _Date ;
var time = _StartTime ;
2017-03-15 15:16:06 +01:00
2017-02-14 13:55:40 +01:00
// 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
2017-03-08 13:05:45 +01:00
if ( date ! = null & & time ! = null )
{
if ( date . Value . Second ! = time . Value . Second )
date = date . Value . AddSeconds ( time . Value . Second ) ;
2016-06-27 01:45:38 +02:00
2017-03-15 15:38:21 +01:00
time = new DateTime ( date . Value . Year , date . Value . Month , date . Value . Day , time . Value . Hour , time . Value . Minute , time . Value . Second ) ;
}
2017-03-09 08:55:05 +01:00
return time ; // date
2016-06-27 01:45:38 +02:00
}
}
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
{
2017-01-11 11:02:58 +01:00
if ( _EndDate = = null ) {
2016-06-27 01:45:38 +02:00
var dt = DateAndTime ;
if ( dt . HasValue )
{
if ( _StartTime ! = null )
{
var timeDt = _StartTime . Value ;
2017-03-09 11:32:48 +01:00
if ( _DurationInStunden = = ZeiterfassungsDauer . Minuten )
2016-06-27 01:45:38 +02:00
{
2017-03-09 11:32:48 +01:00
if ( GroupOid ! = null & & GroupRoundedDuration ! = null )
{
dt = timeDt . AddMinutes ( ( double ) GroupRoundedDuration ) ;
}
else
{
2017-03-15 15:16:06 +01:00
2017-03-09 11:32:48 +01:00
dt = timeDt . AddMinutes ( ( double ) RoundedDuration ) ;
}
}
2016-06-27 01:45:38 +02:00
else
{
2017-03-15 15:16:06 +01:00
2017-03-09 11:32:48 +01:00
if ( GroupOid ! = null & & GroupRoundedDuration ! = null )
{
2017-03-15 15:16:06 +01:00
var x = GroupRoundedDuration / 60 ;
dt = timeDt . AddHours ( ( double ) x /*(double)GroupRoundedDuration*/ ) ;
2017-03-09 11:32:48 +01:00
}
else
{
2017-03-15 15:16:06 +01:00
var x = RoundedDuration / 60 ;
dt = timeDt . AddHours ( ( double ) x /*(double)RoundedDuration*/ ) ;
2017-03-09 11:32:48 +01:00
}
}
2016-06-27 01:45:38 +02:00
}
}
return dt ;
2017-01-11 11:02:58 +01:00
}
else
{
return _EndDate ;
}
}
set
{
if ( AreDifferent ( _EndDate , value ) )
{
_EndDate = value ;
FirePropertyChanged ( PropertyName_EndDate ) ;
}
2016-06-27 01:45:38 +02:00
}
}
public String Id
{
get { return String . Format ( "{0}" , DataContract . ServiceRecordOid ) ; }
}
2017-01-11 11:02:58 +01:00
[Validation(ValidationRule = ValidationRules.GreaterThanOrEqualZero)]
2017-03-15 15:16:06 +01:00
public decimal? Duration
2016-06-27 01:45:38 +02:00
{
2017-01-11 11:02:58 +01:00
get
{
2017-01-31 07:15:00 +01:00
if ( _Duration = = null )
2017-01-11 11:02:58 +01:00
{
2017-01-24 13:43:59 +01:00
return 0 ;
} else {
return _Duration ;
2017-01-11 11:02:58 +01:00
}
2017-01-24 13:43:59 +01:00
}
2017-01-11 11:02:58 +01:00
2017-01-24 13:43:59 +01:00
set
{
if ( AreDifferent ( _Duration , value ) )
2017-01-11 11:02:58 +01:00
{
2017-01-16 16:13:19 +01:00
_Duration = value ;
2017-01-31 07:15:00 +01:00
2016-06-27 01:45:38 +02:00
TimeCheck ( ) ;
2017-01-31 07:15:00 +01:00
2017-01-24 13:43:59 +01:00
FirePropertyChanged ( PropertyName_Duration ) ;
2016-06-27 01:45:38 +02:00
FirePropertyChanged ( PropertyName_RoundedDuration ) ;
2017-01-31 07:15:00 +01:00
}
2016-06-27 01:45:38 +02:00
}
}
2017-01-11 11:02:58 +01:00
2016-06-27 01:45:38 +02:00
public string DurationAndRoundedDuration
{
get
{
var rd = BeWoWpfUtils . GetDecimalValueWithMaxDecimal ( RoundedDuration , 2 ) ;
if ( Category ! = null & & Category . Percentage > 0 & & Category . Percentage < 100 )
{
rd = ( rd * Category . Percentage ) / 100 ;
}
2017-02-02 13:52:49 +01:00
2017-02-01 09:24:33 +01:00
if ( _ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitEndDatum ) {
var strResult = _GroupOid ! = null ? String . Format ( "{0} ({0})" , rd ) : String . Format ( "{0} ({1})" , DurationSTD , rd ) ;
return strResult ;
} else if ( _ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitMonatJahr )
2017-01-31 07:15:00 +01:00
{
2017-02-01 09:24:33 +01:00
var strResult = _GroupOid ! = null ? String . Format ( "{0} ({0})" , rd ) : String . Format ( "{0} ({1})" , DurationMonthYearGes , rd ) ;
2017-01-31 07:15:00 +01:00
2017-02-01 09:24:33 +01:00
return strResult ;
2017-01-31 07:15:00 +01:00
2017-02-01 09:24:33 +01:00
}
else
{
2017-06-11 15:50:31 +02:00
if ( DurationInStunden . HasValue & & DurationInStunden . Value = = ZeiterfassungsDauer . Stunden )
{
return _GroupOid ! = null ? String . Format ( "{0} ({0})" , rd ) : String . Format ( "{0:0.##} ({1:0.##})" , DurationSTD , rd / 60 ) ;
}
2016-06-27 01:45:38 +02:00
2017-06-11 15:50:31 +02:00
return _GroupOid ! = null ? String . Format ( "{0} ({0})" , rd ) : String . Format ( "{0} ({1})" , Duration , rd ) ;
2017-02-01 09:24:33 +01:00
}
2017-01-31 07:15:00 +01:00
2017-02-01 09:24:33 +01:00
2016-06-27 01:45:38 +02:00
}
}
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 ;
}
}
}
2017-03-22 13:38:09 +01:00
}
2016-06-27 01:45:38 +02:00
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
2017-03-27 11:05:32 +02:00
{
2016-06-27 01:45:38 +02:00
if ( _EndTime = = null | | _EndTime . Value . Second ! = 0 )
{
return null ;
}
return String . Format ( "{0:HH:mm}" , _EndTime ) ;
}
set
{
if ( String . IsNullOrEmpty ( value ) )
EndTime = null ;
else
{
2017-03-27 11:05:32 +02:00
if ( BeWoApp . AppSettings . IsEndDateVisible & & ServiceRecordFormat = = null | | ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitEndDatum )
2016-06-27 01:45:38 +02:00
{
DateTime ? endTime = EditableEndDate ;
String dtStr = String . Format ( "{0:dd.MM.yyyy} {1}" , endTime , value ) ;
DateTime dt ;
2017-01-24 13:43:59 +01:00
2016-06-27 01:45:38 +02:00
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 ;
2017-01-24 13:43:59 +01:00
2016-06-27 01:45:38 +02:00
if ( DateTime . TryParse ( dtStr , out dt ) )
EndTime = dt ;
else
EndTime = null ;
}
}
}
}
public DateTime ? EditableEndDate
{
get {
2017-03-27 11:05:32 +02:00
if ( BeWoApp . AppSettings . IsEndDateVisible & & ServiceRecordFormat = = null | | ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitEndDatum )
2016-06-27 01:45:38 +02:00
{
2017-03-27 11:05:32 +02:00
//var x = new DateTime(_EditableEndDate.Value.Year, _EditableEndDate.Value.Month, _EditableEndDate.Value.Day, _EditableEndDate.Value.Hour, _EditableEndDate.Value.Minute,0);
return _EditableEndDate ;
// return x;
2017-01-24 13:43:59 +01:00
} else {
return null ;
2016-06-27 01:45:38 +02:00
}
}
set
{
2017-02-02 13:52:49 +01:00
2017-03-27 11:05:32 +02:00
if ( BeWoApp . AppSettings . IsEndDateVisible & & ServiceRecordFormat = = null | | ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitEndDatum )
2017-02-02 13:52:49 +01:00
{
2017-01-24 13:43:59 +01:00
if ( AreDifferent ( _EditableEndDate , value ) )
2017-02-02 13:52:49 +01:00
{
2017-01-24 13:43:59 +01:00
if ( value < Date )
{
2017-02-02 13:52:49 +01:00
_EditableEndDate = Date ;
2017-01-24 13:43:59 +01:00
}
else
{
_EditableEndDate = value ;
}
2017-01-11 11:02:58 +01:00
2017-01-24 13:43:59 +01:00
var x = _EditableEndDate . Value . Subtract ( _Date . Value ) ;
if ( _DurationInStunden = = ZeiterfassungsDauer . Minuten )
{
2017-03-15 15:16:06 +01:00
_DurationSTD = ( decimal ) x . TotalMinutes ;
2017-01-24 13:43:59 +01:00
}
else
{
2017-03-15 15:16:06 +01:00
_DurationSTD = ( decimal ) x . TotalHours ;
2017-01-24 13:43:59 +01:00
}
2017-03-27 11:05:32 +02:00
TimeCheckForDurationSTD ( ) ;
2017-01-24 13:43:59 +01:00
FirePropertyChanged ( PropertyName_EditableEndDate ) ;
FirePropertyChanged ( PropertyName_DurationSTD ) ;
2017-03-27 11:05:32 +02:00
2017-02-01 09:24:33 +01:00
}
2016-06-27 01:45:38 +02:00
}
}
}
public DateTime ? EndTime
{
get {
2017-03-27 11:05:32 +02:00
if ( BeWoApp . AppSettings . IsEndDateVisible & & ServiceRecordFormat = = null | | ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitEndDatum )
2016-06-27 01:45:38 +02:00
{
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 )
{
2017-03-27 11:05:32 +02:00
if ( BeWoApp . AppSettings . IsEndDateVisible & & ServiceRecordFormat = = null | | ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitEndDatum )
2016-06-27 01:45:38 +02:00
{
2017-03-14 12:48:31 +01:00
//if (_StartTime.Value.Date == null)
//{
// StartTime = new DateTime(StartTime.Value.Year, StartTime.Value.Month, StartTime.Value.Day, StartTime.Value.Hour, 0, 0);
//}
_StartTime = new DateTime ( Date . Value . Year , Date . Value . Month , Date . Value . Day , StartTime . Value . Hour , StartTime . Value . Minute , StartTime . Value . Second ) ;
var diff = _EndTime . Value . Subtract ( _StartTime . Value ) ;
2016-06-27 01:45:38 +02:00
2017-01-24 13:43:59 +01:00
if ( _DurationInStunden = = ZeiterfassungsDauer . Stunden )
2017-01-11 11:02:58 +01:00
{
2017-03-15 15:16:06 +01:00
_DurationSTD = ( decimal ) diff . TotalHours ;
2017-01-11 11:02:58 +01:00
}
else
{
2017-03-15 15:16:06 +01:00
_DurationSTD = ( decimal ) diff . TotalMinutes ;
2017-01-11 11:02:58 +01:00
}
2017-01-24 13:43:59 +01:00
TimeCheckForDurationSTD ( ) ;
FirePropertyChanged ( PropertyName_DurationSTD ) ;
2016-06-27 01:45:38 +02:00
}
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 ) ;
2017-03-09 11:32:48 +01:00
if ( start . TimeOfDay > _EndTime . Value . TimeOfDay )
{
_EndTime = _EndTime . Value . AddDays ( 1 ) ;
}
var diff = _EndTime . Value . Subtract ( start ) ;
2016-06-27 01:45:38 +02:00
2017-01-11 11:02:58 +01:00
2017-01-16 16:13:19 +01:00
if ( _DurationInStunden = = ZeiterfassungsDauer . Stunden )
2017-03-09 11:32:48 +01:00
{
2017-03-15 15:16:06 +01:00
_Duration = ( decimal ) diff . TotalHours ;
2017-01-16 16:13:19 +01:00
}
else
2017-03-09 11:32:48 +01:00
{
2017-03-15 15:16:06 +01:00
_Duration = ( decimal ) diff . TotalMinutes ;
2017-01-16 16:13:19 +01:00
}
2017-01-11 11:02:58 +01:00
2017-01-24 13:43:59 +01:00
TimeCheck ( ) ;
FirePropertyChanged ( PropertyName_Duration ) ;
2016-06-27 01:45:38 +02:00
}
}
2017-01-24 13:43:59 +01:00
2016-06-27 01:45:38 +02:00
FirePropertyChanged ( PropertyName_EndTime ) ;
}
2017-01-31 07:15:00 +01:00
2016-06-27 01:45:38 +02:00
}
}
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 ; }
}
2017-04-03 13:39:11 +02:00
public ImageSource IsUnterschrift
2017-02-09 10:05:55 +01:00
{
get
{
if ( _SignatureOid ! = null ) {
2017-04-03 13:39:11 +02:00
if ( unterschriftVorhanden = = null )
{
unterschriftVorhanden = CreateImage ( "../../Ressources/Icons/Haeckchen.png" ) ;
}
return unterschriftVorhanden ;
2017-02-09 10:05:55 +01:00
}
else
{
2017-04-03 13:39:11 +02:00
return null ;
2017-02-09 10:05:55 +01:00
}
}
2017-02-14 13:55:40 +01:00
//set { _isUnterschrift = value; }
2017-02-09 10:05:55 +01:00
}
2017-04-03 13:39:11 +02:00
private BitmapImage CreateImage ( String path )
{
BitmapImage bix = new BitmapImage ( ) ;
bix . BeginInit ( ) ;
bix . CreateOptions = BitmapCreateOptions . PreservePixelFormat ;
bix . CacheOption = BitmapCacheOption . OnLoad ;
bix . UriSource = new Uri ( path , UriKind . Relative ) ;
bix . EndInit ( ) ;
return bix ;
}
2016-06-27 01:45:38 +02:00
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 bool IsGoalTreeVisible
{
get { return _GoalTree ! = null & & _GoalTree . Count > 0 ; }
}
public string LongDateString
{
get
{
var date = string . Empty ;
2017-02-01 09:24:33 +01:00
2016-06-27 01:45:38 +02:00
string time = string . Empty ;
2017-01-26 09:56:57 +01:00
string endtime = string . Empty ;
2016-06-27 01:45:38 +02:00
if ( _StartTime ! = null )
{
var timeDt = _StartTime . Value ;
if ( timeDt . Second = = 0 )
{
time = timeDt . ToShortTimeString ( ) ;
2017-03-09 12:39:57 +01:00
if ( _DurationInStunden = = ZeiterfassungsDauer . Stunden )
2016-06-27 01:45:38 +02:00
{
2017-03-09 12:39:57 +01:00
if ( GroupOid ! = null & & GroupRoundedDuration ! = null )
{
2017-06-11 15:50:31 +02:00
timeDt = timeDt . AddMinutes ( ( double ) GroupRoundedDuration ) ;
2017-03-09 12:39:57 +01:00
}
else
{
2017-06-11 15:50:31 +02:00
timeDt = timeDt . AddMinutes ( ( double ) RoundedDuration ) ;
2017-03-09 12:39:57 +01:00
}
2016-06-27 01:45:38 +02:00
}
else
{
2017-03-09 12:39:57 +01:00
if ( GroupOid ! = null & & GroupRoundedDuration ! = null )
{
timeDt = timeDt . AddMinutes ( ( double ) GroupRoundedDuration ) ;
}
else
{
timeDt = timeDt . AddMinutes ( ( double ) RoundedDuration ) ;
}
2016-06-27 01:45:38 +02:00
}
2017-03-09 12:39:57 +01:00
2017-01-26 09:56:57 +01:00
endtime = timeDt . ToShortTimeString ( ) ;
//time = time + " - " + timeDt.ToShortTimeString();
}
}
if ( _Date ! = null )
{
2017-02-01 09:24:33 +01:00
if ( endtime . Equals ( "" ) & & time . Equals ( "" ) )
2017-01-26 09:56:57 +01:00
{
2017-02-01 09:24:33 +01:00
date = DateTimeFormatInfo . CurrentInfo . GetAbbreviatedDayName ( _Date . Value . DayOfWeek ) + ", " + _Date . Value . ToShortDateString ( ) ;
2016-06-27 01:45:38 +02:00
}
2017-03-08 13:05:45 +01:00
else {
if ( _EditableEndDate . HasValue ) {
if ( _EditableEndDate . Value . Date ! = _Date . Value . Date )
{
2017-03-15 15:16:06 +01:00
time = StartTime . Value . TimeOfDay . ToString ( ) ;
endtime = _EditableEndDate . Value . TimeOfDay . ToString ( ) ;
2017-03-08 13:05:45 +01:00
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 ;
}
2017-02-01 09:24:33 +01:00
}
else
{
time = time + " - " + endtime ;
date = DateTimeFormatInfo . CurrentInfo . GetAbbreviatedDayName ( _Date . Value . DayOfWeek ) + ", " + _Date . Value . ToShortDateString ( ) + " " + time ;
}
2017-01-26 09:56:57 +01:00
}
2017-02-01 09:24:33 +01:00
}
2016-06-27 01:45:38 +02:00
2017-01-26 09:56:57 +01:00
//date += " " + time;
2016-06-27 01:45:38 +02:00
if ( GroupOid ! = null & & GroupPersonCount ! = null & & GroupRoundedDuration ! = null )
{
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 ) ;
}
}
}
2017-07-27 09:58:04 +02:00
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 ) ;
}
}
}
2016-06-27 01:45:38 +02:00
public List < ServiceDescriptionDC > PossibleServiceDescriptions
{
get
{
if ( _Category = = null )
{
return null ;
}
return _Category2Services . ContainsKey ( _Category ) ? _Category2Services [ _Category ] : null ;
}
}
2017-03-08 13:05:45 +01:00
public decimal RoundedDurationAnzeige
{
get
{
2017-06-11 15:50:31 +02:00
if ( _ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitMonatJahr | | ( DurationInStunden . HasValue & & DurationInStunden . Value = = ZeiterfassungsDauer . Stunden ) )
2017-03-08 13:05:45 +01:00
{
return _RoundedDuration / 60 ;
}
else
{
return _RoundedDuration ;
}
}
}
2016-06-27 01:45:38 +02:00
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 + = goal . TypeDescription ;
}
return goals ;
}
}
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
{
2017-01-24 13:43:59 +01:00
if ( _StartTime ! = null )
return _StartTime . Value . Second ! = 0 ? null : _StartTime ;
else
{
return new DateTime ( ) ;
}
2016-06-27 01:45:38 +02:00
}
set
2017-01-24 13:43:59 +01:00
{
2016-06-27 01:45:38 +02:00
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 )
{
var end = new DateTime ( _StartTime . Value . Year , _StartTime . Value . Month , _StartTime . Value . Day ,
_EndTime . Value . Hour , _EndTime . Value . Minute , 0 ) ;
var diff = end . Subtract ( _StartTime . Value ) ;
if ( diff . TotalSeconds < 0 )
{
EndTime = _StartTime ;
end = EndTime . Value ;
}
diff = end . Subtract ( _StartTime . Value ) ;
2017-01-11 11:02:58 +01:00
2017-01-24 13:43:59 +01:00
2017-03-28 10:51:31 +02:00
if ( BeWoApp . AppSettings . IsEndDateVisible & & ServiceRecordFormat = = null | | ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitEndDatum )
2017-01-16 16:13:19 +01:00
{
2017-01-24 13:43:59 +01:00
var x = _EditableEndDate . Value . Subtract ( _StartTime . Value ) ;
2017-01-16 16:13:19 +01:00
if ( _DurationInStunden = = ZeiterfassungsDauer . Stunden )
2017-01-24 13:43:59 +01:00
{
2017-03-15 15:16:06 +01:00
DurationSTD = ( decimal ) x . TotalHours ;
2017-01-24 13:43:59 +01:00
}
else
2017-01-16 16:13:19 +01:00
{
2017-03-15 15:16:06 +01:00
DurationSTD = ( decimal ) x . TotalMinutes ;
2017-01-24 13:43:59 +01:00
}
2017-01-11 11:02:58 +01:00
2017-01-24 13:43:59 +01:00
FirePropertyChanged ( PropertyName_DurationSTD ) ;
TimeCheckForDurationSTD ( ) ;
2017-01-16 16:13:19 +01:00
2017-01-24 13:43:59 +01:00
}
else
{
if ( _DurationInStunden = = ZeiterfassungsDauer . Stunden )
{
2017-03-15 15:16:06 +01:00
Duration = ( decimal ) diff . TotalHours ;
2017-01-16 16:13:19 +01:00
}
else
{
2017-03-15 15:16:06 +01:00
Duration = ( decimal ) diff . TotalMinutes ;
2017-01-24 13:43:59 +01:00
}
2017-02-09 13:51:26 +01:00
FirePropertyChanged ( PropertyName_Duration ) ;
2017-01-24 13:43:59 +01:00
TimeCheck ( ) ;
2017-01-16 16:13:19 +01:00
}
2016-06-27 01:45:38 +02:00
}
2017-02-09 13:51:26 +01:00
//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);
// }
// }
//}
2016-06-27 01:45:38 +02:00
}
FirePropertyChanged ( PropertyName_StartTime ) ;
}
}
}
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 ; }
2017-01-11 11:02:58 +01:00
}
public ZeiterfassungsDauer ? DurationInStunden
{
get
{
if ( _DurationInStunden = = null )
{
_DurationInStunden = ZeiterfassungsDauer . Minuten ;
return _DurationInStunden ;
}
else
{
return _DurationInStunden ;
}
}
set
{
2017-02-01 09:24:33 +01:00
2017-01-16 16:13:19 +01:00
if ( value = = ZeiterfassungsDauer . Minuten & & _DurationInStunden = = ZeiterfassungsDauer . Stunden )
2017-01-11 11:02:58 +01:00
{
2017-03-27 11:05:32 +02:00
if ( BeWoApp . AppSettings . IsZeiterfassDateNormal & & ServiceRecordFormat = = null | | ServiceRecordFormat = = ServiceRecordFormate . OriginaleZeiterfassung )
2017-03-15 15:16:06 +01:00
{
if ( _Duration . HasValue )
{
var x = _Duration . Value * 60 ;
2017-03-27 11:05:32 +02:00
_Duration = x ; //Math.Round(x,2);
2017-03-15 15:16:06 +01:00
}
}
2017-01-16 16:13:19 +01:00
2017-03-27 11:05:32 +02:00
if ( BeWoApp . AppSettings . IsEndDateVisible & & ServiceRecordFormat = = null | | ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitEndDatum )
2017-03-15 15:16:06 +01:00
{
if ( _DurationSTD . HasValue )
{
var x = _DurationSTD . Value * 60 ;
2017-03-27 11:05:32 +02:00
_DurationSTD = x ; //Math.Round(x, 2);
2017-03-15 15:16:06 +01:00
}
}
2017-01-11 11:02:58 +01:00
}
2017-01-16 16:13:19 +01:00
else if ( value = = ZeiterfassungsDauer . Stunden & & _DurationInStunden = = ZeiterfassungsDauer . Minuten )
2017-01-11 11:02:58 +01:00
{
2017-01-16 16:13:19 +01:00
2017-03-27 11:05:32 +02:00
if ( BeWoApp . AppSettings . IsZeiterfassDateNormal & & ServiceRecordFormat = = null | | ServiceRecordFormat = = ServiceRecordFormate . OriginaleZeiterfassung )
2017-03-15 15:16:06 +01:00
{
if ( _Duration . HasValue )
{
var x = _Duration . Value / 60 ;
2017-03-27 11:05:32 +02:00
_Duration = x ; // Math.Round(x, 2);
2017-03-15 15:16:06 +01:00
}
}
2017-01-16 16:13:19 +01:00
2017-03-27 11:05:32 +02:00
if ( BeWoApp . AppSettings . IsEndDateVisible & & ServiceRecordFormat = = null | | ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitEndDatum )
2017-03-15 15:16:06 +01:00
{
if ( _DurationSTD . HasValue )
{
var x = _DurationSTD . Value / 60 ;
2017-03-27 11:05:32 +02:00
_DurationSTD = x ; /* Math.Round(x, 2);*/
2017-03-15 15:16:06 +01:00
}
}
2017-01-11 11:02:58 +01:00
}
if ( AreDifferent ( _DurationInStunden , value ) )
{
_DurationInStunden = value ;
StoreDirtyInformation ( AreDifferent ( DataContract . DurationInStunden , value ) , PropertyName_DurationInStunden ) ;
2017-01-16 16:13:19 +01:00
2017-01-24 13:43:59 +01:00
FirePropertyChanged ( PropertyName_DurationInStunden ) ;
2017-03-27 11:05:32 +02:00
if ( BeWoApp . AppSettings . IsEndDateVisible & & ServiceRecordFormat = = null | | ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitEndDatum )
{
2017-01-24 13:43:59 +01:00
TimeCheckForDurationSTD ( ) ;
2017-03-27 11:05:32 +02:00
FirePropertyChanged ( PropertyName_DurationSTD ) ;
2017-03-28 10:51:31 +02:00
} else
if ( BeWoApp . AppSettings . IsZeiterfassDateNormal & & ServiceRecordFormat = = null | | ServiceRecordFormat = = ServiceRecordFormate . OriginaleZeiterfassung )
{
TimeCheck ( ) ;
FirePropertyChanged ( PropertyName_Duration ) ;
2017-03-27 11:05:32 +02:00
2017-03-28 10:51:31 +02:00
}
2017-01-11 11:02:58 +01:00
}
}
}
2017-01-19 17:02:07 +01:00
public ServiceRecordFormate ? ServiceRecordFormat
{
get { return _ServiceRecordFormat ; }
set
{
if ( AreDifferent ( _ServiceRecordFormat , value ) )
{
_ServiceRecordFormat = value ;
StoreDirtyInformation ( AreDifferent ( DataContract . ServiceRecordFormat , value ) , PropertyName_ServiceRecordFormat ) ;
FirePropertyChanged ( PropertyName_ServiceRecordFormat ) ;
}
}
}
2017-01-24 13:43:59 +01:00
2017-01-16 16:13:19 +01:00
public string OnlyMonth
{
2017-01-19 17:02:07 +01:00
get
{
if ( _OnlyMonth . IsNullOrEmpty ( ) )
{
_OnlyMonth = DateTime . Now . ToString ( "MMMM" ) ;
}
return _OnlyMonth ;
}
2017-01-16 16:13:19 +01:00
set
{
if ( AreDifferent ( _OnlyMonth , value ) )
{
_OnlyMonth = value ;
FirePropertyChanged ( PropertyName_OnlyMonth ) ;
}
}
}
2017-01-19 17:02:07 +01:00
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 ( ) ; }
}
2017-01-24 13:43:59 +01:00
2017-01-19 17:02:07 +01:00
public string OnlyYear
{
get
{
if ( _OnlyYear . IsNullOrEmpty ( ) )
{
_OnlyYear = DateTime . Now . Year . ToString ( ) ;
}
return _OnlyYear ;
}
set
{
if ( AreDifferent ( _OnlyYear , value ) )
{
_OnlyYear = value ;
2017-01-24 13:43:59 +01:00
2017-01-19 17:02:07 +01:00
FirePropertyChanged ( PropertyName_OnlyYear ) ;
}
}
}
2017-02-02 13:52:49 +01:00
2017-01-11 11:02:58 +01:00
[Validation(ValidationRule = ValidationRules.GreaterThanOrEqualZero)]
2017-02-21 11:05:27 +01:00
public decimal? DurationSTD
2017-01-11 11:02:58 +01:00
{
get
{
2017-01-31 07:15:00 +01:00
if ( _DurationSTD = = null )
2017-01-24 13:43:59 +01:00
{
return 0 ;
} else {
return _DurationSTD ;
}
2016-06-27 01:45:38 +02:00
}
2017-01-11 11:02:58 +01:00
set
{
2017-06-11 15:50:31 +02:00
//if (BeWoApp.AppSettings.IsZeiterfassungInStdMin)
//{
2017-05-18 21:47:09 +02:00
if ( AreDifferent ( _DurationSTD , value ) )
{
_DurationSTD = value ;
2017-01-11 11:02:58 +01:00
2017-05-18 21:47:09 +02:00
StoreDirtyInformation ( AreDifferent ( DataContract . RoundedDuration , value ) ,
PropertyName_DurationSTD ) ;
2017-01-31 07:15:00 +01:00
2017-05-18 21:47:09 +02:00
FirePropertyChanged ( PropertyName_DurationSTD ) ;
FirePropertyChanged ( PropertyName_RoundedDuration ) ;
TimeCheckForDurationSTD ( ) ;
}
2017-06-11 15:50:31 +02:00
//}
//else if (BeWoApp.AppSettings.IsEndDateVisible)
//{
// Duration = val
//}
2017-01-24 13:43:59 +01:00
}
}
[Validation(ValidationRule = ValidationRules.GreaterThanOrEqualZero)]
2017-02-21 11:05:27 +01:00
public decimal? DurationMonthYearGes
2017-01-24 13:43:59 +01:00
{
get
{
2017-01-31 07:15:00 +01:00
if ( _DurationMonthYearGes = = null )
{
return 0 ;
}
else
{
return _DurationMonthYearGes ;
}
2017-01-24 13:43:59 +01:00
}
set
{
if ( AreDifferent ( _DurationMonthYearGes , value ) )
{
_DurationMonthYearGes = value ;
2017-01-31 07:15:00 +01:00
StoreDirtyInformation ( AreDifferent ( DataContract . RoundedDuration , value ) ,
PropertyName_DurationMonthYearGes ) ;
2017-01-24 13:43:59 +01:00
2017-01-31 07:15:00 +01:00
FirePropertyChanged ( PropertyName_DurationMonthYearGes ) ;
FirePropertyChanged ( PropertyName_RoundedDuration ) ;
TimeCheckMonatJahr ( ) ;
}
2017-01-11 11:02:58 +01:00
}
}
2017-03-15 15:16:06 +01:00
2017-03-15 15:58:11 +01:00
//public string IsFloatGesetzt
//{
// get { return _IsFloatGesetzt; }
// set
// {
// if (AreDifferent(_IsFloatGesetzt, value))
// {
// _IsFloatGesetzt = value;
// FirePropertyChanged(PropertyName_DurationSTD);
// FirePropertyChanged(PropertyName_Duration);
// }
// }
//}
2017-03-15 15:16:06 +01:00
2017-01-11 11:02:58 +01:00
2016-06-27 01:45:38 +02:00
#endregion
#region Public Methods
public void ChangeGoalTree ( List < ValueListEntryDC > goalCats , List < ValueListEntryDC > goals ) //, List<ValueListEntryDC> goalsAndCats)
{
_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 ) ;
}
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 ;
2017-07-27 09:58:04 +02:00
copy . RTFNotice = RTFNotice ;
copy . RTFNotice2 = RTFNotice2 ;
copy . RTFNotice3 = RTFNotice3 ;
copy . RTFNotice4 = RTFNotice4 ;
copy . RTFNotice5 = RTFNotice5 ;
2016-06-27 01:45:38 +02:00
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 ;
2017-02-09 10:05:55 +01:00
copy . SignatureOid = SignatureOid ;
2017-02-01 09:24:33 +01:00
2017-01-11 11:02:58 +01:00
copy . DurationInStunden = DurationInStunden ;
2017-01-19 17:02:07 +01:00
copy . ServiceRecordFormat = ServiceRecordFormat ;
2017-01-11 11:02:58 +01:00
2016-06-27 01:45:38 +02:00
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
2017-01-11 11:02:58 +01:00
2016-06-27 01:45:38 +02:00
protected override void InitByDataContract ( ServiceRecordDC pDataContract )
2017-02-02 13:52:49 +01:00
{
2016-06-27 01:45:38 +02:00
if ( pDataContract . ServiceDescription ! = null )
2017-02-02 13:52:49 +01:00
{
2017-01-24 13:43:59 +01:00
if ( pDataContract . ServiceRecordFormat = = ServiceRecordFormate . OriginaleZeiterfassung | | pDataContract . ServiceRecordFormat = = null )
{
_Date = pDataContract . Start . Value ;
_StartTime = pDataContract . Start . Value ;
_EditableEndDate = pDataContract . End . Value ;
2017-06-11 15:50:31 +02:00
_DurationInStunden = pDataContract . DurationInStunden ;
2017-02-02 13:52:49 +01:00
if ( pDataContract . DurationInStunden = = ZeiterfassungsDauer . Stunden )
2017-01-24 13:43:59 +01:00
{
2017-06-11 15:50:31 +02:00
_DurationSTD = ( decimal ) ( pDataContract . End . Value - pDataContract . Start . Value ) . TotalHours ;
_Duration = _DurationSTD ;
2016-06-27 01:45:38 +02:00
2017-06-11 15:50:31 +02:00
_EndTime = pDataContract . Start . Value . AddHours ( ( double ) _DurationSTD ) ;
2017-01-24 13:43:59 +01:00
}
else
{
_Duration = ( pDataContract . End . Value - pDataContract . Start . Value ) . GetTotalMinutes ( ) ;
2016-06-27 01:45:38 +02:00
2017-03-15 15:16:06 +01:00
_EndTime = pDataContract . Start . Value . AddMinutes ( ( double ) _Duration . Value ) ;
2017-01-24 13:43:59 +01:00
}
2017-06-11 15:50:31 +02:00
2017-01-31 07:15:00 +01:00
_DurationMonthYearGes = 0 ;
2017-01-24 13:43:59 +01:00
} else
if ( pDataContract . ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitEndDatum )
2016-06-27 01:45:38 +02:00
{
2017-01-24 13:43:59 +01:00
_Date = pDataContract . Start . Value . Date ;
_StartTime = pDataContract . Start . Value ;
_EndTime = pDataContract . End . Value ;
_EditableEndDate = pDataContract . End . Value ;
2016-06-27 01:45:38 +02:00
2017-06-14 08:28:21 +02:00
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;
_DurationMonthYearGes = 0 ;
2017-01-31 07:15:00 +01:00
}
2017-01-24 13:43:59 +01:00
else if ( pDataContract . ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitMonatJahr )
2016-06-27 01:45:38 +02:00
{
2017-01-31 07:15:00 +01:00
_Date = pDataContract . Start . Value . Date ;
_StartTime = pDataContract . Start . Value ;
_EndTime = pDataContract . End . Value ;
2017-02-21 11:05:27 +01:00
_DurationMonthYearGes = ( decimal ) ( pDataContract . End . Value - pDataContract . Start . Value ) . TotalHours ;
2017-01-24 13:43:59 +01:00
_OnlyMonth = pDataContract . Start . Value . ToString ( "MMMM" ) ;
_OnlyYear = pDataContract . Start . Value . ToString ( "yyyy" ) ;
2017-01-31 07:15:00 +01:00
_Duration = 0 ;
_DurationSTD = 0 ;
2016-06-27 01:45:38 +02:00
}
2017-01-24 13:43:59 +01:00
2016-06-27 01:45:38 +02:00
_Notice = pDataContract . Notice ;
_Notice2 = pDataContract . Notice2 ;
_Notice3 = pDataContract . Notice3 ;
_Notice4 = pDataContract . Notice4 ;
_Notice5 = pDataContract . Notice5 ;
2017-07-27 09:58:04 +02:00
_RTFNotice = pDataContract . RTFNotice1 ;
_RTFNotice2 = pDataContract . RTFNotice2 ;
_RTFNotice3 = pDataContract . RTFNotice3 ;
_RTFNotice4 = pDataContract . RTFNotice4 ;
_RTFNotice5 = pDataContract . RTFNotice5 ;
2016-06-27 01:45:38 +02:00
_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 ;
2017-01-11 11:02:58 +01:00
_DurationInStunden = pDataContract . DurationInStunden ;
2017-01-19 17:02:07 +01:00
_ServiceRecordFormat = pDataContract . ServiceRecordFormat ;
2017-02-09 10:05:55 +01:00
_SignatureOid = pDataContract . SignatureOid ;
2017-01-24 13:43:59 +01:00
2016-06-27 01:45:38 +02:00
if ( pDataContract . Goals ! = null )
{
_SelectedGoals = new ObservableSortCollection < ValueListEntryDC > ( pDataContract . Goals , 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 ;
}
}
protected override ServiceRecordDC MapToDataContract ( ServiceRecordDC pDataContract , bool doCommit )
{
return CopyToDataContract ( pDataContract ) ;
}
private ServiceRecordDC CopyToDataContract ( ServiceRecordDC pDataContract )
2017-01-31 07:15:00 +01:00
{
2017-02-21 11:05:27 +01:00
var srf = ServiceRecordFormat ;
2017-02-17 13:57:11 +01:00
if ( BeWoApp . AppSettings . IsEndDateVisible & & srf = = null | | ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitEndDatum )
2017-01-24 13:43:59 +01:00
{
2017-02-21 11:05:27 +01:00
pDataContract . Start = Date ;
2017-01-24 13:43:59 +01:00
2017-03-15 15:16:06 +01:00
decimal endduration = 0 ;
//pDataContract.End = EditableEndDate;
if ( _DurationSTD ! = null ) {
2017-01-24 13:43:59 +01:00
if ( _DurationInStunden = = ZeiterfassungsDauer . Stunden )
2017-03-28 10:51:31 +02:00
{
var dura = DurationSTD . Value * 60 ;
decimal roundedDuration = Math . Round ( dura , MidpointRounding . AwayFromZero ) ;
RoundedDuration = roundedDuration ;
endduration = roundedDuration ;
2017-01-24 13:43:59 +01:00
}
else
2017-03-28 10:51:31 +02:00
{
var dura = DurationSTD . Value ;
decimal roundedDuration = Math . Round ( dura , MidpointRounding . AwayFromZero ) ;
RoundedDuration = roundedDuration ;
endduration = roundedDuration ;
2017-01-24 13:43:59 +01:00
}
}
2016-06-27 01:45:38 +02:00
2017-03-15 15:16:06 +01:00
pDataContract . End = Date . Value . AddMinutes ( ( double ) endduration ) ;
2017-01-31 07:15:00 +01:00
_DurationMonthYearGes = 0 ;
_Duration = 0 ;
2017-01-24 13:43:59 +01:00
ServiceRecordFormat = ServiceRecordFormate . ZeiterfassungMitEndDatum ;
}
2017-02-17 13:57:11 +01:00
else if ( BeWoApp . AppSettings . IsOnlyYearMonthVisible & & srf = = null | | ServiceRecordFormat = = ServiceRecordFormate . ZeiterfassungMitMonatJahr )
2017-01-24 13:43:59 +01:00
{
2017-02-21 11:05:27 +01:00
var dates = DateTime . Parse ( "1." + OnlyMonth + OnlyYear ) ;
2016-06-27 01:45:38 +02:00
2017-03-08 13:05:45 +01:00
var StartDatetime = new DateTime ( dates . Year , dates . Month , 1 , 0 , 0 , 1 ) ;
2017-01-31 07:15:00 +01:00
2017-01-24 13:43:59 +01:00
pDataContract . Start = StartDatetime ;
2017-02-21 12:41:12 +01:00
pDataContract . End = StartDatetime . AddHours ( ( double ) DurationMonthYearGes ) ;
2017-01-19 17:02:07 +01:00
2017-01-24 13:43:59 +01:00
if ( _DurationMonthYearGes ! = 0 )
2017-01-11 11:02:58 +01:00
{
2017-03-28 10:51:31 +02:00
var dura = DurationMonthYearGes . Value * 60 ;
decimal roundedDuration = Math . Round ( dura , MidpointRounding . AwayFromZero ) ;
RoundedDuration = roundedDuration ;
2017-01-11 11:02:58 +01:00
}
2017-01-19 17:02:07 +01:00
2017-03-15 15:58:11 +01:00
Date = StartDatetime ;
StartTime = StartDatetime ;
2017-01-31 07:15:00 +01:00
_DurationSTD = 0 ;
2017-03-15 15:16:06 +01:00
_Duration = 0 ;
2017-01-31 07:15:00 +01:00
2017-01-24 13:43:59 +01:00
ServiceRecordFormat = ServiceRecordFormate . ZeiterfassungMitMonatJahr ;
2017-01-31 07:15:00 +01:00
2017-02-21 12:41:12 +01:00
_DurationInStunden = ZeiterfassungsDauer . Stunden ;
2017-01-11 11:02:58 +01:00
}
else
2017-01-31 07:15:00 +01:00
{
2017-02-21 11:05:27 +01:00
var date = Date . Value ;
2017-01-24 13:43:59 +01:00
2017-03-27 11:05:32 +02:00
DateTime time ;
if ( StartTime . HasValue )
time = StartTime . Value ;
else
time = Date . Value . AddSeconds ( 1 ) ;
2017-03-09 11:32:48 +01:00
2017-01-24 13:43:59 +01:00
pDataContract . Start = new DateTime ( date . Year , date . Month , date . Day , time . Hour , time . Minute , time . Second ) ;
2017-03-15 15:16:06 +01:00
decimal duration = 0 ;
2017-02-21 11:05:27 +01:00
if ( Duration . HasValue )
2017-03-28 10:51:31 +02:00
{
2017-02-21 11:05:27 +01:00
duration = Duration . Value ;
2017-01-19 17:02:07 +01:00
}
2017-01-24 13:43:59 +01:00
2017-02-21 11:05:27 +01:00
if ( DurationInStunden = = ZeiterfassungsDauer . Stunden )
2017-01-24 13:43:59 +01:00
{
2017-03-28 10:51:31 +02:00
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 ;
2017-01-24 13:43:59 +01:00
}
2017-01-31 07:15:00 +01:00
2017-03-15 09:37:12 +01:00
RoundedDuration = duration ;
2017-01-31 07:15:00 +01:00
_DurationSTD = 0 ;
_DurationMonthYearGes = 0 ;
2017-01-24 13:43:59 +01:00
2017-03-15 15:16:06 +01:00
pDataContract . End = pDataContract . Start . Value . AddMinutes ( ( double ) duration ) ;
2017-01-24 13:43:59 +01:00
ServiceRecordFormat = ServiceRecordFormate . OriginaleZeiterfassung ;
2017-01-11 11:02:58 +01:00
}
2017-03-15 15:16:06 +01:00
2017-01-11 11:02:58 +01:00
2016-06-27 01:45:38 +02:00
pDataContract . Notice = _Notice ;
pDataContract . Notice2 = _Notice2 ;
pDataContract . Notice3 = _Notice3 ;
pDataContract . Notice4 = _Notice4 ;
pDataContract . Notice5 = _Notice5 ;
2017-07-27 09:58:04 +02:00
pDataContract . RTFNotice1 = _RTFNotice ;
pDataContract . RTFNotice2 = _RTFNotice2 ;
pDataContract . RTFNotice3 = _RTFNotice3 ;
pDataContract . RTFNotice4 = _RTFNotice4 ;
pDataContract . RTFNotice5 = _RTFNotice5 ;
2016-06-27 01:45:38 +02:00
pDataContract . ServiceRecordType = _ServiceRecordType ;
pDataContract . DistanceInMeter = _DistanceInMeter ;
2017-01-11 11:02:58 +01:00
pDataContract . DurationInStunden = _DurationInStunden ;
2017-01-19 17:02:07 +01:00
pDataContract . ServiceRecordFormat = _ServiceRecordFormat ;
2017-01-11 11:02:58 +01:00
2016-06-27 01:45:38 +02:00
pDataContract . Employee = _Employee ;
pDataContract . Customer = _Customer ;
pDataContract . SupportConcept = _SupportConcept ;
pDataContract . CostBearer = _CostBearer ;
pDataContract . RoundedDuration = RoundedDuration ;
pDataContract . ServiceDescription = _ServiceDescription ;
pDataContract . Goals = GetSelectedGoals ( ) ;
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 ( )
{
2017-03-15 15:16:06 +01:00
decimal duration = 0 ;
2016-06-27 01:45:38 +02:00
if ( _Duration . HasValue )
{
duration = _Duration . Value ;
2017-03-09 11:32:48 +01:00
}
StoreDirtyInformation (
2017-03-15 15:16:06 +01:00
AreDifferent ( DataContract . End , ( _Date . Value + _StartTime . Value . TimeOfDay ) . AddMinutes ( ( double ) duration ) ) | |
2017-03-09 11:32:48 +01:00
AreDifferent ( DataContract . Start , _Date . Value + _StartTime . Value . TimeOfDay ) , "TIME" ) ;
2017-02-09 13:51:26 +01:00
2017-02-14 13:55:40 +01:00
2017-03-09 11:32:48 +01:00
if ( _StartTime ! = null )
{
if ( _DurationInStunden = = ZeiterfassungsDauer . Minuten )
2017-03-15 15:16:06 +01:00
_EndTime = _StartTime . Value . AddMinutes ( ( double ) duration ) ;
2017-03-09 11:32:48 +01:00
else
2017-03-15 15:16:06 +01:00
_EndTime = _StartTime . Value . AddHours ( ( double ) duration ) ;
2017-02-09 13:51:26 +01:00
2017-03-28 10:51:31 +02:00
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 ) ;
2017-03-09 11:32:48 +01:00
}
2016-06-27 01:45:38 +02:00
}
2017-01-31 07:15:00 +01:00
private void TimeCheckMonatJahr ( )
{
2017-02-21 11:05:27 +01:00
//var duration = 0;
decimal duration = 0 ;
2017-02-21 12:41:12 +01:00
if ( _DurationMonthYearGes . HasValue )
2017-01-31 07:15:00 +01:00
{
duration = _DurationMonthYearGes . Value ;
}
var dates = DateTime . Parse ( "1." + _OnlyMonth + _OnlyYear ) ;
2017-03-08 13:05:45 +01:00
var StartDatetime = new DateTime ( dates . Year , dates . Month , 1 , 0 , 0 , 1 ) ;
2017-01-31 07:15:00 +01:00
StoreDirtyInformation (
2017-03-08 13:05:45 +01:00
AreDifferent ( DataContract . End , StartDatetime . AddHours ( ( double ) duration ) . AddSeconds ( 1 ) ) | |
2017-01-31 07:15:00 +01:00
AreDifferent ( DataContract . Start , StartDatetime ) , "TIME" ) ;
}
2017-01-24 13:43:59 +01:00
private void TimeCheckForDurationSTD ( )
2017-02-02 13:52:49 +01:00
{
2017-02-21 11:05:27 +01:00
double duration = 0 ;
if ( _DurationSTD . HasValue ) {
duration = ( double ) _DurationSTD . Value ;
2017-01-11 11:02:58 +01:00
}
2017-01-24 13:43:59 +01:00
//####################### ich glaub das wars ##########################
2017-02-02 13:52:49 +01:00
if ( _DurationInStunden = = ZeiterfassungsDauer . Minuten )
2017-01-11 11:02:58 +01:00
{
2017-01-24 13:43:59 +01:00
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 ) ;
2017-01-11 11:02:58 +01:00
2017-01-24 13:43:59 +01:00
_EndTime = _StartTime . Value . AddMinutes ( duration ) ;
2017-03-27 11:05:32 +02:00
if ( _EndTime . Value . Second > 1 )
{
_EndTime = new DateTime ( _EndTime . Value . Year , _EndTime . Value . Month , _EndTime . Value . Day , _EndTime . Value . Hour , _EndTime . Value . Minute , 0 ) ;
}
2017-01-24 13:43:59 +01:00
}
2017-01-11 11:02:58 +01:00
2017-01-24 13:43:59 +01:00
if ( _StartTime = = null & & _EndTime ! = null & & duration = = 0 )
2017-01-11 11:02:58 +01:00
{
2017-01-24 13:43:59 +01:00
_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 ) ;
2017-01-11 11:02:58 +01:00
}
2017-01-24 13:43:59 +01:00
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 ) ;
2017-01-11 11:02:58 +01:00
2017-01-24 13:43:59 +01:00
_EndTime = _StartTime . Value . AddMinutes ( duration ) ;
2017-03-27 11:05:32 +02:00
if ( _EndTime . Value . Second > 1 )
{
_EndTime = new DateTime ( _EndTime . Value . Year , _EndTime . Value . Month , _EndTime . Value . Day , _EndTime . Value . Hour , _EndTime . Value . Minute , 0 ) ;
}
2017-01-24 13:43:59 +01:00
}
2017-01-11 11:02:58 +01:00
2017-01-24 13:43:59 +01:00
if ( _StartTime = = null & & _EndTime = = null & & duration = = 0 )
{
2017-02-01 09:24:33 +01:00
_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 ) ;
2017-01-24 13:43:59 +01:00
}
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 ) ;
2017-03-15 15:16:06 +01:00
duration = ( double ) diff . TotalMinutes ;
2017-01-24 13:43:59 +01:00
2017-02-21 11:05:27 +01:00
_DurationSTD = ( decimal ) duration ;
2017-01-24 13:43:59 +01:00
}
2017-02-02 13:52:49 +01:00
else if ( _DurationInStunden = = ZeiterfassungsDauer . Stunden )
2017-01-11 11:02:58 +01:00
{
2017-01-24 13:43:59 +01:00
if ( _StartTime ! = null & & _EndTime ! = null )
2017-02-02 13:52:49 +01:00
{
2017-01-24 13:43:59 +01:00
_StartTime = new DateTime ( _Date . Value . Year , _Date . Value . Month , _Date . Value . Day ,
_StartTime . Value . Hour , _StartTime . Value . Minute , _StartTime . Value . Second ) ;
2017-01-11 11:02:58 +01:00
2017-01-24 13:43:59 +01:00
_EndTime = _StartTime . Value . AddHours ( duration ) ;
2017-03-27 11:05:32 +02:00
if ( _EndTime . Value . Second > 1 )
{
_EndTime = new DateTime ( _EndTime . Value . Year , _EndTime . Value . Month , _EndTime . Value . Day , _EndTime . Value . Hour , _EndTime . Value . Minute , 0 ) ;
}
2017-01-24 13:43:59 +01:00
}
if ( _StartTime = = null & & _EndTime ! = null & & duration = = 0 )
2017-01-11 11:02:58 +01:00
{
2017-01-24 13:43:59 +01:00
_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 )
2017-01-11 11:02:58 +01:00
{
2017-01-24 13:43:59 +01:00
_StartTime = _EndTime . Value . AddHours ( duration * - 1 ) ;
2017-01-11 11:02:58 +01:00
}
2017-01-19 17:02:07 +01:00
2017-01-24 13:43:59 +01:00
if ( _StartTime ! = null & & _EndTime = = null & & duration = = 0 )
2017-01-19 17:02:07 +01:00
{
2017-01-24 13:43:59 +01:00
_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 ) ;
2017-03-27 11:05:32 +02:00
if ( _EndTime . Value . Second > 1 )
{
_EndTime = new DateTime ( _EndTime . Value . Year , _EndTime . Value . Month , _EndTime . Value . Day , _EndTime . Value . Hour , _EndTime . Value . Minute , 0 ) ;
}
2017-01-24 13:43:59 +01:00
}
2017-01-19 17:02:07 +01:00
2017-01-24 13:43:59 +01:00
if ( _StartTime = = null & & _EndTime = = null & & duration = = 0 )
{
2017-02-01 09:24:33 +01:00
_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 ) ;
2017-01-19 17:02:07 +01:00
}
2017-01-24 13:43:59 +01:00
else if ( _StartTime = = null & & _EndTime = = null )
2017-01-19 17:02:07 +01:00
{
2017-01-24 13:43:59 +01:00
//start 1 sek und end duration + 1 sek
_StartTime = new DateTime ( _Date . Value . Year , _Date . Value . Month , _Date . Value . Day , 0 , 0 , 1 ) ;
2017-01-19 17:02:07 +01:00
2017-01-24 13:43:59 +01:00
_EndTime = new DateTime ( _EditableEndDate . Value . Year , _EditableEndDate . Value . Month , _EditableEndDate . Value . Day , 0 , 0 , 1 ) ;
_EndTime = _EndTime . Value . AddHours ( duration ) ;
2017-01-19 17:02:07 +01:00
}
2017-02-01 09:24:33 +01:00
_Date = new DateTime ( _Date . Value . Year , _Date . Value . Month , _Date . Value . Day , _StartTime . Value . Hour , _StartTime . Value . Minute , _StartTime . Value . Second ) ;
2017-01-24 13:43:59 +01:00
_EditableEndDate = new DateTime ( _EndTime . Value . Year , _EndTime . Value . Month , _EndTime . Value . Day , _EndTime . Value . Hour , _EndTime . Value . Minute , _EndTime . Value . Second ) ;
2017-03-27 11:05:32 +02:00
var diff = _EditableEndDate . Value . Subtract ( _Date . Value ) ;
2017-03-15 15:16:06 +01:00
duration = ( double ) diff . TotalHours ;
2017-01-24 13:43:59 +01:00
2017-03-15 15:16:06 +01:00
_DurationSTD = ( decimal ) Math . Round ( duration , 2 ) ;
2017-01-24 13:43:59 +01:00
}
FirePropertyChanged ( PropertyName_DurationSTD ) ;
FirePropertyChanged ( PropertyName_StartTime ) ;
FirePropertyChanged ( PropertyName_EndTime ) ;
FirePropertyChanged ( PropertyName_Date ) ;
FirePropertyChanged ( PropertyName_EditableEndDate ) ;
2017-02-01 09:24:33 +01:00
}
2016-06-27 01:45:38 +02:00
#endregion
}
}