From ebb967706609a624baa8680c61c61daaf01bb8d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Mon, 29 Jan 2024 10:16:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E5=A4=A7=E4=BA=8E0=20=E6=89=8D=E5=BC=80=E5=A7=8B=E8=B7=9F?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OliveEQSetting/InItDbAction.cs | 52 +++++++++++++------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/OliveEQSetting/InItDbAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/OliveEQSetting/InItDbAction.cs index 2422943..61de016 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/OliveEQSetting/InItDbAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/OliveEQSetting/InItDbAction.cs @@ -153,9 +153,14 @@ namespace Mesnac.Action.ChemicalWeighing.OliveEQSetting foreach (var v in pressureSettingViews) { - string sql = - $"update PressureSetting set LowLimit={v.LowLimit},HighLimit={v.HighLimit} where Id={v.Id}"; - DBHelp.ExecuteNonQuery(sql); + + if(v.LowLimit>0 || v.HighLimit > 0) + { + string sql = + $"update PressureSetting set LowLimit={v.LowLimit},HighLimit={v.HighLimit} where Id={v.Id}"; + DBHelp.ExecuteNonQuery(sql); + } + } DataTable table = @@ -182,9 +187,13 @@ namespace Mesnac.Action.ChemicalWeighing.OliveEQSetting var views = ProportionalPlc.UpFromPlc(); foreach (var v in views) { - string sql = - $"update ProportionalSetting set SV={v.SV},PV={v.PV} where Id={v.Id}"; - DBHelp.ExecuteNonQuery(sql); + if(v.SV>0 || v.PV > 0) + { + string sql = + $"update ProportionalSetting set SV={v.SV},PV={v.PV} where Id={v.Id}"; + DBHelp.ExecuteNonQuery(sql); + } + } @@ -211,9 +220,13 @@ namespace Mesnac.Action.ChemicalWeighing.OliveEQSetting var views = WeightSettingPlc.UpFromPlc(); foreach (var v in views) { - string sql = - $"update WeightSetting set LowWeight={v.LowWeight},HighWeight={v.HighWeight} where Id={v.Id}"; - DBHelp.ExecuteNonQuery(sql); + if(v.LowWeight>0 || v.HighWeight > 0) + { + string sql = + $"update WeightSetting set LowWeight={v.LowWeight},HighWeight={v.HighWeight} where Id={v.Id}"; + DBHelp.ExecuteNonQuery(sql); + } + } DataTable table = @@ -238,9 +251,13 @@ namespace Mesnac.Action.ChemicalWeighing.OliveEQSetting var view = ElectricalPlc.UpFromPlc(); foreach (var v in view) { - string sql = - $"update ElectricalSetting set Speed={v.Speed} where Id={v.Id}"; - DBHelp.ExecuteNonQuery(sql); + if (v.Speed > 0) + { + string sql = + $"update ElectricalSetting set Speed={v.Speed} where Id={v.Id}"; + DBHelp.ExecuteNonQuery(sql); + } + } DataTable table = @@ -264,9 +281,14 @@ namespace Mesnac.Action.ChemicalWeighing.OliveEQSetting var view = MetagePlc.UpFromPlc(); foreach (var v in view) { - string sql = - $"update MetageSetting set HighSpeed={v.HighSpeed},LowSpeed={v.LowSpeed},WeightSlow={v.WeightSlow},Precut={v.Precut},JogTime={v.JogTime} where Id={v.Id}"; - DBHelp.ExecuteNonQuery(sql); + if(v.HighSpeed > 0 || v.LowSpeed>0 || v.WeightSlow>0 || v.Precut>0 || v.JogTime > 0) + { + string sql = + $"update MetageSetting set HighSpeed={v.HighSpeed},LowSpeed={v.LowSpeed}," + + $"WeightSlow={v.WeightSlow},Precut={v.Precut},JogTime={v.JogTime} where Id={v.Id}"; + DBHelp.ExecuteNonQuery(sql); + } + } DataTable table =