|
|
|
|
using System;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.LjMaterial;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.LjWeight
|
|
|
|
|
{
|
|
|
|
|
public partial class FrmWeight : Form
|
|
|
|
|
{
|
|
|
|
|
public FrmWeight()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int _id = 0;
|
|
|
|
|
|
|
|
|
|
public FrmWeight(int id) : this()
|
|
|
|
|
{
|
|
|
|
|
this._id = id;
|
|
|
|
|
SetUpdateFromPlc();
|
|
|
|
|
LowWeight.MaxLength = 5;
|
|
|
|
|
HighWeight.MaxLength = 5;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetUpdateFromPlc()
|
|
|
|
|
{
|
|
|
|
|
WeightSettingView view = WeightSettingPlc.UpFromPlc(_id);
|
|
|
|
|
this.HighWeight.Text = view.HighWeight.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
this.LowWeight.Text = view.LowWeight.ToString(CultureInfo.InvariantCulture);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string lowWeight = LowWeight.Text.Trim();
|
|
|
|
|
string highWeight = HighWeight.Text.Trim();
|
|
|
|
|
|
|
|
|
|
if (!float.TryParse(lowWeight, out var low))
|
|
|
|
|
{
|
|
|
|
|
LowWeight.Focus();
|
|
|
|
|
MessageBox.Show("请输入正确的低料位重量");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!float.TryParse(highWeight, out var high))
|
|
|
|
|
{
|
|
|
|
|
HighWeight.Focus();
|
|
|
|
|
MessageBox.Show("请输入正确的高料位重量");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WeightSettingView view = new WeightSettingView()
|
|
|
|
|
{
|
|
|
|
|
Id = _id,
|
|
|
|
|
HighWeight = high,
|
|
|
|
|
LowWeight = low
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
WeightSettingPlc.DownToPlc(new []{view});
|
|
|
|
|
//select Id,Name,ActWeight,HighLevel,HighWeight,LowLevel,LowWeight from WeightSetting
|
|
|
|
|
string sql =$"update WeightSetting set LowWeight={view.LowWeight},HighWeight={view.HighWeight} where Id={view.Id}";
|
|
|
|
|
DBHelp.ExecuteNonQuery(sql);
|
|
|
|
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void label1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|