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/LjProportional/FrmProportional.cs

73 lines
1.8 KiB
C#

1 year ago
using System;
using System.Globalization;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.LjProportional
{
public partial class FrmProportional : Form
{
public FrmProportional()
{
InitializeComponent();
}
private int _id = 0;
public FrmProportional(int id):this()
{
this._id = id;
SV.MaxLength = 5;
SV.Enabled = true;
var view = ProportionalPlc.UpFromPlc(id);
if (view != null)
{
SV.Text = view.SV.ToString(CultureInfo.InvariantCulture);
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnOK_Click(object sender, EventArgs e)
{
string sv = SV.Text.Trim();
if(!float.TryParse(sv,out var rs))
{
SV.Focus();
MessageBox.Show("请输入正确的值");
return;
}
1 year ago
var watchDoy = LjHelp.WatchDog;
if (watchDoy == 0)
{
11 months ago
1 year ago
MessageBox.Show("PLC通讯失败");
return;
}
1 year ago
ProportionalSettingView view = new ProportionalSettingView();
view.Id = _id;
view.SV = Convert.ToSingle(sv);
1 year ago
var i = LjHelp.WatchDog;
1 year ago
if (i == 0)
{
11 months ago
1 year ago
MessageBox.Show("PLC通讯失败");
return;
}
11 months ago
1 year ago
ProportionalPlc.DownToPlc(new []{view});
1 year ago
ProportionalDB.Update(view);
11 months ago
1 year ago
this.DialogResult = DialogResult.OK;
1 year ago
}
}
}