Beispiel #1
0
 /// 设置窗体上对象的Text值
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="t"></param>
 protected virtual void SetEntity(EntityInterface entity)
 {
     Type type = entity.GetType();
     foreach (Control control in panelContent.Controls)
     {
         SetControlValue(control, entity, type);
     }
 }
Beispiel #2
0
        /// <summary>
        /// 获取窗体上的对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        protected virtual void GetEntity(EntityInterface entity)
        {
            Type type = entity.GetType();

            foreach (Control control in panelContent.Controls)
            {
                Type controlType = control.GetType().GetInterface(typeof(ITableControl).ToString());
                if (controlType != null)
                {
                    ITableControl tableControl = (ITableControl)control;
                    type.InvokeMember(tableControl.ControlName, BindingFlags.SetProperty, null, entity, new object[] { tableControl.ControlText });
                }
            }
        }
Beispiel #3
0
        private void GetControlValue(Control controlItem,EntityInterface entity,Type type)
        {
            Type controlType = controlItem.GetType().GetInterface(typeof(ITableControl).ToString());
            if (controlType != null)
            {
                ITableControl tableControl = (ITableControl)controlItem;
                Type proType = entity.GetType().GetProperty(tableControl.ControlName).PropertyType;
                type.InvokeMember(tableControl.ControlName, BindingFlags.SetProperty, null, entity, new object[] { Convert.ChangeType(tableControl.ControlText, proType) });
            }

            foreach (Control control in controlItem.Controls)
            {
                GetControlValue(control, entity, type);
            }
        }