init: 北航大学BH-DAS项目首次入库
This commit is contained in:
121
CCYQ_JieFang/OP/MeasureRangeSet.cs
Normal file
121
CCYQ_JieFang/OP/MeasureRangeSet.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using MesWork;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CCYQ_JieFang
|
||||
{
|
||||
public partial class MeasureRangeSet : Form
|
||||
{
|
||||
string currentOpName;
|
||||
object oldValue = null;
|
||||
public MeasureRangeSet(string opName)
|
||||
{
|
||||
currentOpName = opName;
|
||||
InitializeComponent();
|
||||
dataGridView1_part.AutoGenerateColumns = false;
|
||||
SearchPartInit(currentOpName);
|
||||
}
|
||||
|
||||
private void button1_search_Click(object sender, EventArgs e)
|
||||
{
|
||||
SearchPartInit(Name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void SearchPartInit(string opName)
|
||||
{
|
||||
try
|
||||
{
|
||||
SearchMeasureInfo(opName, out DataTable dt, out string errorMsg);
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
dataGridView1_part.DataSource = dt;
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private bool UpdateMeasureInfo(string ID, string upVlaue, string downVlaue, string unit, out string errorMsg)
|
||||
{
|
||||
string procedureName;
|
||||
procedureName = "基础数据_质量数据_编辑";
|
||||
SqlParameter[] thisParms = new SqlParameter[4];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@ID", ID);
|
||||
thisParms[1] = new System.Data.SqlClient.SqlParameter("@上限值", upVlaue);
|
||||
thisParms[2] = new System.Data.SqlClient.SqlParameter("@下限值", downVlaue);
|
||||
thisParms[3] = new System.Data.SqlClient.SqlParameter("@测量单位", unit);
|
||||
return publicCore.ExecuteStoredProcedure(procedureName, MesWorkForm.ConnectionString, ref thisParms, out errorMsg);
|
||||
}
|
||||
private bool SearchMeasureInfo(string opName, out DataTable dt, out string errorMsg)
|
||||
{
|
||||
string procedureName;
|
||||
procedureName = "基础数据_质量数据_查询";
|
||||
SqlParameter[] thisParms = new SqlParameter[1];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
|
||||
return publicCore.ExecuteStoredProcedure(procedureName, MesWorkForm.ConnectionString, ref thisParms, out dt, out errorMsg);
|
||||
}
|
||||
|
||||
private void dataGridView1_part_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
object newValue = dataGridView1_part.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
|
||||
if(oldValue != newValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
string ID = GetDgvSVal(e, "ID");
|
||||
string upVlaue = GetDgvSVal(e, "上限值");
|
||||
string downVlaue = GetDgvSVal(e, "下限值");
|
||||
|
||||
if (Convert.ToDouble(upVlaue) < Convert.ToDouble(downVlaue))
|
||||
{
|
||||
MessageBox.Show("上限值应大于下限值!");
|
||||
return;
|
||||
}
|
||||
|
||||
string unit = GetDgvSVal(e, "测量单位");
|
||||
if (UpdateMeasureInfo(ID, upVlaue, downVlaue, unit, out string errMsg))
|
||||
{
|
||||
MessageBox.Show("设置成功!");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("设置失败!");
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
MessageBox.Show("设置错误!");
|
||||
}
|
||||
SearchPartInit(currentOpName);
|
||||
}
|
||||
|
||||
}
|
||||
private string GetDgvSVal(DataGridViewCellEventArgs e, string cellName)
|
||||
{
|
||||
return ((DataTable)dataGridView1_part.DataSource).Rows[e.RowIndex][cellName].ToString();
|
||||
}
|
||||
|
||||
private void dataGridView1_part_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
||||
{
|
||||
MessageBox.Show(e.Exception.Message.ToString());
|
||||
}
|
||||
|
||||
private void dataGridView1_part_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
|
||||
{
|
||||
oldValue = dataGridView1_part.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user