简单快速开发C\S架构程序用最简单的不分层最快的效率达到功能要求的例子程序FrmKnowledge日积月累功能的实现
2012-09-03 14:51 通用C#系统架构 阅读(1615) 评论(0) 编辑 收藏 举报用通用权限管理系统组件开发一个简易的日积月累功能的代码实现,运行效果如下效果,很多通用的小功能系统组件自动都实现了,那开发应用程序会变得又快又简单了。
具体代码参考如下:
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.Business;
12 using DotNet.Utilities;
13
14 /// <summary>
15 /// FrmKnowledge.cs
16 /// 日积月累
17 ///
18 /// 修改记录
19 ///
20 /// 2012.09.03 版本:1.0 JiRiGaLa 修改功能页面编写。
21 ///
22 /// 版本:1.0
23 ///
24 /// <author>
25 /// <name>JiRiGaLa</name>
26 /// <date>2012.09.03</date>
27 /// </author>
28 /// </summary>
29 public partial class FrmKnowledge : BaseForm
30 {
31 public FrmKnowledge()
32 {
33 InitializeComponent();
34 }
35
36 /// <summary>
37 /// 日积月累的知识库
38 /// </summary>
39 DataTable dtKnowledge = null;
40
41 /// <summary>
42 /// 当前显示第几条
43 /// </summary>
44 int CurrentIndex = 0;
45
46 #region public override void ShowEntity() 显示内容
47 /// <summary>
48 /// 显示内容
49 /// </summary>
50 public override void ShowEntity()
51 {
52 // 显示信息
53 BaseCommentEntity commentEntity = new BaseCommentEntity(dtKnowledge.Rows[this.CurrentIndex]);
54 this.txtContents.Text = commentEntity.Contents;
55 }
56 #endregion
57
58 public override void SetControlState()
59 {
60 if (this.dtKnowledge != null && this.dtKnowledge.Rows.Count > 0)
61 {
62 this.btnNext.Enabled = true;
63 if (this.CurrentIndex == this.dtKnowledge.Rows.Count - 1)
64 {
65 this.btnNext.Enabled = false;
66 }
67 this.btnPrevious.Enabled = true;
68 if (this.CurrentIndex == 0)
69 {
70 this.btnPrevious.Enabled = false;
71 }
72 }
73 }
74
75 #region public override void FormOnLoad() 加载窗体
76 /// <summary>
77 /// 加载窗体
78 /// </summary>
79 public override void FormOnLoad()
80 {
81 // 获取数据
82 SQLBuilder sqlBuilder = new SQLBuilder(this.UserCenterDbHelper);
83 sqlBuilder.BeginSelect("BaseKnowledge");
84 // 只获取前200个数据就可以了,减小网络传递数据的网络带宽。
85 sqlBuilder.SelectTop(200);
86 if (!string.IsNullOrEmpty(this.EntityId))
87 {
88 sqlBuilder.SetWhere(BaseCommentEntity.FieldId, this.EntityId);
89 }
90 // 这里是为了每次显示的数据都是乱序的,数据测循序是被打乱的。
91 sqlBuilder.SetOrderBy( " NEWID() ");
92 dtKnowledge = sqlBuilder.EndSelect();
93 if (dtKnowledge.Rows.Count > 1)
94 {
95 this.CurrentIndex = new Random().Next(0, dtKnowledge.Rows.Count - 1);
96 }
97 // 显示实体
98 this.ShowEntity();
99
100 // 显示日积月累
101 string showKnowledge = DotNetService.Instance.ParameterService.GetParameter(BaseSystemInfo.UserInfo, "User", "ShowKnowledg", "Show");
102 if (!string.IsNullOrEmpty(showKnowledge))
103 {
104 this.chkShowKnowledge.Checked = showKnowledge.Equals(true.ToString());
105 }
106 }
107 #endregion
108
109 private void chkShowKnowledge_CheckedChanged(object sender, EventArgs e)
110 {
111 if (this.FormLoaded)
112 {
113 DotNetService.Instance.ParameterService.SetParameter(BaseSystemInfo.UserInfo, "User", "ShowKnowledg", "Show", this.chkShowKnowledge.Checked.ToString());
114 }
115 }
116
117 private void btnPrevious_Click(object sender, EventArgs e)
118 {
119 if (this.CurrentIndex > 0)
120 {
121 this.CurrentIndex--;
122 this.ShowEntity();
123 }
124 this.SetControlState();
125 }
126
127 private void btnNext_Click(object sender, EventArgs e)
128 {
129 if (this.CurrentIndex < this.dtKnowledge.Rows.Count -1)
130 {
131 this.CurrentIndex++;
132 this.ShowEntity();
133 }
134 this.SetControlState();
135 }
136
137 private void btnColse_Click(object sender, EventArgs e)
138 {
139 this.Close();
140 }
141 }
142 }
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.Business;
12 using DotNet.Utilities;
13
14 /// <summary>
15 /// FrmKnowledge.cs
16 /// 日积月累
17 ///
18 /// 修改记录
19 ///
20 /// 2012.09.03 版本:1.0 JiRiGaLa 修改功能页面编写。
21 ///
22 /// 版本:1.0
23 ///
24 /// <author>
25 /// <name>JiRiGaLa</name>
26 /// <date>2012.09.03</date>
27 /// </author>
28 /// </summary>
29 public partial class FrmKnowledge : BaseForm
30 {
31 public FrmKnowledge()
32 {
33 InitializeComponent();
34 }
35
36 /// <summary>
37 /// 日积月累的知识库
38 /// </summary>
39 DataTable dtKnowledge = null;
40
41 /// <summary>
42 /// 当前显示第几条
43 /// </summary>
44 int CurrentIndex = 0;
45
46 #region public override void ShowEntity() 显示内容
47 /// <summary>
48 /// 显示内容
49 /// </summary>
50 public override void ShowEntity()
51 {
52 // 显示信息
53 BaseCommentEntity commentEntity = new BaseCommentEntity(dtKnowledge.Rows[this.CurrentIndex]);
54 this.txtContents.Text = commentEntity.Contents;
55 }
56 #endregion
57
58 public override void SetControlState()
59 {
60 if (this.dtKnowledge != null && this.dtKnowledge.Rows.Count > 0)
61 {
62 this.btnNext.Enabled = true;
63 if (this.CurrentIndex == this.dtKnowledge.Rows.Count - 1)
64 {
65 this.btnNext.Enabled = false;
66 }
67 this.btnPrevious.Enabled = true;
68 if (this.CurrentIndex == 0)
69 {
70 this.btnPrevious.Enabled = false;
71 }
72 }
73 }
74
75 #region public override void FormOnLoad() 加载窗体
76 /// <summary>
77 /// 加载窗体
78 /// </summary>
79 public override void FormOnLoad()
80 {
81 // 获取数据
82 SQLBuilder sqlBuilder = new SQLBuilder(this.UserCenterDbHelper);
83 sqlBuilder.BeginSelect("BaseKnowledge");
84 // 只获取前200个数据就可以了,减小网络传递数据的网络带宽。
85 sqlBuilder.SelectTop(200);
86 if (!string.IsNullOrEmpty(this.EntityId))
87 {
88 sqlBuilder.SetWhere(BaseCommentEntity.FieldId, this.EntityId);
89 }
90 // 这里是为了每次显示的数据都是乱序的,数据测循序是被打乱的。
91 sqlBuilder.SetOrderBy( " NEWID() ");
92 dtKnowledge = sqlBuilder.EndSelect();
93 if (dtKnowledge.Rows.Count > 1)
94 {
95 this.CurrentIndex = new Random().Next(0, dtKnowledge.Rows.Count - 1);
96 }
97 // 显示实体
98 this.ShowEntity();
99
100 // 显示日积月累
101 string showKnowledge = DotNetService.Instance.ParameterService.GetParameter(BaseSystemInfo.UserInfo, "User", "ShowKnowledg", "Show");
102 if (!string.IsNullOrEmpty(showKnowledge))
103 {
104 this.chkShowKnowledge.Checked = showKnowledge.Equals(true.ToString());
105 }
106 }
107 #endregion
108
109 private void chkShowKnowledge_CheckedChanged(object sender, EventArgs e)
110 {
111 if (this.FormLoaded)
112 {
113 DotNetService.Instance.ParameterService.SetParameter(BaseSystemInfo.UserInfo, "User", "ShowKnowledg", "Show", this.chkShowKnowledge.Checked.ToString());
114 }
115 }
116
117 private void btnPrevious_Click(object sender, EventArgs e)
118 {
119 if (this.CurrentIndex > 0)
120 {
121 this.CurrentIndex--;
122 this.ShowEntity();
123 }
124 this.SetControlState();
125 }
126
127 private void btnNext_Click(object sender, EventArgs e)
128 {
129 if (this.CurrentIndex < this.dtKnowledge.Rows.Count -1)
130 {
131 this.CurrentIndex++;
132 this.ShowEntity();
133 }
134 this.SetControlState();
135 }
136
137 private void btnColse_Click(object sender, EventArgs e)
138 {
139 this.Close();
140 }
141 }
142 }
将权限管理、工作流管理做到我能力的极致,一个人只能做好那么很少的几件事情。