173 lines
4.1 KiB
C#
173 lines
4.1 KiB
C#
using BS.Shared;
|
|
using System;
|
|
|
|
namespace BeWo.Data.Entities
|
|
{
|
|
public class ArbeitszeitEintrag : BeWoEntityBase
|
|
{
|
|
public static string PropertyName_UhrzeitVon = "UhrzeitVon";
|
|
|
|
public static string PropertyName_UhrzeitBis = "UhrzeitBis";
|
|
|
|
public static string PropertyName_Tag = "Tag";
|
|
|
|
public static string PropertyName_ArbeitszeitOid = "ArbeitszeitOid";
|
|
|
|
public static string PropertyName_Klient = "Klient";
|
|
|
|
public ArbeitszeitEintrag()
|
|
{
|
|
_Tid = TableID.ArbeitszeitEintrag;
|
|
}
|
|
|
|
private string _UhrzeitVon;
|
|
|
|
private string _UhrzeitBis;
|
|
|
|
private AppointmentDayOfWeek _Tag;
|
|
|
|
private long? _ArbeitszeitOid;
|
|
|
|
private long? _CustomerOid;
|
|
|
|
|
|
public virtual string UhrzeitVon
|
|
{
|
|
get
|
|
{
|
|
return this._UhrzeitVon;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._UhrzeitVon, value))
|
|
{
|
|
this._UhrzeitVon = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual string UhrzeitBis
|
|
{
|
|
get
|
|
{
|
|
return this._UhrzeitBis;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._UhrzeitBis, value))
|
|
{
|
|
this._UhrzeitBis = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual long? CustomerOid
|
|
{
|
|
get
|
|
{
|
|
return this._CustomerOid;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._CustomerOid, value))
|
|
{
|
|
this._CustomerOid = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public virtual AppointmentDayOfWeek Tag
|
|
{
|
|
get
|
|
{
|
|
return this._Tag;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._Tag, value))
|
|
{
|
|
this._Tag = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual long? ArbeitszeitOid
|
|
{
|
|
get
|
|
{
|
|
return this._ArbeitszeitOid;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (this.AreDifferent(this._ArbeitszeitOid, value))
|
|
{
|
|
this._ArbeitszeitOid = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual Employee Employee { get; set; }
|
|
|
|
public virtual Customer Customer { get; set; }
|
|
|
|
public virtual bool IstAmGleichenWochentag(DateTime date)
|
|
{
|
|
var day = date.DayOfWeek;
|
|
|
|
if (day == DayOfWeek.Monday && Tag == AppointmentDayOfWeek.Montag)
|
|
{
|
|
return true;
|
|
}
|
|
if (day == DayOfWeek.Tuesday && Tag == AppointmentDayOfWeek.Dienstag)
|
|
{
|
|
return true;
|
|
}
|
|
if (day == DayOfWeek.Wednesday && Tag == AppointmentDayOfWeek.Mittwoch)
|
|
{
|
|
return true;
|
|
}
|
|
if (day == DayOfWeek.Thursday && Tag == AppointmentDayOfWeek.Donnerstag)
|
|
{
|
|
return true;
|
|
}
|
|
if (day == DayOfWeek.Friday && Tag == AppointmentDayOfWeek.Freitag)
|
|
{
|
|
return true;
|
|
}
|
|
if (day == DayOfWeek.Saturday && Tag == AppointmentDayOfWeek.Samstag)
|
|
{
|
|
return true;
|
|
}
|
|
if (day == DayOfWeek.Sunday && Tag == AppointmentDayOfWeek.Sonntag)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public virtual decimal BerechneStunden()
|
|
{
|
|
DateTime dt = DateTime.Now;
|
|
|
|
String dateStr1 = String.Format("{0:dd.MM.yyyy} {1}", dt, UhrzeitVon);
|
|
String dateStr2 = String.Format("{0:dd.MM.yyyy} {1}", dt, UhrzeitBis);
|
|
|
|
DateTime date1;
|
|
DateTime date2;
|
|
|
|
if (DateTime.TryParse(dateStr1, out date1) && DateTime.TryParse(dateStr2, out date2))
|
|
{
|
|
|
|
return (decimal)date2.Subtract(date1).TotalHours;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
} |