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/LjElectrical/FrmElectrical.cs

70 lines
1.9 KiB
C#

1 year ago
using System;
using System.Collections.Generic;
using System.Windows.Forms;
1 year ago
using Mesnac.Action.ChemicalWeighing.LjMaterial;
1 year ago
namespace Mesnac.Action.ChemicalWeighing.LjElectrical
{
public partial class FrmElectrical : Form
{
public FrmElectrical()
{
InitializeComponent();
}
private int _id;
public FrmElectrical(int id) : this()
{
this._id = id;
ElectricalView view = new ElectricalView();
view =new ElectricalPlc().UpFromPlc(id);
1 year ago
if (null != view)
{
this.Speed.Text = view.Speed.ToString();
1 year ago
this.Speed.Enabled = true;
1 year ago
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnOK_Click(object sender, EventArgs e)
{
var speed = Speed.Text.Trim();
if (!float.TryParse(speed, out var sp))
{
Speed.Focus();
MessageBox.Show("请输入正确的值");
return;
}
1 year ago
11 months ago
1 year ago
var watchDog = LjHelp.WatchDog;
if (watchDog == 0)
{
11 months ago
1 year ago
MessageBox.Show("PLC通讯失败");
return;
}
1 year ago
ElectricalView view = new ElectricalView();
view.Id = _id;
view.Speed = Convert.ToSingle(speed);
new ElectricalPlc().DownToPlc(new List<ElectricalView>()
1 year ago
{
view
});
1 year ago
//select Id, Name, Speed from ElectricalSetting
string sql = $"update ElectricalSetting set Speed={view.Speed} where id={view.Id}";
DBHelp.ExecuteNonQuery(sql);
11 months ago
1 year ago
this.DialogResult = DialogResult.OK;
1 year ago
}
}
}