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.
202 lines
6.1 KiB
C#
202 lines
6.1 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using Mesnac.Action.ChemicalWeighing.LjMaterial;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.LjStock
|
|
{
|
|
public partial class FrmStock : Form
|
|
{
|
|
public FrmStock()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private StockView viewl;
|
|
public FrmStock(StockView view) : this()
|
|
{
|
|
this.viewl = view;
|
|
Init();
|
|
}
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void Init()
|
|
{
|
|
var nameValueCollection = MaterialInfoTypeHelp.GetALL();
|
|
this.comboBox1.DataSource = nameValueCollection;
|
|
comboBox1.ValueMember = "Id";
|
|
comboBox1.DisplayMember = "Name";
|
|
foreach (MyNameValue combo in comboBox1.Items)
|
|
{
|
|
if (combo.Id == viewl.MTypeId)
|
|
{
|
|
comboBox1.SelectedItem = combo;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (null != viewl)
|
|
{
|
|
this.TankCode.Text = viewl.Code;
|
|
this.TankName.Text = viewl.StockName;
|
|
this.High.Text = viewl.High.ToString();
|
|
this.Slow.Text = viewl.Slow.ToString();
|
|
this.SlowScale.Text = viewl.SlowScale.ToString();
|
|
this.Lead.Text = viewl.Lead.ToString();
|
|
this.Jog.Text = viewl.Jog.ToString();
|
|
}
|
|
}
|
|
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
{
|
|
#region check
|
|
|
|
if (string.IsNullOrEmpty(High.Text.Trim()))
|
|
{
|
|
High.Focus();
|
|
MessageBox.Show("请输入高速称量速度");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if (float.TryParse(High.Text.Trim(),out float a))
|
|
{
|
|
if (a < 0 || a > 50)
|
|
{
|
|
High.Focus();
|
|
MessageBox.Show("请输入正确高速称量速度[0.0~50.0]");
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
High.Focus();
|
|
MessageBox.Show("请输入正确高速称量速度[0.0~50.0]");
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(Slow.Text.Trim()))
|
|
{
|
|
Slow.Focus();
|
|
MessageBox.Show("请输入慢速称量速度");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if (float.TryParse(Slow.Text.Trim(),out float b))
|
|
{
|
|
if (b < 0 || b > 50)
|
|
{
|
|
Slow.Focus();
|
|
MessageBox.Show("请输入正确低速称量速度[0.0~50.0]");
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Slow.Focus();
|
|
MessageBox.Show("请输入正确低速称量速度[0.0~50.0]");
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(SlowScale.Text.Trim()))
|
|
{
|
|
SlowScale.Focus();
|
|
MessageBox.Show("请输入慢称值");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if (float.TryParse(SlowScale.Text.Trim(),out float b))
|
|
{
|
|
if (b < 0 || b > 10)
|
|
{
|
|
SlowScale.Focus();
|
|
MessageBox.Show("请输入正确低速称量速度[0.0~10.0]");
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SlowScale.Focus();
|
|
MessageBox.Show("请输入正确低速称量速度[0.0~10.0]");
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(Lead.Text.Trim()))
|
|
{
|
|
Lead.Focus();
|
|
MessageBox.Show("请输入提前量");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if (float.TryParse(Lead.Text.Trim(),out float b))
|
|
{
|
|
if (b < 0 || b > 10)
|
|
{
|
|
Lead.Focus();
|
|
MessageBox.Show("请输入正确低速称量速度[0.0~10.0]");
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Lead.Focus();
|
|
MessageBox.Show("请输入正确低速称量速度[0.0~10.0]");
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(Jog.Text.Trim()))
|
|
{
|
|
Jog.Focus();
|
|
MessageBox.Show("请输入点动值");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if (float.TryParse(Lead.Text.Trim(),out float b))
|
|
{
|
|
if (b < 0 || b > 20)
|
|
{
|
|
Jog.Focus();
|
|
MessageBox.Show("请输入正确低速称量速度[0.0~20.0]");
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Jog.Focus();
|
|
MessageBox.Show("请输入正确低速称量速度[0.0~20.0]");
|
|
return;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
viewl.MTypeId = Convert.ToInt32(this.comboBox1.SelectedValue);
|
|
viewl.High = Convert.ToSingle(High.Text);
|
|
viewl.Slow = Convert.ToSingle(Slow.Text);
|
|
viewl.SlowScale = Convert.ToSingle(SlowScale.Text);
|
|
viewl.Lead = Convert.ToSingle(Lead.Text);
|
|
viewl.Jog = Convert.ToSingle(Jog.Text);
|
|
|
|
|
|
StockDbHelp.Update(viewl);
|
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
|
}
|
|
}
|
|
} |