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/LjDry/UpAction.cs

52 lines
1.7 KiB
C#

using System;
using System.Linq;
using System.Windows.Forms;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.LjElectrical;
using Mesnac.Action.ChemicalWeighing.LjMaterial;
namespace Mesnac.Action.ChemicalWeighing.LjDry
{
public class UpAction:ChemicalWeighingAction, IAction
{
private RuntimeParameter _runtime;
public static event EventHandler OnHandler;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
this._runtime = runtime;
DbMCControl materialGridControl =
this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "DrySetting")
.FirstOrDefault(); //获取物料数据控件
if (MessageBox.Show("确定上传到数据库?","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Information) == DialogResult.OK)
{
DoWord();
};
}
private void DoWord()
{
var view = DryPlc.UpFromPlc();
foreach (var v in view)
{
string sql =
$"update DrySetting set Speed={v.Speed},Model={v.Model},Status={v.Status},Batch={v.Batch},Step={v.Step},StepCode={v.StepCode},TotalTime={v.TotalTime},StepTime={v.StepTime}" +
$" ,Temperature={v.Temperature} ,Currnet={v.Currnet}, Pressure={v.Pressure} " +
$" where Id={v.Id}";
DBHelp.ExecuteNonQuery(sql);
}
if (OnHandler != null)
{
OnHandler(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
}
}
}
}