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/LjPressure/FrmPressureUpdate.cs

122 lines
3.2 KiB
C#

1 year ago
using System;
using System.Collections.Generic;
1 year ago
using System.Globalization;
1 year ago
using System.Linq;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
using Mesnac.Action.ChemicalWeighing.LjMaterial;
namespace Mesnac.Action.ChemicalWeighing.LjPressure
{
public partial class FrmPressureUpdate : Form
{
public FrmPressureUpdate()
{
InitializeComponent();
}
private int _id;
public FrmPressureUpdate(int id) : this()
{
1 year ago
11 months ago
1 year ago
1 year ago
_id = id;
IList<MyNameValue> ls = new List<MyNameValue>();
ls.Add(new MyNameValue()
{
Id = 1,Name = "超压",
});
ls.Add(new MyNameValue()
{
Id = 0,Name = "正常",
});
1 year ago
// this.Alarm.DataSource = ls;
// Alarm.ValueMember = "Id";
// Alarm.DisplayMember = "Name";
1 year ago
1 year ago
var i = LjHelp.WatchDog;
1 year ago
if (i == 0)
{
11 months ago
1 year ago
MessageBox.Show("PLC通讯失败");
return;
}
1 year ago
var v = PressurePLC.UpdateFromPlc(id);
if (null!=v)
1 year ago
{
1 year ago
this.LowLimit.Text = v.LowLimit.ToString(CultureInfo.InvariantCulture);
this.HighLimit.Text = v.HighLimit.ToString(CultureInfo.InvariantCulture);
1 year ago
1 year ago
// foreach (MyNameValue combo in Alarm.Items)
// {
// if (combo.Id == v.Alarm)
// {
// Alarm.SelectedItem = combo;
// Alarm.Enabled = false;
// break;
// }
// }
1 year ago
}
else
{
MessageBox.Show("获取PLC 异常请联系管理员");
}
1 year ago
11 months ago
1 year ago
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void Alarm_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void btnOK_Click(object sender, EventArgs e)
{
if (!float.TryParse(LowLimit.Text.Trim(), out float a))
{
LowLimit.Focus();
MessageBox.Show("请输入正确的数值");
return;
}
if (!float.TryParse(HighLimit.Text.Trim(), out float b))
{
HighLimit.Focus();
MessageBox.Show("请输入正确的数值");
return;
}
PressureSettingView view = new PressureSettingView()
{
Id = _id,
1 year ago
HighLimit =b,
1 year ago
LowLimit = a,
1 year ago
1 year ago
};
1 year ago
PressurePLC.DownToPlc(new List<PressureSettingView>()
{
view
});
string sql =
$"update PressureSetting set LowLimit={view.LowLimit},HighLimit={view.HighLimit} where Id={view.Id}";
DBHelp.ExecuteNonQuery(sql);
1 year ago
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
1 year ago
}
}