Esempio n. 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);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 删除实体类
 /// </summary>
 /// <param name="entity"></param>
 public void EntityRemove(EntityInterface entity)
 {
     try
     {
         AssertLogin();
         entity.SystemService = this;
         entity.Remove();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
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 });
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 更新实体类
        /// </summary>
        /// <param name="entity"></param>
        public EntityInterface EntityUpdate(EntityInterface entity)
        {
            try
            {
                AssertLogin();
                entity.SystemService = this;
                entity.Update();

                return entity;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 5
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);
            }
        }
Esempio n. 6
0
        private void SetControlValue(Control controlItem, EntityInterface entity, Type type)
        {
            Type controlType = controlItem.GetType().GetInterface(typeof(ITableControl).ToString());
            if (controlType != null)
            {
                ITableControl tableControl = (ITableControl)controlItem;
                object obj = type.InvokeMember(tableControl.ControlName, BindingFlags.GetProperty, null, entity, null);
                if (obj != null)
                    tableControl.ControlText = obj.ToString();
            }

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