From 61239955b0ec7f5f7f2f6ceda91e9dab168d05ee Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 13 Jan 2022 16:53:39 +0100 Subject: [PATCH] Fix calcolo true/false ore lav OK --- GPW_Admin/BaseUserControl.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/GPW_Admin/BaseUserControl.cs b/GPW_Admin/BaseUserControl.cs index 76e2732..9a01361 100644 --- a/GPW_Admin/BaseUserControl.cs +++ b/GPW_Admin/BaseUserControl.cs @@ -208,7 +208,17 @@ namespace GPW_Admin public bool toBool(object valore) { bool answ = false; - bool.TryParse($"{valore}", out answ); + string strVal = $"{valore}"; + // se è lungh 1 (0/1) converto 0=false, 1 = true... + if (strVal.Length == 1) + { + answ = strVal == "1" ? true : false; + } + else + { + // se è un valore testuale --> converisone boolean + bool.TryParse($"{valore}", out answ); + } return answ; }