using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Core.LZMes.Client.UIM
{
public partial class UIM010151 : Form
{
private int areaType = 0;
private int minCol = 1;
private string yardRow = "";
private UIM010150 parent = null;
public UIM010151()
{
InitializeComponent();
}
public UIM010151(UIM010150 parent,int areaType, string yardRow)
{
InitializeComponent();
this.areaType = areaType;
this.yardRow = yardRow;
this.parent = parent;
}
private void UIM010151_Load(object sender, EventArgs e)
{
this.DoQuery();
this.ultraTextEditor1.Text = yardRow;
setYardInfo();
}
///
/// 查询该行下垛位及钢卷信息
///
private void DoQuery()
{
parent.queryYardCols(areaType, yardRow);
parent.queryYardColCoils(areaType, yardRow);
minCol = parent.queryMinYardCol(areaType, yardRow);
this.ultraGrid1.DataSource = parent.dataSet2;
this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns[1].Hidden = true;
}
///
/// 将库存中存在的垛位激活
///
private void setYardInfo()
{
DataRowCollection drs = parent.dataSet3.Tables[0].Rows;
for (int i = 0; i < drs.Count; i++)
{
string col_fl = (int.Parse(drs[i]["CLF_COL"].ToString().Trim()) - minCol + 1).ToString() + drs[i]["CLF_FL"].ToString().Trim();
Control yardControl1 = null;
for (int j = 0; j < panel5.Controls.Count; j++)
{
if (panel5.Controls[j].Name.Equals("textBox_" + col_fl) || panel5.Controls[j].Name.Equals("pictureBox_" + col_fl))
{
if (null == yardControl1)
{
yardControl1 = panel5.Controls[j];
}
else
{
if (yardControl1.Name.Contains("textBox"))
{
setYardEnabled((PictureBox)panel5.Controls[j], (TextBox)yardControl1, drs[i]["CLF_COL"].ToString().Trim(), drs[i]["CLF_FL"].ToString().Trim());
}
else
{
setYardEnabled((PictureBox)yardControl1, (TextBox)panel5.Controls[j], drs[i]["CLF_COL"].ToString().Trim(), drs[i]["CLF_FL"].ToString().Trim());
}
break;
}
}
}
}
}
///
/// 激活垛位
///
///
///
///
private void setYardEnabled(PictureBox pictureBox,TextBox textBox,string col,string fl)
{
pictureBox.BackColor = System.Drawing.SystemColors.Window;
textBox.ReadOnly = false;
DataRowCollection drs = parent.dataSet2.Tables[0].Rows;
for (int i = 0; i < drs.Count; i++)
{
string clfCol = drs[i]["CLF_COL"].ToString().Trim();
string clfFl = drs[i]["CLF_FL"].ToString().Trim();
if (col.Equals(clfCol) && fl.Equals(clfFl))
{
textBox.Text = drs[i]["COIL_NO"].ToString().Trim();
break;
}
}
}
}
}