You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPressure/UpAction.cs

48 lines
1.5 KiB
C#

1 year ago
using System;
using System.Linq;
using System.Windows.Forms;
1 year ago
using Mesnac.Action.Base;
1 year ago
using Mesnac.Action.ChemicalWeighing.LjMaterial;
1 year ago
namespace Mesnac.Action.ChemicalWeighing.LjPressure
{
public class UpAction:ChemicalWeighingAction, IAction
{
1 year ago
1 year ago
private RuntimeParameter _runtime;
1 year ago
public static event EventHandler OnHandler;
1 year ago
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
this._runtime = runtime;
DbMCControl materialGridControl =
this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "pressureSetting")
.FirstOrDefault(); //获取物料数据控件
1 year ago
1 year ago
if (MessageBox.Show("确定上传到数据库?","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Information) == DialogResult.OK)
{
DoWord();
};
}
private void DoWord()
{
var pressureSettingViews = PressurePLC.UpdateFromPlc();
foreach (var v in pressureSettingViews)
{
string sql =
$"update PressureSetting set LowLimit={v.LowLimit},HighLimit={v.HighLimit} where Id={v.Id}";
1 year ago
DBHelp.ExecuteNonQuery(sql);
}
if (OnHandler != null)
{
OnHandler(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
}
1 year ago
}
}
}