先写需求:
01.显示员工信息
02.实现项目经理给员工评分的功能
第一步:
建立两个类,员工类和项目经理类
定义属性和方法
员工类:工号、年龄、姓名、人气值、项目经理年度评分、经理评价
项目经理类:ID、年龄、姓名、性别、资历,由于经理可以给员工评分,因此还有评分的方法
先上两张图再说:
查看窗体FrmShow
评分窗体FrmJudge
不说了,上代码
首先是员工类
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; } }}
然后是经理类
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; } }}
接下来是查看窗体中的代码
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(); } }}
最后是经理评分窗体中写的代码
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.txt@R_403_6817@Jia.Text = se.Assess; this.txt@R_403_6817@Fen.Text = se.Mscore.ToString(); } //点击评分按钮响应事件 private voID btn@R_403_6817@Fen_Click(object sender,EventArgs e) { try { PM pm = new PM(); pm.Judge(se,this.txt@R_403_6817@Jia.Text.Trim(),Int32.Parse(this.txt@R_403_6817@Fen.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#编写经理评分系统,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对编程小技巧网站的支持!
总结以上是内存溢出为你收集整理的基于C#编写经理评分系统全部内容,希望文章能够帮你解决基于C#编写经理评分系统所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)