博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
通用权限管理系统组件 (GPM - General Permissions Manager) 中实现系统参数配置保存,附源码...
阅读量:6885 次
发布时间:2019-06-27

本文共 7335 字,大约阅读时间需要 24 分钟。

   其实GPM不仅仅是权限管理系统,其实更是一个灵活的轻量级快速.Net开发架构,他需要最短的学习时间,可以最快速入门,并不是通过玩技术来实现我们的日常需求。GPM中只要写一套代码,就可以实现在多种数据库上的稳定运行。

   下面我们给大家参考一下如何在GMP中实现系统参数配置的保存功能,开发界面见下图:

吉日嘎拉,通用权限管理系统组件

数据库中的保存效果如下:

吉日嘎拉,通用权限管理系统组件

配置文件中的保存效果如下:

吉日嘎拉,通用权限管理系统组件

 

实现代码的优点就是,1套代码支持多种数据库,1个参数基本上1行代码就可以实现保存,读取功能,代码的量少稳定性高。见参考代码如下:

  1 
//
-----------------------------------------------------------------
  2 
//
 All Rights Reserved , Copyright (C) 2012 , Hairihan TECH, Ltd. 
  3 
//
-----------------------------------------------------------------
  4 
  5 
using System;
  6 
using System.Data;
  7 
using System.Windows.Forms;
  8 
  9 
namespace DotNet.WinForm
 10 {
 11     
using DotNet.Utilities;
 12     
using DotNet.Business;
 13 
 14     
///
 
<summary>
 15 
    
///
 FrmSystemSecurity
 16 
    
///
 用户登录系统
 17 
    
///
 
 18 
    
///
 修改纪录
 19 
    
///
 
 20 
    
///
        2012.02.12 版本:1.1 JiRiGaLa 功能实现。
 21 
    
///
        2012.01.19 版本:1.0 JiRiGaLa 整理文件。
 22 
    
///
        
 23 
    
///
 版本:1.0
 24 
    
///
 25 
    
///
 
<author>
 26 
    
///
        
<name>
JiRiGaLa
</name>
 27 
    
///
        
<date>
2012.02.12
</date>
 28 
    
///
 
</author>
 
 29 
    
///
 
</summary>
 30 
    
public 
partial 
class FrmSystemSecurity : BaseForm
 31     {
 32         
public FrmSystemSecurity()
 33         {
 34             InitializeComponent();
 35         }
 36 
 37         
///
 
<summary>
 38 
        
///
 从数据库读取当前配置情况
 39 
        
///
 
</summary>
 40 
        
private 
void GetParameter()
 41         {
 42             
string parameter = 
string.Empty;
 43             parameter = DotNetService.Instance.ParameterService.GetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
ServerEncryptPassword
");
 44             
if (!
string.IsNullOrEmpty(parameter))
 45             {
 46                 
this.chkServerEncryptPassword.Checked = parameter.Equals(
true.ToString());
 47             }
 48             parameter = DotNetService.Instance.ParameterService.GetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
PasswordMiniLength
");
 49             
if (!
string.IsNullOrEmpty(parameter))
 50             {
 51                 
this.nudPasswordMiniLength.Value = 
int.Parse(parameter);
 52             }
 53             parameter = DotNetService.Instance.ParameterService.GetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
NumericCharacters
");
 54             
if (!
string.IsNullOrEmpty(parameter))
 55             {
 56                 
this.chkNumericCharacters.Checked = parameter.Equals(
true.ToString());
 57             }
 58             parameter = DotNetService.Instance.ParameterService.GetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
PasswordCycle
");
 59             
if (!
string.IsNullOrEmpty(parameter))
 60             {
 61                 
this.nudPasswordChangeCycle.Value = 
int.Parse(parameter);
 62             }
 63             parameter = DotNetService.Instance.ParameterService.GetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
CheckOnLine
");
 64             
if (!
string.IsNullOrEmpty(parameter))
 65             {
 66                 
this.chkCheckOnLine.Checked = parameter.Equals(
true.ToString());
 67             }
 68             parameter = DotNetService.Instance.ParameterService.GetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
AccountMinimumLength
");
 69             
if (!
string.IsNullOrEmpty(parameter))
 70             {
 71                 
this.nudAccountMinimumLength.Value = 
int.Parse(parameter);
 72             }
 73             parameter = DotNetService.Instance.ParameterService.GetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
PasswordErrowLockLimit
");
 74             
if (!
string.IsNullOrEmpty(parameter))
 75             {
 76                 
this.nudPasswordErrowLockLimit.Value = 
int.Parse(parameter);
 77             }
 78             parameter = DotNetService.Instance.ParameterService.GetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
PasswordErrowLockCycle
");
 79             
if (!
string.IsNullOrEmpty(parameter))
 80             {
 81                 
this.nudPasswordErrowLockCycle.Value = 
int.Parse(parameter);
 82             }
 83         }
 84 
 85         
///
 
<summary>
 86 
        
///
 将设置保存到数据库
 87 
        
///
 
</summary>
 88 
        
private 
void SaveParameter()
 89         {
 90             DotNetService.Instance.ParameterService.SetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
ServerEncryptPassword
"
this.chkServerEncryptPassword.Checked.ToString());
 91             DotNetService.Instance.ParameterService.SetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
PasswordMiniLength
"
this.nudPasswordMiniLength.Value.ToString());
 92             DotNetService.Instance.ParameterService.SetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
NumericCharacters
"
this.chkNumericCharacters.Checked.ToString());
 93             DotNetService.Instance.ParameterService.SetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
PasswordCycle
"
this.nudPasswordChangeCycle.Value.ToString());
 94             DotNetService.Instance.ParameterService.SetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
CheckOnLine
"
this.chkCheckOnLine.Checked.ToString());
 95             DotNetService.Instance.ParameterService.SetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
AccountMinimumLength
"
this.nudAccountMinimumLength.Value.ToString());
 96             DotNetService.Instance.ParameterService.SetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
PasswordErrowLockLimit
"
this.nudPasswordErrowLockLimit.Value.ToString());
 97             DotNetService.Instance.ParameterService.SetParameter(
this.UserInfo, 
"
System
"
"
SystemSecurity
"
"
PasswordErrowLockCycle
"
this.nudPasswordErrowLockCycle.Value.ToString());
 98         }
 99 
100         
///
 
<summary>
101 
        
///
 从当前配置文件显示到界面上
102 
        
///
 
</summary>
103 
        
private 
void GetConfig()
104         {
105             
this.chkServerEncryptPassword.Checked = BaseSystemInfo.ServerEncryptPassword;
106             
this.nudPasswordMiniLength.Value = BaseSystemInfo.PasswordMiniLength;
107             
this.chkNumericCharacters.Checked = BaseSystemInfo.NumericCharacters;
108             
this.nudPasswordChangeCycle.Value = BaseSystemInfo.PasswordChangeCycle;
109             
this.chkCheckOnLine.Checked = BaseSystemInfo.CheckOnLine;
110             
this.nudAccountMinimumLength.Value = BaseSystemInfo.AccountMinimumLength;
111             
this.nudPasswordErrowLockLimit.Value = BaseSystemInfo.PasswordErrowLockLimit;
112             
this.nudPasswordErrowLockCycle.Value = BaseSystemInfo.PasswordErrowLockCycle;
113         }
114 
115         
///
 
<summary>
116 
        
///
 当窗体加载时执行的方法,
117 
        
///
 这个方法会自动处理鼠标的忙碌状态等等
118 
        
///
 
</summary>
119 
        
public 
override 
void FormOnLoad()
120         {
121             
this.GetConfig();
122             
this.GetParameter();
123         }
124 
125         
///
 
<summary>
126 
        
///
 将配置文件保存到XML文件里
127 
        
///
 
</summary>
128 
        
private 
void SaveConfig()
129         {
130             BaseSystemInfo.ServerEncryptPassword = 
this.chkServerEncryptPassword.Checked;
131             BaseSystemInfo.PasswordMiniLength = (
int)
this.nudPasswordMiniLength.Value;
132             BaseSystemInfo.NumericCharacters = 
this.chkNumericCharacters.Checked;
133             BaseSystemInfo.PasswordChangeCycle = (
int)
this.nudPasswordChangeCycle.Value;
134             BaseSystemInfo.CheckOnLine = 
this.chkCheckOnLine.Checked;
135             BaseSystemInfo.AccountMinimumLength =  (
int)
this.nudAccountMinimumLength.Value;
136             BaseSystemInfo.PasswordErrowLockLimit = (
int)
this.nudPasswordErrowLockLimit.Value;
137             BaseSystemInfo.PasswordErrowLockCycle = (
int)
this.nudPasswordErrowLockCycle.Value;
138 
139             
//
 保存用户的信息
140 
            
#if (!DEBUG)
141                 UserConfigHelper.SaveConfig();
142             
#endif
143         }
144 
145         
///
 
<summary>
146 
        
///
 保存系统设置
147 
        
///
 
</summary>
148 
        
private 
void SaveSystemConfig()
149         {
150             
//
 设置鼠标繁忙状态,并保留原先的状态
151 
            Cursor holdCursor = 
this.Cursor;
152             
this.Cursor = Cursors.WaitCursor;
153             
try
154             {
155                 
this.SaveParameter();
156                 
this.SaveConfig();
157 
158                 
//
 是否需要有提示信息?
159 
                
if (BaseSystemInfo.ShowInformation)
160                 {
161                     
//
 批量保存,进行提示
162 
                    MessageBox.Show(AppMessage.MSG0011, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
163                 }
164             }
165             
catch (Exception ex)
166             {
167                 
this.ProcessException(ex);
168             }
169             
finally
170             {
171                 
//
 设置鼠标默认状态,原来的光标状态
172 
                
this.Cursor = holdCursor;
173             }
174         }
175 
176         
private 
void btnConfirm_Click(
object sender, EventArgs e)
177         {
178             
//
 保存系统设置
179 
            
this.SaveSystemConfig();
180         }
181 
182         
private 
void btnCancel_Click(
object sender, EventArgs e)
183         {
184             
this.Close();
185         }
186     }
187 }

 

 

转载地址:http://wlnbl.baihongyu.com/

你可能感兴趣的文章
android框架Java API接口总注释/**@hide*/和internal API
查看>>
20175318 2018-2019-2 《Java程序设计》第七周学习总结
查看>>
比特币:一种点对点的电子现金系统
查看>>
Android - 按钮组件详解
查看>>
MEF简单学习笔记
查看>>
Srping - bean的依赖注入(Dependency injection)
查看>>
NSAutoreleasePool 用处
查看>>
import matplotlib.pyplot as plt出错
查看>>
常用集合与Dictionary用例
查看>>
MVC
查看>>
AI - TensorFlow - 张量(Tensor)
查看>>
js table 导出 Excel
查看>>
AHSC DAY2总结
查看>>
java.lang.SecurityException: class "javax.servlet.FilterRegistration"(spark下maven)
查看>>
[Vue CLI 3] 配置解析之 css.extract
查看>>
Linux——信息采集(三)dmitry、路由跟踪命令tracerouter
查看>>
提取ipa里面的资源图片 png
查看>>
wxpython ItemContainer
查看>>
工作中 Oracle 常用数据字典集锦
查看>>
SFB 项目经验-12-为某上市企业的Skype for Business购买Godday证书
查看>>