diff --git a/eDosStation/App.config b/eDosStation/App.config
index 45ca604..1e91979 100644
--- a/eDosStation/App.config
+++ b/eDosStation/App.config
@@ -44,5 +44,6 @@
+
diff --git a/eDosStation/DataInterface.cs b/eDosStation/DataInterface.cs
index 1e4a392..bd1a74a 100644
--- a/eDosStation/DataInterface.cs
+++ b/eDosStation/DataInterface.cs
@@ -291,12 +291,11 @@ namespace eDosStation
{
User u = new User();
object[] Values = null;
- if (int.TryParse(Code,out int PersID))
using (var cmd = new SqlCommand("GetPersonInfo", localConnection))
{
cmd.CommandType = System.Data.CommandType.StoredProcedure;
- cmd.Parameters.AddWithValue("csn", CSN);
- cmd.Parameters.AddWithValue("PersID", PersID);
+ if (int.TryParse(Code, out int PersID) ) cmd.Parameters.AddWithValue("PersID", PersID);
+ else cmd.Parameters.AddWithValue("csn", CSN);
//if (!string.IsNullOrWhiteSpace(Code)) cmd.Parameters.AddWithValue("Badge", Code);
checkCon(true);
cmd.Connection = localConnection;
diff --git a/eDosStation/EntryBadge.xaml b/eDosStation/EntryBadge.xaml
index 6cf9bad..58ed806 100644
--- a/eDosStation/EntryBadge.xaml
+++ b/eDosStation/EntryBadge.xaml
@@ -33,6 +33,9 @@
+
+
+
diff --git a/eDosStation/EntryBadge.xaml.cs b/eDosStation/EntryBadge.xaml.cs
index 8f23f43..077232f 100644
--- a/eDosStation/EntryBadge.xaml.cs
+++ b/eDosStation/EntryBadge.xaml.cs
@@ -8,14 +8,12 @@ using System.Windows.Threading;
namespace eDosStation
{
-
///
/// Interaction logic for EntryBadge.xaml
///
public partial class EntryBadge : Window
{
const int PageTimeout = 10000;
-
bool initialising = true;
Station thisStation;
EpdBaseClr.Epd2 ep;
@@ -51,6 +49,7 @@ namespace eDosStation
thisStation = curStation;
_User = null;
}
+
private bool LoadDoses()
{
bool rv = true;
@@ -131,7 +130,14 @@ namespace eDosStation
private void DoEPD()
{
int? StationVisitID = null;
- int? ID_Visit= DataInterface.NextID();
+ int? ID_Visit = null;
+ try
+ {
+ ID_Visit = DataInterface.NextID();
+ } catch (System.Exception ex)
+ {
+ MessageBox.Show($"Error {ex.Message}");
+ }
if (ID_Visit.HasValue && LoadDoses())
{
bool isBG = (ep.epdType != 3); //3 = zwarte 0=grijs
@@ -145,7 +151,7 @@ namespace eDosStation
dataInterface.VisitInitCommand.Parameters["EPD_InternalID"].Value = (int)ep.EpdID;
dataInterface.VisitInitCommand.Parameters["isBG"].Value = isBG;
dataInterface.VisitInitCommand.Parameters["ENTRY_EPD_CLOCK"].Value = ep.CountsClock;
-
+
using (var l = new SqlLog())
try
@@ -369,7 +375,7 @@ namespace eDosStation
void CheckBadge()
{
_User = dataInterface.GetUser(CSN.Text, Code.Text);
- ShowUserInfo(); //AskTask();
+ if (!ShowUserInfo()) endPage();
}
public void showBadge(int persID, string csn)
{
@@ -594,6 +600,11 @@ namespace eDosStation
}
+ private void LeesCancel_Click(object sender, RoutedEventArgs e)
+ {
+ endPage();
+ }
+
private void DfReader_BadgeTO(LSWDesfirePublic.CCard Sender, EventArgs e)
{
this.Dispatcher.Invoke(new Action(() => endPage()));
diff --git a/eDosStation/SqlLog.cs b/eDosStation/SqlLog.cs
index 47c0e93..3b33a0d 100644
--- a/eDosStation/SqlLog.cs
+++ b/eDosStation/SqlLog.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -8,15 +9,23 @@ namespace eDosStation
{
public class SqlLog: IDisposable
{
+ private string sqlLogFolder;
+ private string sqlLogFile;
private bool disposed = false;
System.IO.StreamWriter wr;
System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.GetCultureInfo("en-US");
public SqlLog()
{
+ wr = null;
try
{
- wr = new System.IO.StreamWriter(@"c:\temp\sql.txt", true);
+ sqlLogFolder = ConfigurationManager.AppSettings["sqlLogFolder"];
+ if (System.IO.Directory.Exists(sqlLogFolder))
+ {
+ sqlLogFile = System.IO.Path.Combine(sqlLogFolder, "sql.txt");
+ wr = new System.IO.StreamWriter(sqlLogFile, true);
+ }
} catch(System.Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
@@ -35,7 +44,7 @@ namespace eDosStation
if (disposing)
{
if (wr?.BaseStream != null) wr.Close();
- wr.Dispose();
+ wr?.Dispose();
}
disposed = true;
}
@@ -47,7 +56,7 @@ namespace eDosStation
public void LogCommand(string ermsg)
{
- if (wr.BaseStream.CanWrite)
+ if (wr !=null && wr.BaseStream.CanWrite)
{
wr.WriteLine($"-- {System.DateTime.Now.ToString("yyyy-MM-dd HH:mm")} --- err {ermsg} ---");
wr.Flush();
@@ -56,26 +65,29 @@ namespace eDosStation
public void LogCommand(System.Data.SqlClient.SqlCommand co )
{
- wr.WriteLine($"-- {System.DateTime.Now.ToString("yyyy-MM-dd HH:mm")} ---");
- if (co.CommandType == System.Data.CommandType.StoredProcedure) wr.Write("exec ");
- wr.Write(co.CommandText);
- int paidx = 0;
- foreach (System.Data.SqlClient.SqlParameter pa in co.Parameters)
+ if (wr != null)
{
- if (paidx++ > 0) wr.Write(",");
- wr.Write($" @{pa.ParameterName}=");
- if (pa.Value == DBNull.Value) wr.Write("null");
- else if (pa.DbType == System.Data.DbType.String) wr.Write($"'{pa.Value}'");
- else if (pa.DbType == System.Data.DbType.DateTime) wr.Write($"'{pa.Value:yyyyMMdd HH:mm}'");
- else if (pa.DbType == System.Data.DbType.Double)
+ wr.WriteLine($"-- {System.DateTime.Now.ToString("yyyy-MM-dd HH:mm")} ---");
+ if (co.CommandType == System.Data.CommandType.StoredProcedure) wr.Write("exec ");
+ wr.Write(co.CommandText);
+ int paidx = 0;
+ foreach (System.Data.SqlClient.SqlParameter pa in co.Parameters)
{
- wr.Write(((double)pa.Value).ToString("0.0",ci));
+ if (paidx++ > 0) wr.Write(",");
+ wr.Write($" @{pa.ParameterName}=");
+ if (pa.Value == DBNull.Value) wr.Write("null");
+ else if (pa.DbType == System.Data.DbType.String) wr.Write($"'{pa.Value}'");
+ else if (pa.DbType == System.Data.DbType.DateTime) wr.Write($"'{pa.Value:yyyyMMdd HH:mm}'");
+ else if (pa.DbType == System.Data.DbType.Double)
+ {
+ wr.Write(((double)pa.Value).ToString("0.0", ci));
+ }
+ else wr.Write(pa.Value);
}
- else wr.Write(pa.Value);
+ wr.WriteLine();
+ wr.WriteLine("----");
+ wr.Flush();
}
- wr.WriteLine();
- wr.WriteLine("----");
- wr.Flush();
}
}
}