using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; using Stone.WinBiz.BasicData; using Stone.Common; namespace Stone.WinModule.MyControl { public partial class MyBoardCell : UserControl { private DataSet dsData = null; #region 属性 [CategoryAttribute(""), DescriptionAttribute("获取或设置控件选择的值")] public DataSet Data { get { return dsData; } set { try { this.dsData = value; ShowText(); ShowBgColor(); } catch (Exception ex) { MyMessageBox.ShowErrorMessage(ex.Message); } } } #endregion #region 方法 private void ShowText() { if (dsData.Tables[0].Rows.Count > 0) { this.lblProductName.Text = ""; foreach (DataRow drData in dsData.Tables[0].Rows) { //this.lblProductName.Text += drData["ProductName"].ToString() + "\r\n"; this.lblProductName.Text += drData["CarModelName"].ToString() + "\r\n" + drData["ColorName"].ToString() + "\r\n"; this.lblProductName.Text += drData["Qty"].ToString() + " " + drData["Batch"].ToString(); this.lblProductName.Text += "\r\n"; if (drData["TrayCode"].ToString() != "") this.lblProductName.Text += drData["TrayCode"].ToString() + "\r\n"; if (drData["StockQty"] is DBNull) { } else { if (drData["StockQty"].ToString() != "0") { this.lblProductName.Text += "最大容量:" + drData["StockQty"].ToString() + "\r\n"; } } } } else { this.lblProductName.Text = ""; } } private void ShowBgColor() { if (dsData != null & dsData.Tables[0].Rows.Count > 0) { string TrayCode = dsData.Tables[0].Rows[0]["TrayCode"].ToString(); if ( TrayCode == "") { if (Convert.ToInt32(dsData.Tables[0].Rows[0]["Qty"]) < Convert.ToInt32(dsData.Tables[0].Rows[0]["StockQty"])) { this.BackColor = Color.Yellow; } else { this.BackColor = Color.Red; this.lblProductName.ForeColor = Color.White; } } else { this.BackColor = Color.Red; this.lblProductName.ForeColor = Color.White; } } else { this.BackColor = Color.Green; } } #endregion #region 界面调整 public MyBoardCell() { InitializeComponent(); this.Dock = DockStyle.Fill; this.Padding = new Padding(0, 0, 0, 0); } private void MyBoardCell_Resize(object sender, EventArgs e) { this.lblProductName.Width = this.Width - this.lblProductName.Left; } #endregion private void lblProductName_MouseHover(object sender, EventArgs e) { ToolTip toolTip1 = new ToolTip(); toolTip1.AutoPopDelay = 5000; toolTip1.InitialDelay = 1000; toolTip1.ReshowDelay = 500; toolTip1.ShowAlways = true; toolTip1.SetToolTip(this.lblProductName, this.lblProductName.Text); } } }