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.9 KiB
C#

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;
}
var watchDoy = LjHelp.WatchDog;
if (watchDoy == 0)
{
LoadingHelper.CloseForm();
MessageBox.Show("PLC通讯失败");
return;
}
ProportionalSettingView view = new ProportionalSettingView();
view.Id = _id;
view.SV = Convert.ToSingle(sv);
var i = BasePlcHelper.Instance.WatchDog.LastValue.ToInt();
if (i == 0)
{
LoadingHelper.CloseForm();
MessageBox.Show("PLC通讯失败");
return;
}
LoadingHelper.ShowLoadingScreen();
ProportionalPlc.DownToPlc(new []{view});
ProportionalDB.Update(view);
LoadingHelper.CloseForm();
this.DialogResult = DialogResult.OK;
}
}
}