先写需求:
01.显示员工信息
02.实现项目经理给员工评分的功能
第一步:
建立两个类,员工类和项目经理类
定义属性和方法
员工类:工号、年龄、姓名、人气值、项目经理年度评分、经理评价
项目经理类:id、年龄、姓名、性别、资历,由于经理可以给员工评分,因此还有评分的方法
先上两张图再说:
查看窗体frmshow
评分窗体frmjudge
不说了,上代码
首先是员工类
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
using system.text; using system.threading.tasks; namespace 经理评分系统 { public class se { //员工工号 public int engineerid { get ; set ; } //员工年龄 public int age { get ; set ; } //员工性别 public char sex { get ; set ; } //员工姓名 public string name { get ; set ; } //员工人气值 public int popularvalue { get ; set ; } //经理年度评分 public int mscore { get ; set ; } //经理评价 public string assess { get ; set ; } } } |
然后是经理类
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace 经理评分系统 { class pm { //经理id public int mid { get ; set ; } //经理年龄 public int mage{ get ; set ; } //经理姓名 public string mname { get ; set ; } //经理性别 public char msex{ get ; set ; } //定义评分方法 public void judge(se se, string assess, int score) { se.assess = assess; se.mscore = score; } } } |
接下来是查看窗体中的代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; namespace 经理评分系统 { public partial class frmshow : form { //定义员工数组 public se[] engineer= new se[3]; public frmshow() { initializecomponent(); init(); //初始化se集合信息 updateview(); } //初始化员工信息 public void init() { se s1 = new se(); s1.engineerid = 111; s1.age = 26; s1.name = "王小毛" ; s1.assess = "未评价" ; s1.mscore = 0; engineer[0]=s1; se s2 = new se(); s2.engineerid = 112; s2.age = 22; s2.name = "周新雨" ; s2.assess = "未评价" ; s2.mscore = 0; engineer[1] = s2; se s3 = new se(); s3.engineerid = 113; s3.age = 30; s3.name = "张烨" ; s3.assess = "未评价" ; s3.mscore = 0; engineer[2] = s3; } //将数据绑定到listview对象的lvassess上 public void updateview() { lvassess.items.clear(); //评价后对数据进行刷新 for ( int i = 0; i < engineer.length;i++ ) { listviewitem item = new listviewitem(); //将员工信息绑定到listview中 item.text = engineer[i].engineerid.tostring(); item.subitems.add(engineer[i].name); item.subitems.add(engineer[i].age.tostring()); item.subitems.add(engineer[i].mscore.tostring()); item.subitems.add(engineer[i].assess); this .lvassess.items.add(item); } } //双击listview private void lvassess_doubleclick( object sender, eventargs e) { //获取当前选中的对象 if ( this .lvassess.selecteditems.count==0) { return ; //必须先选中一行 } int index = 0; for ( int i = 0; i < engineer.length;i++) { if (engineer[i].engineerid.tostring()== this .lvassess.selecteditems[0].text.trim()) { index = i; break ; } } //选中对象评分 frmjudge frm = new frmjudge( this ,index); frm.show(); } } } |
最后是经理评分窗体中写的代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; namespace 经理评分系统 { public partial class frmjudge : form { //保存父窗体的实例 public frmshow myparent; //要评价的员工对象 private se se; //参数:父窗体的实例、被评分的员工在员工数组中的位置 public frmjudge(frmshow fparent, int index) { initializecomponent(); this .myparent = fparent; this .se = myparent.engineer[index]; } private void frmjudge_load( object sender, eventargs e) { //窗体加载,显示要评价的员工的姓名和得分等信息 this .txtname.text = se.name; this .txtpingjia.text = se.assess; this .txtpingfen.text = se.mscore.tostring(); } //点击评分按钮响应事件 private void btnpingfen_click( object sender, eventargs e) { try { pm pm = new pm(); pm.judge(se, this .txtpingjia.text.trim(),int32.parse( this .txtpingfen.text.trim())); //刷新主窗体 this .myparent.updateview(); this .close(); } catch (exception ex) { messagebox.show( "评分失败!" +ex.tostring()); } } private void btncancel_click( object sender, eventargs e) { this .close(); } } } |
以上所述是小编给大家介绍的基于c#编写经理评分系统,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对服务器之家网站的支持!
原文链接:http://www.cnblogs.com/hfddz/archive/2017/03/10/6530027.html