/// <summary>app
/// 數據源ide
/// </summary>this
private DataTable g_dtSource = new DataTable();編碼
#region InitGrid 初始化Grid標題信息string
/// <summary>it
/// 初始化Grid標題信息io
/// </summary>class
private void InitGrid()object
{循環
this.g_dtSource.Clear();
this.g_dtSource.Columns.Add("DeviceCode", typeof(string)).ReadOnly = true;
this.g_dtSource.Columns.Add("SlotName", typeof(string)).ReadOnly = true;
this.g_dtSource.Columns.Add("MitemCode", typeof(string)).ReadOnly = true;
this.g_dtSource.Columns.Add("LoadStatus", typeof(string)).ReadOnly = true;
this.dgInfo.DataSource = this.g_dtSource;
DataGridTableStyle dgtStyle = new DataGridTableStyle();
if (this.dgInfo.TableStyles.Count == 0)
{
this.dgInfo.TableStyles.Add(dgtStyle);
dgtStyle.GridColumnStyles[0].HeaderText = "設備";
dgtStyle.GridColumnStyles[0].MappingName = "DeviceCode";
dgtStyle.GridColumnStyles[0].NullText = "";
dgtStyle.GridColumnStyles[0].Width = 50;
dgtStyle.GridColumnStyles[1].HeaderText = "棧位";
dgtStyle.GridColumnStyles[1].MappingName = "SlotName";
dgtStyle.GridColumnStyles[1].NullText = "";
dgtStyle.GridColumnStyles[1].Width = 60;
dgtStyle.GridColumnStyles[2].HeaderText = "物料編碼";
dgtStyle.GridColumnStyles[2].MappingName = "MitemCode";
dgtStyle.GridColumnStyles[2].NullText = "";
dgtStyle.GridColumnStyles[2].Width = 60;
dgtStyle.GridColumnStyles[3].HeaderText = "上料狀態";
dgtStyle.GridColumnStyles[3].MappingName = "LoadStatus";
dgtStyle.GridColumnStyles[3].NullText = "";
dgtStyle.GridColumnStyles[3].Width = 60;
}
}
#endregion
#region 選中整行
private void dgInfo_CurrentCellChanged(object sender, EventArgs e)
{
this.dgInfo.Select(this.dgInfo.CurrentRowIndex);
}
#endregion
//循環處理
for (int i = 0; i < this.g_dtSource.Rows.Count; i++)
{
if (this.g_dtSource.Rows[i]["SlotName"].ToString() == SloatName)
{
bSloatName = true;
currMitemCode = this.g_dtSource.Rows[i]["MitemCode"].ToString();
//bool bEqualMitemCode = false;
//bEqualMitemCode = this.txtMitem.Text.IndexOf(currMitemCode) > 0; 不能確認是這樣
//當前棧位的物料 是否 與掃描的物料的UID 一致
if (ScanMitemCode == currMitemCode)
//if (bEqualMitemCode)
{
//匹配成功修改成Y
this.g_dtSource.Columns["LoadStatus"].ReadOnly = false;
this.g_dtSource.Rows[i]["LoadStatus"] = "Y";
this.dgInfo.Select(i); //設置選中
this.txtMitem.Text = "";
this.txtSloatName.Text = "";
this.txtMitem.Focus();
}
else
{
this.txtMitem.SelectAll();
this.SetMsg("上料表的物料和料盤的物料不一致!", Color.Red);
break;
//return;
}
}
if (this.g_dtSource.Rows[i]["LoadStatus"].ToString() == "Y")
{
iFinishCnt++;
}
}