/// <summary> /// 获取控件基本信息 /// </summary> /// <param name="pageid"></param> /// <returns></returns> private List <ControlDetailForPage> GetControlBaseInfo(int pageid) { string sql = @"select * from hs_new_page_ctrls t where t.page_id = '{0}'"; sql = string.Format(sql, pageid); SQLiteDataReader reader = this.ExcuteReader(sql); List <ControlDetailForPage> listControl = new List <ControlDetailForPage>(); while (reader.Read()) { //int index = 0; ControlDetailForPage obj = new ControlDetailForPage(); foreach (var prop in obj.GetType().GetFields()) { string value = reader[prop.Name].ToString(); //这里判断一下类型 if ("Boolean".Equals(prop.FieldType.Name)) { prop.SetValue(obj, CommonConverter.StringToBool(value)); } else if ("Int32".Equals(prop.FieldType.Name)) { prop.SetValue(obj, CommonConverter.StringToInt(value)); } else { prop.SetValue(obj, value); } } listControl.Add(obj); } reader.Close(); this._connection.Close(); return(listControl); }
/// <summary> /// 可见性 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="inControl"></param> /// <param name="text"></param> public static void SetD18 <T>(this T inControl, string text) where T : IControl { if (string.IsNullOrEmpty(text)) { } (inControl as FrameworkElement).Visibility = CommonConverter.StringToBool(text) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; }