246 lines
8.7 KiB
C#
246 lines
8.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Reflection.Emit;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
using System.Windows.Threading;
|
|
using System.Xml;
|
|
using Telerik.Windows.Input.Touch;
|
|
|
|
namespace eDosStation
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for UserInfo.xaml
|
|
/// </summary>
|
|
public partial class UserInfo : Window
|
|
{
|
|
int PersID;
|
|
DataTable dsInfo;
|
|
DataSet1.GetPersonOverviewRow rw;
|
|
GridLength glz = new GridLength(0);
|
|
Station station;
|
|
|
|
public UserInfo( Station s, int persid)
|
|
{
|
|
InitializeComponent();
|
|
PersID = persid;
|
|
if (PersID == 0)
|
|
{
|
|
station = s;
|
|
s.ReceivedPersid = Pelatec_DataReceived;
|
|
}
|
|
}
|
|
|
|
private void showBadge(int persid)
|
|
{
|
|
PersID = persid;
|
|
dataLoad();
|
|
|
|
}
|
|
private void Pelatec_DataReceived(int PersID)
|
|
{
|
|
this.Dispatcher.InvokeAsync(new Action(() => showBadge(PersID)), DispatcherPriority.Background);
|
|
}
|
|
|
|
|
|
private void cmdOK_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void SetEmpty()
|
|
{
|
|
LastName.Text = "Please scan your badge";
|
|
FirstName.Text = string.Empty;
|
|
Type.Text = string.Empty;
|
|
BadgeColor.Text = string.Empty;
|
|
|
|
QuizExpiry.Text = string.Empty;
|
|
MedicExpiry.Text = string.Empty;
|
|
|
|
RFEnd.Text = string.Empty;
|
|
|
|
BadgeColor.Text = string.Empty;
|
|
QuizOK.Text = string.Empty;
|
|
MedicOK.Text = string.Empty;
|
|
|
|
int r = Grid.GetRow(InVivoOK);
|
|
RowDefinition rowDef = G1.RowDefinitions[r];
|
|
rowDef.Height = glz;
|
|
|
|
r = Grid.GetRow(InVitroOK);
|
|
rowDef = G1.RowDefinitions[r];
|
|
rowDef.Height = glz;
|
|
|
|
VxExpiry.Text = string.Empty;
|
|
VxColor.Text = string.Empty;
|
|
|
|
bEPDOff.Visibility = Visibility.Collapsed;
|
|
|
|
}
|
|
|
|
void setTBExpiry(TextBlock tb, DateTime? exp, bool? ok)
|
|
{
|
|
Brush rv;
|
|
|
|
if (ok.HasValue && !ok.Value)
|
|
{
|
|
rv = Converters.cbRed;
|
|
}
|
|
else
|
|
{
|
|
if (exp.HasValue)
|
|
{
|
|
DateTime dt = exp.Value;
|
|
int weeks = (int)((dt - DateTime.Today).TotalDays / 7.0);
|
|
if (weeks > 2) rv = Converters.cbGreen;
|
|
else if (weeks > -1) rv = Converters.cbYellow;
|
|
else rv = Converters.cbRed;
|
|
}
|
|
else
|
|
rv = Converters.cbGray;
|
|
}
|
|
|
|
if (exp.HasValue) tb.Text = exp.Value.ToString("yyyy-MM-dd"); else tb.Text = string.Empty;
|
|
tb.Background = rv;
|
|
|
|
}
|
|
|
|
void setTB( TextBlock tb, bool? ok, string yes="OK", string no = "Not OK")
|
|
{
|
|
if ( ok.HasValue && ok.Value)
|
|
{
|
|
tb.Text = yes;
|
|
tb.Background = Converters.cbGreen;
|
|
} else
|
|
{
|
|
tb.Text = no;
|
|
tb.Background = Converters.cbGreen;
|
|
}
|
|
|
|
}
|
|
|
|
private void dataLoad()
|
|
{
|
|
rw = null;
|
|
using (var ta = new DataSet1TableAdapters.GetPersonOverviewTableAdapter())
|
|
{
|
|
dsInfo = ta.GetData(PersID);
|
|
if (dsInfo != null && dsInfo.Rows.Count > 0) rw = dsInfo.Rows[0] as DataSet1.GetPersonOverviewRow;
|
|
}
|
|
|
|
if (rw != null)
|
|
{
|
|
LastName.Text = rw.LastName;
|
|
FirstName.Text = rw.FirstName;
|
|
Type.Text = rw.Type;
|
|
MarginHP10_Y.Text = rw.MarginHP10_Y.ToString() + " µSv";
|
|
|
|
if (rw.VisitIDLocked > 0)
|
|
VisitLocked.Text = rw.VisitIDLocked.ToString();
|
|
else
|
|
VisitLocked.Text = string.Empty;
|
|
|
|
bool? bAccessAllow = rw.AccessAllow as bool?;
|
|
setTB(AccessAllow, bAccessAllow, no: "No Access");
|
|
|
|
Comment.Text = rw.ReasonNoAccess;
|
|
|
|
if (rw.eDosAgent) bEPDOff.Visibility = Visibility.Visible; else bEPDOff.Visibility = Visibility.Collapsed;
|
|
|
|
if (!rw.IsinfoNull())
|
|
{
|
|
XmlDocument xmlDocument = new XmlDocument();
|
|
xmlDocument.LoadXml(rw.info);
|
|
var nl = xmlDocument.SelectSingleNode("Info[1]") as XmlElement;
|
|
|
|
//QuizDate.Text = XmlConvert.ToDateTime(nl.GetAttribute("QuizDate"), XmlDateTimeSerializationMode.Local).ToString("yyyy-MM-dd");
|
|
bool bQuizOK = XmlConvert.ToBoolean(nl.GetAttribute("QuizOK"));
|
|
setTB(QuizOK, bQuizOK);
|
|
setTBExpiry(QuizExpiry, XmlConvert.ToDateTime( nl.GetAttribute("QuizExpiry"), XmlDateTimeSerializationMode.Local), bQuizOK);
|
|
|
|
bool bMedicOK = XmlConvert.ToBoolean(nl.GetAttribute("MedicOK"));
|
|
setTB(MedicOK, bMedicOK);
|
|
setTBExpiry(MedicExpiry, XmlConvert.ToDateTime(nl.GetAttribute("MedicExpiry"), XmlDateTimeSerializationMode.Local),bMedicOK);
|
|
|
|
setTBExpiry(RFEnd, XmlConvert.ToDateTime(nl.GetAttribute("RFEnd"), XmlDateTimeSerializationMode.Local), null);
|
|
|
|
BadgeColor.Text = nl.GetAttribute("badgeColor");
|
|
|
|
bool BunkerReq = XmlConvert.ToBoolean(nl.GetAttribute("InVivoReq"));
|
|
int r = Grid.GetRow(InVivoOK);
|
|
RowDefinition rowDef = G1.RowDefinitions[r];
|
|
rowDef.Height = BunkerReq ? GridLength.Auto : glz;
|
|
if (BunkerReq)
|
|
{
|
|
bool bInvivoOK = XmlConvert.ToBoolean(nl.GetAttribute("InVivoOK"));
|
|
//InVivoWbcFreq.Text = nl.GetAttribute("InVivoWbcFreq");
|
|
setTB(InVivoOK, bInvivoOK);
|
|
setTBExpiry(InVivoWbcExpiry, XmlConvert.ToDateTime(nl.GetAttribute("InVivoWbcExpiry"), XmlDateTimeSerializationMode.Local), bInvivoOK);
|
|
}
|
|
|
|
bool LRMReq = XmlConvert.ToBoolean(nl.GetAttribute("InVitroReq"));
|
|
r = Grid.GetRow(InVitroOK);
|
|
rowDef = G1.RowDefinitions[r];
|
|
rowDef.Height = LRMReq ? GridLength.Auto : glz;
|
|
if (LRMReq)
|
|
{
|
|
bool bInvitroOK = XmlConvert.ToBoolean(nl.GetAttribute("InVitroOK"));
|
|
//InVitroFreq.Text = nl.GetAttribute("InVitroFreq");
|
|
setTB(InVitroOK, bInvitroOK);
|
|
setTBExpiry(InVivoWbcExpiry, XmlConvert.ToDateTime(nl.GetAttribute("InVitroExpiry"), XmlDateTimeSerializationMode.Local), bInvitroOK);
|
|
}
|
|
|
|
bool bVXOK = nl.GetAttribute("VxColor").Equals("1");
|
|
setTB(VxColor, bVXOK);
|
|
setTBExpiry(VxExpiry, XmlConvert.ToDateTime(nl.GetAttribute("VxExpiry"), XmlDateTimeSerializationMode.Local), bVXOK);
|
|
|
|
}
|
|
else
|
|
{
|
|
//QuizDate.Text = string.Empty;
|
|
QuizExpiry.Text = string.Empty;
|
|
MedicExpiry.Text = string.Empty;
|
|
//RFStart.Text = string.Empty;
|
|
RFEnd.Text = string.Empty;
|
|
|
|
BadgeColor.Text = string.Empty;
|
|
QuizOK.Text = string.Empty;
|
|
MedicOK.Text = string.Empty;
|
|
|
|
int r = Grid.GetRow(InVivoOK);
|
|
RowDefinition rowDef = G1.RowDefinitions[r];
|
|
rowDef.Height = glz;
|
|
|
|
r = Grid.GetRow(InVitroOK);
|
|
rowDef = G1.RowDefinitions[r];
|
|
rowDef.Height = glz;
|
|
|
|
VxExpiry.Text = string.Empty;
|
|
VxColor.Text = string.Empty;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
SetEmpty();
|
|
if (PersID != 0) dataLoad();
|
|
}
|
|
|
|
private void bEPDOff_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
MessageBox.Show("Not implemented yet", "Warning", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
}
|
|
}
|
|
}
|