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; using System.Collections; using CoreFS.CA06; namespace Core.LZMes.Client.UIM { public partial class UIM010041 : Form { public string YARD_ADDR = "";//垛位位置 private int areaType = 0; private int minRow = 1; private UIM010040 parent = null; public UIM010041() { InitializeComponent(); } public UIM010041(UIM010040 parent , int areaType) { InitializeComponent(); this.parent = parent; this.areaType = areaType; } private void label4_Click(object sender, EventArgs e) { YARD_ADDR = this.textBox1.Text.Trim().ToUpper(); if (null == YARD_ADDR || "".Equals(YARD_ADDR)) { MessageBox.Show("请输入需要入库的垛位!"); this.textBox1.Focus(); return; } parent.before_yard = YARD_ADDR; this.DialogResult = DialogResult.OK; this.Close(); } private void UIM010041_Load(object sender, EventArgs e) { ArrayList list = parent.queryYardAreas(areaType); int listSize = list.Count; Infragistics.Win.ValueListItem[] valueListItems = new Infragistics.Win.ValueListItem[listSize]; for (int i = 0; i < listSize; i++) { Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem(); Hashtable ht = (Hashtable)list[i]; item.DataValue = ((Hashtable)(ht["AREA_NO"]))["value"].ToString(); item.DisplayText = ht["AREA_NAME"].ToString(); valueListItems[i] = item; } this.ultraComboEditor1.Items.AddRange(valueListItems); this.ultraComboEditor1.SelectedIndex = 0; int areaNo = int.Parse(this.ultraComboEditor1.Value.ToString()); list = parent.queryYardColsByArea(areaNo); if (null != list) { listSize = list.Count; valueListItems = new Infragistics.Win.ValueListItem[listSize]; for (int i = 0; i < listSize; i++) { Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem(); Hashtable ht = (Hashtable)list[i]; item.DataValue = ht["CLF_COL"].ToString(); item.DisplayText = ht["CLF_COL"].ToString(); valueListItems[i] = item; } this.ultraComboEditor2.Items.AddRange(valueListItems); this.ultraComboEditor2.SelectedIndex = 0; this.DoQuery(); //查询出垛位区域 setYardInfo(); } this.textBox1.Text = parent.before_yard; } //private int areaType = 0; //private string yardCol = ""; ////private UIM010070 parent = null; /// /// 查询该行下垛位及钢卷信息 /// private void DoQuery() { int areaNo = int.Parse(this.ultraComboEditor1.Value.ToString()); string yardCol = this.ultraComboEditor2.Value.ToString(); parent.queryYardRows(areaType,areaNo, yardCol); parent.queryYardRowCoils(areaType,areaNo, yardCol); minRow = parent.queryMinYardRow(areaType, areaNo, yardCol); 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; foreach (Control control in panel5.Controls) { if (control.Name.Contains("textBox")) { ((TextBox)control).ReadOnly = true; control.Text = ""; control.DoubleClick += null; } else if (control.Name.Contains("pictureBox")) { ((PictureBox)control).BackColor = System.Drawing.SystemColors.InactiveBorder; //control.DoubleClick += null; } } for (int i = 0; i < drs.Count; i++) { string row_fl = (int.Parse(drs[i]["CLF_ROW"].ToString().Trim()) - minRow + 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_" + row_fl) || panel5.Controls[j].Name.Equals("pictureBox_" + row_fl)) { if (null == yardControl1) { yardControl1 = panel5.Controls[j]; } else { if (yardControl1.Name.Contains("textBox")) { setYardEnabled((PictureBox)panel5.Controls[j], (TextBox)yardControl1, drs[i]["CLF_ROW"].ToString().Trim(), drs[i]["CLF_FL"].ToString().Trim()); } else { setYardEnabled((PictureBox)yardControl1, (TextBox)panel5.Controls[j], drs[i]["CLF_ROW"].ToString().Trim(), drs[i]["CLF_FL"].ToString().Trim()); } break; } } } } } /// /// 激活垛位 /// /// /// /// private void setYardEnabled(PictureBox pictureBox, TextBox textBox, string row, string fl) { pictureBox.BackColor = System.Drawing.SystemColors.Window; textBox.ReadOnly = false; string clfRow = ""; string clfFl = ""; DataRowCollection drs = parent.dataSet2.Tables[0].Rows; for (int i = 0; i < drs.Count; i++) { clfRow = drs[i]["CLF_ROW"].ToString().Trim(); clfFl = drs[i]["CLF_FL"].ToString().Trim(); if (row.Equals(clfRow) && fl.Equals(clfFl)) { textBox.Text = drs[i]["COIL_NO"].ToString().Trim(); break; } } //pictureBox.DoubleClick += new EventHandler(pictureBox_doubleClick); textBox.DoubleClick += new EventHandler(textBox_doubleClick); } private void pictureBox_doubleClick(object sender, EventArgs e) { PictureBox picBox = (PictureBox)sender; string row_fl = picBox.Name.Split(new Char[] { '_' })[1]; setYardAddr(row_fl); } private void textBox_doubleClick(object sender, EventArgs e) { TextBox txtBox = (TextBox)sender; string row_fl = txtBox.Name.Split(new Char[] { '_' })[1]; setYardAddr(row_fl); } private void setYardAddr(string row_fl) { string row = (int.Parse(row_fl.Substring(0, row_fl.Length - 1)) + minRow - 1).ToString(); if(row.Length < 2) { row = "0" + row; } string fl = row_fl.Substring(row_fl.Length - 1); string flFlag = ""; if (fl.Equals("2")) { flFlag = "B"; } else if (fl.Equals("3")) { flFlag = "C"; } else { flFlag = "A"; } this.textBox1.Text = this.ultraComboEditor2.Value.ToString() + flFlag + "-" + row;// +"-" + fl; } private void ultraComboEditor1_ValueChanged(object sender, EventArgs e) { int areaNo = int.Parse(this.ultraComboEditor1.Value.ToString()); this.ultraComboEditor2.Items.Clear(); ArrayList list = parent.queryYardColsByArea(areaNo); if (null != list) { int listSize = list.Count; Infragistics.Win.ValueListItem[] valueListItems = new Infragistics.Win.ValueListItem[listSize]; for (int i = 0; i < listSize; i++) { Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem(); Hashtable ht = (Hashtable)list[i]; item.DataValue = ht["CLF_COL"].ToString(); item.DisplayText = ht["CLF_COL"].ToString(); valueListItems[i] = item; } this.ultraComboEditor2.Items.AddRange(valueListItems); this.ultraComboEditor2.SelectedIndex = 0; this.DoQuery(); } } private void ultraComboEditor2_ValueChanged(object sender, EventArgs e) { this.DoQuery(); setYardInfo(); } } }