using System; using System.Collections.Generic; using System.Windows.Forms; 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 = ElectricalPlc.UpFromPlc(id); if (null != view) { this.Speed.Text = view.Speed.ToString(); this.Speed.Enabled = false; } } 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; } ElectricalView view = new ElectricalView(); view.Id = _id; view.Speed = Convert.ToSingle(speed); ElectricalPlc.DownToPlc(new List() { view }); } } }