|
|
@@ -47,6 +47,8 @@ namespace UAS_MES.Packing
|
|
|
|
|
|
string recordSW = ""; //存标准重量
|
|
|
string recordEV = "";//存误差值
|
|
|
+
|
|
|
+ bool isKg = false;//记录单位是否KG
|
|
|
public Packing_ProdWeightSet()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
@@ -183,8 +185,16 @@ namespace UAS_MES.Packing
|
|
|
}
|
|
|
sum = sum / weights.Count;
|
|
|
//更新彩盒重量最大值最小值
|
|
|
- dh.ExecuteSql("update product set PR_COLORBOXMAXW ='"+(sum+double.Parse(errorValue.Text))+"', PR_COLORBOXMINW = '"+ (sum - double.Parse(errorValue.Text)) + "',PR_COLORBOXUNIT='"+pr_cartonunit.Text+"' where pr_code='" + pr_code.Text+"'", "update");
|
|
|
- OperateResult.AppendText("<<重量设置成功,最大值"+ (sum + double.Parse(errorValue.Text)) + ",最小值"+ (sum - double.Parse(errorValue.Text)) + "\n", Color.Green);
|
|
|
+ if (isKg)
|
|
|
+ {
|
|
|
+ dh.ExecuteSql("update product set PR_COLORBOXMAXW ='" + (sum + double.Parse(errorValue.Text))/1000 + "', PR_COLORBOXMINW = '" + (sum - double.Parse(errorValue.Text))/1000 + "',PR_COLORBOXUNIT='" + pr_cartonunit.Text + "' where pr_code='" + pr_code.Text + "'", "update");
|
|
|
+ OperateResult.AppendText("<<重量设置成功,最大值" + (sum + double.Parse(errorValue.Text))/1000 + "kg,最小值" + (sum - double.Parse(errorValue.Text))/1000 + "kg\n", Color.Green);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dh.ExecuteSql("update product set PR_COLORBOXMAXW ='" + (sum + double.Parse(errorValue.Text)) + "', PR_COLORBOXMINW = '" + (sum - double.Parse(errorValue.Text)) + "',PR_COLORBOXUNIT='" + pr_cartonunit.Text + "' where pr_code='" + pr_code.Text + "'", "update");
|
|
|
+ OperateResult.AppendText("<<重量设置成功,最大值"+ (sum + double.Parse(errorValue.Text)) + "g,最小值"+ (sum - double.Parse(errorValue.Text)) + "g\n", Color.Green);
|
|
|
+ }
|
|
|
//更新采样记录表
|
|
|
string serialNum = dh.GetSerialNumberByCaller("ProdWeightSample");
|
|
|
sql.Clear();
|
|
|
@@ -255,6 +265,16 @@ namespace UAS_MES.Packing
|
|
|
|
|
|
private void ma_code_UserControlTextChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
+ //赋值
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("select ma_code,pr_code,pr_detail,pr_spec,ma_qty from make left join product on ma_prodcode=pr_code ");
|
|
|
+ sql.Append("where ma_code='" + ma_code.Text + "'");
|
|
|
+ Dbfind = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
+ if (Dbfind.Rows.Count == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BaseUtil.SetFormValue(this.Controls, Dbfind);
|
|
|
//清空称量记录
|
|
|
showResult.Items.Clear();
|
|
|
indates.Clear();
|
|
|
@@ -279,26 +299,6 @@ namespace UAS_MES.Packing
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void pr_detail_TextChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- //产品更换的时候
|
|
|
- DataTable d = (DataTable)dh.ExecuteSql("select PR_COLORBOXMAXW,PR_COLORBOXMINW from product where pr_code='"+pr_code.Text+"'","select");
|
|
|
- //给标准重量赋值
|
|
|
- if (d.Rows[0]["PR_COLORBOXMAXW"].ToString() == "" || d.Rows[0]["PR_COLORBOXMINW"].ToString() == "")
|
|
|
- {
|
|
|
- standardWeight.Text = 0 + "";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //取二者平均值来
|
|
|
- standardWeight.Text = (double.Parse(d.Rows[0]["PR_COLORBOXMAXW"].ToString())+ double.Parse(d.Rows[0]["PR_COLORBOXMINW"].ToString()))/2+"";
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void standardWeight_TextChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
private void standardWeight_Leave(object sender, EventArgs e)
|
|
|
{
|
|
|
//在采样的时候不能更改
|
|
|
@@ -335,25 +335,28 @@ namespace UAS_MES.Packing
|
|
|
recordEV = errorValue.Text;
|
|
|
}
|
|
|
|
|
|
- private void ma_code_KeyDown(object sender, KeyEventArgs e)
|
|
|
+ private void pr_code_TextChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
- if (e.KeyCode==Keys.Enter)
|
|
|
+ //产品更换的时候
|
|
|
+ DataTable d = (DataTable)dh.ExecuteSql("select PR_COLORBOXMAXW,PR_COLORBOXMINW,PR_COLORBOXUNIT from product where pr_code='" + pr_code.Text + "'", "select");
|
|
|
+ isKg = false;
|
|
|
+ //给标准重量赋值
|
|
|
+ if (d.Rows[0]["PR_COLORBOXMAXW"].ToString() == "" || d.Rows[0]["PR_COLORBOXMINW"].ToString() == "")
|
|
|
{
|
|
|
- //赋值
|
|
|
- sql.Clear();
|
|
|
- sql.Append("select ma_code,pr_code,pr_detail,pr_spec,ma_qty from make left join product on ma_prodcode=pr_code ");
|
|
|
- sql.Append("where ma_code='" + ma_code.Text + "'");
|
|
|
- Dbfind = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
- if (Dbfind.Rows.Count==0)
|
|
|
+ standardWeight.Text = 0 + "";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //取二者平均值来
|
|
|
+ standardWeight.Text = (double.Parse(d.Rows[0]["PR_COLORBOXMAXW"].ToString()) + double.Parse(d.Rows[0]["PR_COLORBOXMINW"].ToString())) / 2 + "";
|
|
|
+ if (d.Rows[0]["PR_COLORBOXUNIT"].ToString()=="kg")
|
|
|
{
|
|
|
- return;
|
|
|
+ isKg = true;
|
|
|
+ standardWeight.Text = double.Parse(standardWeight.Text) * 1000 + "";
|
|
|
}
|
|
|
- BaseUtil.SetFormValue(this.Controls, Dbfind);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- private void pr_code_TextChanged(object sender, EventArgs e)
|
|
|
- {
|
|
|
+ //取误差值
|
|
|
+ errorValue.Text = dh.GetConfig("prodWeightErrorValue", "MESSetting").ToString();
|
|
|
//查询重量设置采样个数
|
|
|
try
|
|
|
{
|