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; } ProportionalSettingView view = new ProportionalSettingView(); view.Id = _id; view.SV = Convert.ToSingle(sv); ProportionalPlc.DownToPlc(new []{view}); } } }