恒石成品库WCS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

914 lines
32 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Windows.Forms;
using DBFactory;
namespace CommonClassLib
{
public partial class UCellPanel : UserControl
{
#region 变量定义
DBOperator dbo = new DBOperator();
//最大尺寸
int bigWidth = 20;
int bigHeight =20 ;
//传递的参数
Form parentForm;
Control controlCellCode;
Control controlShow;
Control controlBarCode;
int taskType = -1;
DataTable tableCellALLList;
DataTable tableCellInfoList; //V_CellInfoList
DataTable tableLines; //获取cmbLines的DataSource
List<Rectangle> listRecCell = new List<Rectangle>(); //存储绘制货格
List<string> listCellCode = new List<string>(); //存储货格货位编码
List<int> listCellID = new List<int>(); //存储货位的FID
int cellID = -1; //ST_CELL表中的FID
string goodsName; //货物名称
#region -------绘图常量
private const int tickFontSpac = 10; //绘制坐标时边界
private const int tickTopBounds = 20; //顶端边界
private const int tickBottomBounds = 30; //底部边界
private const int tickLeftBounds = 60; //左边界
private const int tickRightBounds = 10; //右端边界
private const int tickScroll = 15; //滚动条高度
private const int tickClearance = 3; //货格间隙
private Font fontCoordinate; //绘制坐标的字体
#endregion
#region -------绘图变量
private int intXMax, intYMax, intXMin, intYMin;
private Rectangle selectedRec; //当前选定的货位
private Rectangle drawedRec; //已经绘制的货位
SolidBrush brushSelectedRec = new SolidBrush(Color.FromArgb(80, Color.Transparent)); //选中货位的颜色
Color paintBorderColor = Color.Navy; //绘图面板边框颜色
string stackDevice = string.Empty; //堆垛机设备编号
string laneway = string.Empty;
string wareHouse = string.Empty; //选择的仓库
string wareHouseDescription = string.Empty; //仓库的名称
private int selectedZ; //选择的列
private string selectedCellCode = string.Empty; //选择的货位的名称
private int selectedCellStatus; //选择的货位存储状态
private int selectedRunStatus; //选择的货位运行状态
private string BoxBarCode = string.Empty; //条码信息20110425
#endregion
#endregion
#region 属性
/// <summary>
/// 货物名称
/// </summary>
public string GoodsName
{
set { goodsName = value; }
}
/// <summary>
/// 仓库编码
/// </summary>
public string WareHouse
{
get { return this.wareHouse; }
set
{
this.wareHouse = value;
if (!this.DesignMode)
{
//object obj = bllOperation.GetSingle("FNAME", "T_ITEMWAREHOUSE", "FCODE = '" + value + "'");
//if (obj != null)
//{
cmbWareHouse.SelectedValue = value;
//wareHouseDescription = obj.ToString();
//}
}
}
}
/// <summary>
/// 堆垛机设备编号
/// </summary>
public string StackDevice
{
get { return stackDevice; }
set
{
stackDevice = value;
DataView dv = dbo.ExceSQL("SELECT min(F_Z) FROM ST_CELL WHERE (FStack = " + stackDevice + ")").Tables[0].DefaultView;
if (dv.Count > 0)
{
int a = 0;
if (int.TryParse(dv[0][0].ToString(), out a) == false)
{
SelectedZ = 0;
}
else
{
SelectedZ = Convert.ToInt32(dv[0][0]);
}
}
else
{
SelectedZ = 0;
}
}
}
/// <summary>
/// 巷道设备号
/// </summary>
public string Laneway
{
get { return laneway; }
set {
laneway = value;
DataView dv = dbo.ExceSQL("SELECT min(F_Z) FROM ST_CELL WHERE (Flaneway = " + laneway + ")").Tables[0].DefaultView;
if (dv.Count > 0)
{
if (Convert.ToString(dv[0][0]) == "")
{
SelectedZ = 0;
}
else
{
SelectedZ = Convert.ToInt32(dv[0][0]);
}
}
}
}
/// <summary>
/// 承载返回数据的控件
/// </summary>
public Control ControlCellCode
{
get { return controlCellCode; }
set { controlCellCode = value; }
}
/// <summary>
/// 列
/// </summary>
public int SelectedZ
{
get { return this.selectedZ; }
set
{
if (!this.DesignMode)
{
this.selectedZ = value;
//初始化数据
InitDataTable();
this.cmbLine.Text = value.ToString();
//重新绘制
panelCell.Invalidate();
}
}
}
/// <summary>
/// 货位编码CellCode
/// </summary>
public string CellCode
{
get { return this.selectedCellCode.TrimEnd(); }
set
{
selectedCellCode = value;
}
}
/// <summary>
/// 货位索引
/// </summary>
public int CellID
{
get { return cellID; }
set { cellID = value; ShowCellInformation(); }
}
/// <summary>
/// 任务类型
/// </summary>
public string TaskType
{
set { taskType = Convert.ToInt32(value); }
}
private bool allowWareHouseChanged = false;
/// <summary>
/// 仓库是否可选
/// </summary>
public bool AllowWareHouseChanged
{
set { allowWareHouseChanged = value; cmbWareHouse.Enabled = allowWareHouseChanged; }
}
#endregion
#region 构造函数
public UCellPanel()
{
InitializeComponent();
//设置样式
panelCell.AutoScroll = true;
this.SetStyle(ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);
this.cmbLine.SelectionChangeCommitted += new EventHandler(cmbLine_SelectionChangeCommitted);
this.fontCoordinate = new Font("Tohoma", 9, FontStyle.Bold);
}
/// <summary>
/// 构造函数
/// </summary>
/// <param name="parent">父窗体</param>
/// <param name="control">关联控件</param>
/// <param name="type">调度任务类型ManageType</param>
/// <param name="where">筛选条件</param>
public UCellPanel(Form parent, Control control, Control ctrlShow,Control ctrlBarCode, string where)
: this()
{
this.parentForm = parent;
controlCellCode = control;
controlShow = ctrlShow;
controlBarCode = ctrlBarCode;
//taskType = type;
//T_WAREHOUSE
DataTable tableWareHouse = dbo.ExceSQL("SELECT F_WarehouseIndex,F_Description FROM T_WAREHOUSE").Tables[0];
cmbWareHouse.DisplayMember = "F_Description";
cmbWareHouse.ValueMember = "F_WarehouseIndex";
cmbWareHouse.DataSource = tableWareHouse.DefaultView;
//初始化变量 货位 add for CATL YB2 调度存在多货位表时候初始化有问题
//for (int i = 1; i <=2; i++)
//{
// if (cmbWareHouse.SelectedValue != null)
// {
// //cmbWareHouse.SelectedValue.ToString();
// WareHouse = i.ToString();
// SelectedZ = 1;
// }
//}
//if (cmbWareHouse.SelectedValue != null)
//{
// WareHouse = cmbWareHouse.SelectedValue.ToString();
// SelectedZ = 1;
//}
// add for CATL YB5
if (cmbWareHouse.SelectedValue != null)
{
WareHouse = cmbWareHouse.SelectedValue.ToString();
SelectedZ = 1;
}
//if (cmbWareHouse.SelectedValue != null)
//{
// WareHouse = cmbWareHouse.SelectedValue.ToString();
// if (WareHouse == "1")
// {
// SelectedZ = 5;
// }
// else
// {
// SelectedZ = 1;
// }
//}
}
#endregion
#region 初始化数据
/// <summary>
/// 初始化数据
/// </summary>
private void InitDataTable()
{
string strstack = "";
if (StackDevice != string.Empty)
{
strstack = " and FStack=" + StackDevice + " ";
}
string strlaneway = "";
if (laneway != string.Empty)
{
strlaneway = " and FLaneway=" + laneway + " ";
}
//st_Cell 的列值
tableLines = dbo.ExceSQL("SELECT DISTINCT F_Z FROM ST_CELL WHERE FWAREHOUSE = '" + this.wareHouse + "' " + strstack + strlaneway + " ORDER BY F_Z").Tables[0];
cmbLine.DisplayMember = "F_Z";
cmbLine.DataSource = this.tableLines;
//add for CATL YB6 货位BUG
//DataView dvZZ = dbo.ExceSQL("SELECT min(F_Z) FROM ST_CELL WHERE (FWAREHOUSE = " + this.wareHouse + ")").Tables[0].DefaultView;
//if (dvZZ.Count > 0)
//{
// selectedZ = Convert.ToInt32(dvZZ[0][0]);
//}
//ST_Cell
tableCellInfoList = dbo.ExceSQL("SELECT * FROM ST_CELL WHERE ST_CELL.FWAREHOUSE = '" + this.wareHouse + "' AND F_Z = '" + selectedZ + "' ORDER BY F_X,F_Y DESC").Tables[0];
int count = tableCellInfoList.Rows.Count;
//初始化最大值
InitMaxSet();
//选中货位为空
selectedRec = Rectangle.Empty;
}
//获取最大的行,列数,以设置滚动条
private void InitMaxSet()
{
DataView dv = dbo.ExceSQL("SELECT MAX(F_X) FROM ST_CELL WHERE FWAREHOUSE = '" + wareHouse + "' ").Tables[0].DefaultView;
if (dv.Count > 0)
{
intXMax =Convert.ToInt32( dv[0][0]);
}
dv = dbo.ExceSQL("SELECT MAX(F_Y) FROM ST_CELL WHERE FWAREHOUSE = '" + wareHouse + "'").Tables[0].DefaultView;
if (dv.Count > 0)
{
intYMax = Convert.ToInt32(dv[0][0]);
}
dv = dbo.ExceSQL("SELECT MIN(F_X) FROM ST_CELL WHERE FWAREHOUSE = '" + wareHouse + "'").Tables[0].DefaultView;
if (dv.Count > 0)
{
intXMin = Convert.ToInt32(dv[0][0]);
}
dv = dbo.ExceSQL("SELECT MIN(F_Y) FROM ST_CELL WHERE FWAREHOUSE = '" + wareHouse + "' ").Tables[0].DefaultView;
if (dv.Count > 0)
{
intYMin = Convert.ToInt32(dv[0][0]);
}
//滚动条设置
panelCell.AutoScrollMinSize = new Size((Convert.ToInt32(bigWidth) + 2 * tickClearance) * (intXMax - intXMin + 1) + tickLeftBounds + 2 * tickClearance + tickFontSpac + tickScroll, (Convert.ToInt32(bigHeight) + 2 * tickClearance) * (intYMax - intYMin + 1) + 3 * tickTopBounds);
}
#endregion
#region ComboBox SeletedValueChanged改变列
/// <summary>
/// 选择仓库
/// </summary>
private void cmbWareHouse_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbWareHouse.SelectedValue != null)
{
wareHouse = cmbWareHouse.SelectedValue.ToString();
DataView dv = dbo.ExceSQL("SELECT F_Description FROM T_WAREHOUSE WHERE F_WarehouseIndex = '" + wareHouse+ "'").Tables[0].DefaultView;
if (dv.Count > 0)
{
wareHouseDescription = dv[0]["F_Description"].ToString();
}
}
SelectedZ = 1;
}
/// <summary>
/// ComboBox SeletedValueChanged改变列
/// </summary>
private void cmbLine_SelectionChangeCommitted(object sender, EventArgs e)
{
SetBeginData();
SelectedZ = Convert.ToInt32(this.cmbLine.Text);
}
/// <summary>
/// 恢复初始化数据
/// </summary>
private void SetBeginData()
{
//初始化显示
panelCell.AutoScrollPosition = new Point(0, 0);
cellID = -1;
selectedCellCode = string.Empty;
BoxBarCode = string.Empty;
selectedRec = Rectangle.Empty;
drawedRec = Rectangle.Empty;
lblCellCode.Text = string.Empty;
lblCellStatus.Text = string.Empty;
lblRunStatus.Text = string.Empty;
lblBoxCode.Text = string.Empty;
txtCellCode.Clear();
}
#endregion
#region 绘制货位
/// <summary>
/// 绘制货位
/// </summary>
private void panelCell_Paint(object sender, PaintEventArgs e)
{
if (this.DesignMode)
return;
Graphics g = e.Graphics;
//g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
//设置滚动条
g.TranslateTransform(panelCell.AutoScrollPosition.X, panelCell.AutoScrollPosition.Y);
int minBottom = 0, maxRight = 0; //最大边缘记录
int nextPosition = tickTopBounds; //下一个绘图区域纵坐标位置
int currentPosition = 0; //当前位置
Rectangle cellPaint = Rectangle.Empty; //绘制的最大区域
Point p1, p2; //绘制坐标轴的点
Dictionary<int, int> paintArea = new Dictionary<int, int>(); //绘图区域的纵坐标位置
int x = 0, y = 0; //绘制货格坐标
int width = 0, height = 0; //绘制货格的长宽
//存储区域变量
int areaWith = 0; //货格区域的宽度
int areaHeight = 0; //货格区域的高度
string code; //货位编码
int i = 0, j = 0, k = 0; //索引
//char side = Char.MinValue; //双货位侧
//清空保存的记录
listCellCode.Clear();
listRecCell.Clear();
listCellID.Clear();
//绘制图形
foreach (DataRow rowCell in tableCellInfoList.Rows)
{
//货位编码
code = rowCell["FCELLCODE"].ToString().TrimEnd();
i = Convert.ToInt32(code.Split('-')[1]);
j = Convert.ToInt32(code.Split('-')[2]);
//根据货格规格设置区域尺寸
areaWith = bigWidth + 2 * tickClearance;
areaHeight = bigHeight + 2 * tickClearance;
#region -------计算区域
if (k == 0 || (k > 0 && code.Split('-').Length == 3) || (k > 0 && (code.Split('-').Length == 4) && listCellCode[k - 1].Substring(0, listCellCode[k - 1].Length - 2) != code.Substring(0, code.Length - 2)))
{
//计算当前位置和下一位置
if (paintArea.ContainsKey(j))
{
currentPosition = paintArea[j];
nextPosition = currentPosition + areaHeight;
}
else
{
currentPosition = nextPosition;
nextPosition = currentPosition + areaHeight;
//存储值对
paintArea[j] = currentPosition;
}
//当前区域坐标
x = tickLeftBounds + areaWith * (i - intXMin);
y = currentPosition;
//填充区域颜色
g.FillRectangle(new SolidBrush(Color.FromArgb(-8355585)), x, y, areaWith, areaHeight);
//计算货格
//width = Convert.ToInt32(rowCell["FWIDTH"].ToString());
//height = (Convert.ToInt32(rowCell["FCELLMODEL"]) == 2) ? Convert.ToInt32(rowCell["FLENGTH"].ToString()) + 2 * tickClearance : Convert.ToInt32(rowCell["FLENGTH"].ToString());
width = bigWidth;
height = bigHeight;
//坐标和记录矩形起始坐标
x += tickClearance;
y += tickClearance;
}
#endregion
#region ----判断货位规格--单货位还是双深货位
//存储绘制货位矩形和货位编码
listRecCell.Insert(k, new Rectangle(x, y, width, height));
listCellCode.Insert(k, code);
listCellID.Insert(k, Convert.ToInt32(rowCell["FID"]));
//填充货格背景颜色
g.FillRectangle(new SolidBrush(Color.Black), x, y, width + 1, height + 1);
//存储状态颜色
if (rowCell["FCELLSTATUS"].ToString().TrimEnd() == "1")//20110101
{
g.FillRectangle(new SolidBrush(Color.Navy), listRecCell[k]);
}
else
if (rowCell["FCELLSTATUS"].ToString().TrimEnd() == "0")//20110101
{
g.FillRectangle(new SolidBrush(Color.FromArgb(Convert.ToInt32(-12550016))), listRecCell[k]);
}
else//-1禁用
{
g.FillRectangle(new SolidBrush(Color.Red), listRecCell[k]);
}
//运行状态标示
if (rowCell["FRUNSTATUS"].ToString().TrimEnd() == "1")
{
g.DrawString("R", fontCoordinate, new SolidBrush(Color.Lime), x + width / 2 - 5, y + height / 2 - fontCoordinate.Height / 2);
}
else
{
g.DrawString("", fontCoordinate, new SolidBrush(Color.Black), x + width / 2 - 5, y + height / 2 - fontCoordinate.Height / 2);
}
#endregion
//计算最大边缘
if (intXMax == i && maxRight == 0)
maxRight = x + areaWith - tickLeftBounds - tickClearance;
if (intYMin == j && minBottom == 0)
minBottom = nextPosition - tickTopBounds;
//索引增加
k++;
//绘X坐标 经常需要调整的列坐标显示刻度
if (((i+1) % 5 == 0 && j == intYMin) || (i == intXMax - 1 && i > 5 && j == intYMin))
g.DrawString((i+1).ToString(), this.fontCoordinate, Brushes.Black, x + width / 2 - this.fontCoordinate.Height / 2 + width + 3, nextPosition + tickClearance + tickFontSpac);
//Y轴坐标
if ((j % 5 == 0 && i == intXMin) || (j == intYMax && j > 5 && i == intXMin))
g.DrawString(j.ToString(), this.fontCoordinate, Brushes.Black, tickLeftBounds - tickFontSpac - tickClearance - 3 * this.fontCoordinate.Height / 2, y + height / 2 - this.fontCoordinate.Height / 2);
}
#region ------绘制坐标轴和原点
//绘制绘图边框
cellPaint = new Rectangle(tickLeftBounds, tickTopBounds, maxRight, minBottom);
g.DrawRectangle(new Pen(paintBorderColor, 2), cellPaint);
//绘制X坐标轴
p1 = new Point(tickLeftBounds - tickFontSpac, cellPaint.Bottom + tickFontSpac);
p2 = new Point(cellPaint.Right + tickClearance + tickFontSpac, cellPaint.Bottom + tickFontSpac);
g.DrawLine(new Pen(Color.Black, 2), p1, p2);
//绘制箭头
g.DrawLine(new Pen(Color.Black, 1), p2, new Point(p2.X - tickClearance, p2.Y + tickClearance));
g.DrawLine(new Pen(Color.Black, 1), p2, new Point(p2.X - tickClearance, p2.Y - tickClearance));
//绘制Y坐标轴
p2 = new Point(tickLeftBounds - tickFontSpac, tickTopBounds - tickFontSpac);
g.DrawLine(new Pen(Color.Black, 2), p1, p2);
//绘制箭头
g.DrawLine(new Pen(Color.Black, 1), p2, new Point(p2.X - tickClearance, p2.Y + tickClearance));
g.DrawLine(new Pen(Color.Black, 1), p2, new Point(p2.X + tickClearance, p2.Y + tickClearance));
//绘制原点
p2 = new Point(tickLeftBounds - tickFontSpac - tickClearance - 3 * this.fontCoordinate.Height / 2, cellPaint.Bottom + tickFontSpac + tickClearance);
g.DrawString("O", new Font("Tohoma", 9, FontStyle.Bold | FontStyle.Italic), Brushes.Black, p2);
#endregion
//获得选定货位的绘制矩形大小
if (cellID != -1)
{
int index = listCellID.IndexOf(cellID);
if (index != -1)
selectedRec = listRecCell[index];
}
//突出显示选中的货位
DrawSelectedRectangel();
//释放
g.Dispose();
paintArea.Clear();
}
#endregion
#region Mouse Down Event
/// <summary>
/// 鼠标点击时显示货位信息
/// </summary>
private void panelCell_MouseClick(object sender, MouseEventArgs e)
{
foreach (Rectangle recCell in listRecCell)
{
if (recCell.Contains(e.X + Math.Abs(panelCell.AutoScrollPosition.X), e.Y + Math.Abs(panelCell.AutoScrollPosition.Y)))
{
//绘制样式
if (recCell != drawedRec)
{
//获得货位编码
int index = listRecCell.IndexOf(recCell);
selectedCellCode = listCellCode[index];
cellID = listCellID[index];
selectedRec = listRecCell[index];
//显示货位信息
ShowCellInformation();
//绘制样式
DrawSelectedRectangel();
}
break;
}
}
}
/// <summary>
/// 显示货位信息
/// </summary>
private void ShowCellInformation()
{
//货位编码
DataRow[] rows = tableCellInfoList.Select("FID = '" + cellID + "'");
if (rows.Length > 0)
{
//选择的货位的当前DataRow
DataRow row = rows[0];
//状态编码
selectedCellStatus = Convert.ToInt32(row["FCELLSTATUS"]);
selectedRunStatus = Convert.ToInt32(row["FRUNSTATUS"]);
//显示信息
this.lblCellCode.Text = row["FCELLCODE"].ToString();
this.lblBoxCode.Text = row["FPALLETBARCODE"].ToString();//20110425
lblCellStatus.Text = "";
lblRunStatus.Text = "";
}
}
/// <summary>
/// 绘制选定的货位样式
/// </summary>
private void DrawSelectedRectangel()
{
//判断是否重复位置
if (selectedRec == Rectangle.Empty || cellID == -1)
return;
//取消旧的选定样式
if (selectedRec != drawedRec && drawedRec != Rectangle.Empty)
panelCell.Invalidate(new Rectangle(drawedRec.X - Math.Abs(panelCell.AutoScrollPosition.X) - 1, drawedRec.Y - Math.Abs(panelCell.AutoScrollPosition.Y) - 1, drawedRec.Width + 2, drawedRec.Height + 2));
using (Graphics g = panelCell.CreateGraphics())
{
Rectangle recTrans = new Rectangle(selectedRec.X - Math.Abs(panelCell.AutoScrollPosition.X), selectedRec.Y - Math.Abs(panelCell.AutoScrollPosition.Y), selectedRec.Width, selectedRec.Height);
g.DrawRectangle(new Pen(Color.Red, 2), recTrans);
g.FillRectangle(brushSelectedRec, recTrans);
//重新记录绘制的货位
drawedRec = selectedRec;
//释放
g.Dispose();
}
}
#endregion
#region 鼠标双击时,传递货位
/// <summary>
/// 鼠标双击时,传递货位
/// </summary>
private void panelCell_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
return;
if (parentForm == null || controlCellCode == null)//20110425
return;
//重新选择货位
cellID = -1;
selectedCellCode = string.Empty;
selectedRec = Rectangle.Empty;
BoxBarCode = string.Empty;
foreach (Rectangle recCell in listRecCell)
{
if (recCell.Contains(e.X + Math.Abs(panelCell.AutoScrollPosition.X), e.Y + Math.Abs(panelCell.AutoScrollPosition.Y)))
{
//获得货位编码
int index = listRecCell.IndexOf(recCell);
selectedCellCode = listCellCode[index];
cellID = listCellID[index];
selectedRec = listRecCell[index];
DataRow[] rows = tableCellInfoList.Select("FID = '" + cellID + "'");
if (rows.Length > 0)
{
DataRow row = rows[0];
BoxBarCode = row["FPALLETBARCODE"].ToString();//20110425
}
break;
}
}
if (cellID == -1)
return;
//传递货位编码值
SetCellCode();
}
/// <summary>
/// 为控件传递货位编码
/// </summary>
private void SetCellCode()
{
if (controlCellCode.GetType() == typeof(TextBox))
{
TextBox textBox = controlCellCode as TextBox;
textBox.Text = selectedCellCode;
}
else if (controlCellCode.GetType() == typeof(ComboBox))
{
ComboBox comboBox = controlCellCode as ComboBox;
if (selectedCellCode != null)
{
//层列排代码
//string clpz = selectedCellCode.Substring(0, 2).ToString();//排
//string clpx = selectedCellCode.Substring(3, 2).ToString();//列
//string clpy = selectedCellCode.Substring(6,2).ToString();//层
//string yxz = (clpy + "-" + clpx + "-" + clpz).ToString();
//comboBox.Text = yxz;
comboBox.Text = selectedCellCode;
}
}
if (controlBarCode!=null)
{
if (controlBarCode.GetType() == typeof(TextBox))
{
TextBox textBox = controlBarCode as TextBox;
//if (BoxBarCode != "-")
//{
textBox.Text = BoxBarCode;
//}
}
else if (controlBarCode.GetType() == typeof(ComboBox))
{
ComboBox comboBox = controlBarCode as ComboBox;
//if (BoxBarCode!="-")
//{
comboBox.Text = BoxBarCode;
//}
}
}
//隐藏控件
if (controlShow != null)
{
if (controlShow.GetType() == typeof(SplitContainer))
{
SplitContainer splitContainer = controlShow as SplitContainer;
splitContainer.Panel1Collapsed = true;
}
}
//this.Hide();
//this.Parent.Visible = false;
}
#endregion
#region 搜索刷新
/// <summary>
/// 搜索
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnFind_Click(object sender, EventArgs e)
{
if (txtCellCode.Text == string.Empty)
return;
int index = listCellCode.IndexOf(txtCellCode.Text);
if (index == -1)
return;
//记录货位信息
selectedCellCode = txtCellCode.Text.TrimEnd();
cellID = listCellID[index];
//搜索指定货位
FindCell();
}
/// <summary>
/// 搜索指定货位
/// </summary>
private void FindCell()
{
if (cellID == -1)
return;
int index = listCellID.IndexOf(cellID);
if (index == -1)
return;
Rectangle recFind = listRecCell[index];
if (recFind != drawedRec)
{
selectedRec = recFind;
//显示货位信息
ShowCellInformation();
//绘制选定货位的样式
DrawSelectedRectangel();
}
//计算滚动值
int difX = (selectedRec.X - Math.Abs(panelCell.AutoScrollPosition.X)) - panelCell.AutoScrollPosition.X - panelCell.Width / 2;
int difY = (selectedRec.Y - Math.Abs(panelCell.AutoScrollPosition.Y)) - panelCell.AutoScrollPosition.Y - panelCell.Height / 2;
//设置滚动距离
panelCell.AutoScrollPosition = new Point(difX, difY);
}
/// <summary>
/// 响应回车键,进行搜索
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void txtCellCode_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
btnFind_Click(null, EventArgs.Empty);
}
}
/// <summary>
/// 刷新按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnUpdate_Click(object sender, EventArgs e)
{
if (cmbLine.Text == string.Empty)
return;
this.SelectedZ = int.Parse(cmbLine.Text);
//搜索指定货位
int index = listCellID.IndexOf(cellID);
if (index == -1)
return;
//记录货位信息
selectedCellCode = listCellCode[index];
FindCell();
}
#endregion
#region 取消选择或关闭
/// <summary>
/// 关闭或隐藏父控件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnHide_Click(object sender, EventArgs e)
{
this.Hide();
this.Parent.Visible = false;
}
#endregion
}
}