Esempio n. 1
0
        /// <summary>
        /// 设置表单数据
        /// </summary>
        public static void SetForm <T>(Page Ucontrol, T enity, string prefix)
        {
            foreach (PropertyInfo p in typeof(T).GetProperties())
            {
                Control ctrl = FindControl(Ucontrol, prefix + p.Name);
                if (ctrl != null)
                {
                    string value = string.Empty;
                    if (p.GetValue(enity, null) != null)
                    {
                        if (p.PropertyType == typeof(DateTime) || p.PropertyType == typeof(DateTime?))
                        {
                            value = p.GetValue(enity, null).ToString().Trim();

                            if (!string.IsNullOrEmpty(value))
                            {
                                value = DateTime.Parse(value).ToString("yyyy-MM-dd");
                            }
                        }
                        else
                        {
                            value = p.GetValue(enity, null).ToString().Trim();
                        }
                    }
                    else
                    {
                        continue;
                    }

                    WebControlValue.SetValue(ctrl, value);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 取得表单数据
        /// </summary>
        public static void GetForm <T>(Page Ucontrol, T entity, string prefix)
        {
            foreach (PropertyInfo p in typeof(T).GetProperties())
            {
                Control ctrl = FindControl(Ucontrol, prefix + p.Name);

                if (ctrl != null)
                {
                    object value = WebControlValue.GetValue(ctrl);
                    SetPropertyValue <T>(p, value.ToString(), entity);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 取得表单数据
        /// </summary>
        public static void GetForm <T>(UserControl Ucontrol, T entity, string prefix)
        {
            foreach (PropertyInfo p in typeof(T).GetProperties())
            {
                Control ctrl = Ucontrol.FindControl(prefix + p.Name);

                if (ctrl != null)
                {
                    //Trace.Write(" not null ,type = "+ ctrl.GetType().Name);
                    object value = WebControlValue.GetValue(ctrl);
                    SetPropertyValue <T>(p, value.ToString(), entity);
                }
                //Trace.WriteLine("");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 设置表单数据
        /// </summary>
        public static void SetForm <T>(UserControl Ucontrol, T enity, string prefix)
        {
            foreach (PropertyInfo p in typeof(T).GetProperties())
            {
                Control ctrl = Ucontrol.FindControl(prefix + p.Name);
                if (ctrl != null)
                {
                    string value = string.Empty;

                    if (p.GetValue(enity, null) != null)
                    {
                        value = p.GetValue(enity, null).ToString().Trim();
                    }
                    else
                    {
                        continue;
                    }

                    WebControlValue.SetValue(ctrl, value);
                }
            }
        }