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 = LjHelp.WatchDog; if (i == 0) { LoadingHelper.CloseForm(); MessageBox.Show("PLC通讯失败"); return; } LoadingHelper.ShowLoadingScreen(); ProportionalPlc.DownToPlc(new []{view}); ProportionalDB.Update(view); LoadingHelper.CloseForm(); this.DialogResult = DialogResult.OK; } } }