public void SaveSysSettingEntity(SysGlobalSettingEntity entity)
        {
            var sb = new StringBuilder();
            sb.AppendLine(" delete from Sys_GlobalSetting ");
            PropertyInfo[] pis = entity.GetType().GetProperties();
            foreach (PropertyInfo pi in pis)
            {
                object[] attributes = pi.GetCustomAttributes(typeof (Field), false);
                if (attributes.Length == 0)
                    continue;

                Field theAttribute = (Field) attributes[0];
                sb.AppendFormat(" insert into Sys_GlobalSetting values ('{0}','{1}') ", theAttribute.FieldName,
                    pi.GetValue(entity, null));
            }

            Db.ExecuteNonQuery(sb.ToString());
        }
        private SysGlobalSettingEntity PrepareFormData()
        {
            //校验参数的合法性
            txtSysName.Text.InitValidation("系统名称").NotEmpty();
            txtSysDescription.Text.InitValidation("系统说明").NotEmpty();
            txtErrorPage.Text.InitValidation("错误页面").NotEmpty();
            txtBuildingPage.Text.InitValidation("建设页面").NotEmpty();
            txtSuperAdmins.Text.InitValidation("超级管理员").NotEmpty();
            txtErrorLogPath.Text.InitValidation("错误日志路径").NotEmpty();
            txtGridviewPageSize.Text.InitValidation("默认分页数").IsNum().LargerThan(5);

            var entity = new SysGlobalSettingEntity();
            entity.SysName = txtSysName.Text;
            entity.SysDescription = txtSysDescription.Text;
            entity.ErrorPage = txtErrorPage.Text;
            entity.BuildingPage = txtBuildingPage.Text;
            entity.ErrorLogPath = txtErrorLogPath.Text;
            entity.SuperAdmins = txtSuperAdmins.Text;
            entity.GridViewPageSize = txtGridviewPageSize.Text;
            return entity;
        }
        public SysGlobalSettingEntity GetSysSettingEntity2()
        {
            DataTable dt = Db.ExecuteDataTable(" select * from Sys_GlobalSetting ");
            if (dt == null || dt.Rows.Count == 0)
                return null;

            SysGlobalSettingEntity entity = new SysGlobalSettingEntity();
            PropertyInfo[] pis = entity.GetType().GetProperties();
            foreach (PropertyInfo pi in pis)
            {
                object[] attributes = pi.GetCustomAttributes(typeof (Field), false);
                if (attributes.Length == 0)
                    continue;

                Field theAttribute = (Field) attributes[0];
                DataRow[] drs = dt.Select("SysKey='" + theAttribute.FieldName + "'");
                if (drs.Length == 0)
                    continue;

                pi.SetValue(entity, drs[0]["SysValue"], null);
            }

            return entity;
        }
 public ExcuteResultEnum UpdateSysSettingEntity(SysGlobalSettingEntity entity)
 {
     SaveSysSettingEntity(entity);
     DataCache.SetCache(CacheKey, entity);
     return ExcuteResultEnum.Success;
 }