FrmLEdit.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using DevComponents.DotNetBar;
  10. using DevComponents.DotNetBar.Layout;
  11. namespace WCS_Client.UC
  12. {
  13. public partial class FrmLEdit : Office2007Form
  14. {
  15. public FrmLEdit()
  16. {
  17. InitializeComponent();
  18. ErrItem.BlinkStyle = ErrorBlinkStyle.BlinkIfDifferentError;
  19. }
  20. ErrorProvider ErrItem = new ErrorProvider();
  21. List<LayoutControlItem> _LCItemList = new List<LayoutControlItem>();
  22. public void InitFrm(List<LayoutControlItem> LCItemList)
  23. {
  24. _LCItemList = LCItemList;
  25. //LayoutControl添加控件
  26. if (_LCItemList != null)
  27. {
  28. foreach (LayoutControlItem LocItem in _LCItemList)
  29. {
  30. this.layoutControl1.Controls.Add(LocItem.Control);
  31. this.layoutControl1.RootGroup.Items.Add(LocItem);
  32. }
  33. }
  34. }
  35. public void SetLCItemErr(LayoutControlItem LCItem, string ErrText)
  36. {
  37. if (LCItem == null || LCItem.Control == null)
  38. {
  39. return;
  40. }
  41. if (!string.IsNullOrEmpty(ErrText))
  42. {
  43. LCItem.Control.Padding = new System.Windows.Forms.Padding(0, 0, 15, 0);
  44. LCItem.Control.Margin = new System.Windows.Forms.Padding(0, 0, 15, 0);
  45. }
  46. else
  47. {
  48. LCItem.Control.Padding = new System.Windows.Forms.Padding(0, 0, 0, 0);
  49. LCItem.Control.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0);
  50. }
  51. ErrItem.SetError(LCItem.Control, ErrText);
  52. }
  53. public void ClearLCItemErr()
  54. {
  55. ErrItem.Clear();
  56. }
  57. public void SetLCItemErr(string LCName, string ErrText)
  58. {
  59. LayoutControlItem LCItem = GetLCItem(LCName);
  60. SetLCItemErr(LCItem, ErrText);
  61. }
  62. public List<LayoutControlItem> GetLCItemList()
  63. {
  64. return _LCItemList;
  65. }
  66. public LayoutControlItem GetLCItem(string LCName)
  67. {
  68. return _LCItemList.Find(a => a.Name == LCName);
  69. }
  70. public void ClearLCItemValue()
  71. {
  72. LCItemUtil.ClearValue_LCItem(_LCItemList);
  73. }
  74. public void LCItemIsEnable(string LCName, bool IsEnable)
  75. {
  76. LayoutControlItem item = GetLCItem(LCName);
  77. if (item == null || item.Control == null)
  78. {
  79. return;
  80. }
  81. item.Control.Enabled = IsEnable;
  82. }
  83. public void LCItemIsEnable(bool IsEnable)
  84. {
  85. foreach (LayoutControlItem item in _LCItemList)
  86. {
  87. if (item == null || item.Control == null)
  88. {
  89. continue;
  90. }
  91. item.Control.Enabled = IsEnable;
  92. }
  93. }
  94. public DataRow GetData()
  95. {
  96. DataTable dt = new DataTable();
  97. foreach (LayoutControlItem Item in _LCItemList)
  98. {
  99. dt.Columns.Add(Item.Name, typeof(object));
  100. }
  101. DataRow dr = dt.NewRow();
  102. foreach (LayoutControlItem Item in _LCItemList)
  103. {
  104. dr[Item.Name] = LCItemUtil.GetValue_LCItem(Item);
  105. }
  106. return dr;
  107. }
  108. public void SetLCItemValue(DataRow dr)
  109. {
  110. foreach (LayoutControlItem Item in _LCItemList)
  111. {
  112. if (dr.Table.Columns.Contains(Item.Name))
  113. {
  114. LCItemUtil.SetValue_LCItem(Item, dr[Item.Name]);
  115. }
  116. }
  117. }
  118. }
  119. }