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 DevComponents.DotNetBar; using DevComponents.DotNetBar.Layout; namespace WCS_Client.UC { public partial class FrmLEdit : Office2007Form { public FrmLEdit() { InitializeComponent(); ErrItem.BlinkStyle = ErrorBlinkStyle.BlinkIfDifferentError; } ErrorProvider ErrItem = new ErrorProvider(); List _LCItemList = new List(); public void InitFrm(List LCItemList) { _LCItemList = LCItemList; //LayoutControl添加控件 if (_LCItemList != null) { foreach (LayoutControlItem LocItem in _LCItemList) { this.layoutControl1.Controls.Add(LocItem.Control); this.layoutControl1.RootGroup.Items.Add(LocItem); } } } public void SetLCItemErr(LayoutControlItem LCItem, string ErrText) { if (LCItem == null || LCItem.Control == null) { return; } if (!string.IsNullOrEmpty(ErrText)) { LCItem.Control.Padding = new System.Windows.Forms.Padding(0, 0, 15, 0); LCItem.Control.Margin = new System.Windows.Forms.Padding(0, 0, 15, 0); } else { LCItem.Control.Padding = new System.Windows.Forms.Padding(0, 0, 0, 0); LCItem.Control.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0); } ErrItem.SetError(LCItem.Control, ErrText); } public void ClearLCItemErr() { ErrItem.Clear(); } public void SetLCItemErr(string LCName, string ErrText) { LayoutControlItem LCItem = GetLCItem(LCName); SetLCItemErr(LCItem, ErrText); } public List GetLCItemList() { return _LCItemList; } public LayoutControlItem GetLCItem(string LCName) { return _LCItemList.Find(a => a.Name == LCName); } public void ClearLCItemValue() { LCItemUtil.ClearValue_LCItem(_LCItemList); } public void LCItemIsEnable(string LCName, bool IsEnable) { LayoutControlItem item = GetLCItem(LCName); if (item == null || item.Control == null) { return; } item.Control.Enabled = IsEnable; } public void LCItemIsEnable(bool IsEnable) { foreach (LayoutControlItem item in _LCItemList) { if (item == null || item.Control == null) { continue; } item.Control.Enabled = IsEnable; } } public DataRow GetData() { DataTable dt = new DataTable(); foreach (LayoutControlItem Item in _LCItemList) { dt.Columns.Add(Item.Name, typeof(object)); } DataRow dr = dt.NewRow(); foreach (LayoutControlItem Item in _LCItemList) { dr[Item.Name] = LCItemUtil.GetValue_LCItem(Item); } return dr; } public void SetLCItemValue(DataRow dr) { foreach (LayoutControlItem Item in _LCItemList) { if (dr.Table.Columns.Contains(Item.Name)) { LCItemUtil.SetValue_LCItem(Item, dr[Item.Name]); } } } } }