Files
Samuele Locatelli 94245a0a44 Calendario Radzen
- sostituito cal precedente
- fix comportamento di base
- ok navigazione di base
2024-09-06 17:35:34 +02:00

143 lines
4.1 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GPW.CORE.Data.DTO
{
public class EventDTO
{
public string CodTipo { get; set; } = "";
public int IdxEv { get; set; } = 0;
public int IdxDipendente { get; set; } = 0;
public string CognomeNome { get; set; } = "";
public string Abbrev { get; set; } = "";
public string Titolo { get; set; } = "";
public string Descrizione { get; set; } = "";
public string Tooltip { get; set; } = "";
public DateTime DtStart { get; set; } = DateTime.Today.AddHours(9);
public DateTime DtEnd { get; set; } = DateTime.Today.AddHours(17);
public string Note { get; set; } = "";
public bool Conf { get; set; } = false;
public bool IsDraggable { get; set; } = false;
public bool IsCompany { get; set; } = false;
public EventDTO Clone()
{
return new EventDTO()
{
CodTipo = this.CodTipo,
IdxEv = this.IdxEv,
IdxDipendente = this.IdxDipendente,
CognomeNome = this.CognomeNome,
Abbrev = this.Abbrev,
Titolo = this.Titolo,
Descrizione = this.Descrizione,
Tooltip = this.Tooltip,
DtStart = this.DtStart,
DtEnd = this.DtEnd,
Note = this.Note,
Conf = this.Conf,
IsDraggable = this.IsDraggable,
IsCompany = this.IsCompany
};
}
public string Durata
{
get
{
string answ = "-";
var durata = DtEnd.Subtract(DtStart);
if (CodTipo == "FER")
{
answ = $"{durata.TotalDays + 1:N0}gg";
}
else
{
answ = $"{durata.TotalHours:N1}h";
}
return answ;
}
}
public static string DateForm(string Tipo, DateTime DtEvent)
{
return (Tipo == "PERM" || Tipo == "104") ? $"{DtEvent:HH:mm}" : $"{DtEvent:ddd yyyy-MM-dd}";
}
public string Color
{
get => calcColor(CodTipo, Conf, IsCompany);
}
public string? ForeColor
{
get => calcText(CodTipo, Conf, IsCompany);
}
private string calcColor(string codGiust, bool conf, bool isComp)
{
string answ = "#EDEDED";
switch (codGiust)
{
case "FER":
answ = isComp? "#EEDD11" : conf ? "#11CD44" : "#AAFFCD";
break;
case "FEST":
answ = "#DD0033";
break;
case "104":
answ = conf ? "#DE00AB" : "#FFAACD";
break;
case "MAL":
answ = conf ? "#000" : "#696969";
break;
case "PERM":
answ = conf ? "#9966DE" : "#CDAAFF";
break;
default:
break;
}
return answ;
}
private string calcText (string codGiust, bool conf, bool isComp)
{
string answ = "#EDEDED";
switch (codGiust)
{
case "FER":
answ = isComp ? "#000000" : conf ? "#FFFFFF" : "#000000";
break;
case "FEST":
answ = "#EEDD11";
break;
case "104":
answ = conf ? "#DEDEDE" : "#000000";
break;
case "MAL":
answ = conf ? "#DEDEDE" : "#ABABAB";
break;
case "PERM":
answ = conf ? "#DEDEDE" : "#000000";
break;
default:
break;
}
return answ;
}
}
}