Csharp/C#教程:基于C#编写经理评分系统分享

先写需求:

    01.显示员工信息

    02.实现项目经理给员工评分的功能

第一步:

    建立两个类,员工类和项目经理类

    定义属性和方法

   员工类:工号、年龄、姓名、人气值、项目经理年度评分、经理评价

   项目经理类:ID、年龄、姓名、性别、资历,由于经理可以给员工评分,因此还有评分的方法

先上两张图再说:

查看窗体FrmShow

基于C#编写经理评分系统

评分窗体FrmJudge

基于C#编写经理评分系统

不说了,上代码

首先是员工类

usingSystem.Text; usingSystem.Threading.Tasks; namespace经理评分系统 { publicclassSE { //员工工号 publicintEngineerId{get;set;} //员工年龄 publicintAge{get;set;} //员工性别 publiccharSex{get;set;} //员工姓名 publicstringName{get;set;} //员工人气值 publicintPopularValue{get;set;} //经理年度评分 publicintMScore{get;set;} //经理评价 publicstringAssess{get;set;} } }

然后是经理类

usingSystem; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks; namespace经理评分系统 { classPM { //经理ID publicintMId{get;set;} //经理年龄 publicintMAge{get;set;} //经理姓名 publicstringMName{get;set;} //经理性别 publiccharMSex{get;set;} //定义评分方法 publicvoidJudge(SEse,Stringassess,intscore) { se.Assess=assess; se.MScore=score; } } }

接下来是查看窗体中的代码

usingSystem; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing; usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks; usingSystem.Windows.Forms; namespace经理评分系统 { publicpartialclassFrmShow:Form { //定义员工数组 publicSE[]engineer=newSE[3]; publicFrmShow() { InitializeComponent(); Init();//初始化SE集合信息 UpdateView(); } //初始化员工信息 publicvoidInit() { SEs1=newSE(); s1.EngineerId=111; s1.Age=26; s1.Name="王小毛"; s1.Assess="未评价"; s1.MScore=0; engineer[0]=s1; SEs2=newSE(); s2.EngineerId=112; s2.Age=22; s2.Name="周新雨"; s2.Assess="未评价"; s2.MScore=0; engineer[1]=s2; SEs3=newSE(); s3.EngineerId=113; s3.Age=30; s3.Name="张烨"; s3.Assess="未评价"; s3.MScore=0; engineer[2]=s3; } //将数据绑定到listview对象的lvAssess上 publicvoidUpdateView() { lvAssess.Items.Clear();//评价后对数据进行刷新 for(inti=0;i<engineer.Length;i++) { ListViewItemitem=newListViewItem(); //将员工信息绑定到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 privatevoidlvAssess_DoubleClick(objectsender,EventArgse) { //获取当前选中的对象 if(this.lvAssess.SelectedItems.Count==0) { return;//必须先选中一行 } intindex=0; for(inti=0;i<engineer.Length;i++) { if(engineer[i].EngineerId.ToString()==this.lvAssess.SelectedItems[0].Text.Trim()) { index=i; break; } } //选中对象评分 FrmJudgefrm=newFrmJudge(this,index); frm.Show(); } } }

最后是经理评分窗体中写的代码

usingSystem; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing; usingSystem.Linq; usingSystem.Text; usingSystem.Threading.Tasks; usingSystem.Windows.Forms; namespace经理评分系统 { publicpartialclassFrmJudge:Form { //保存父窗体的实例 publicFrmShowmyParent; //要评价的员工对象 privateSEse; //参数:父窗体的实例、被评分的员工在员工数组中的位置 publicFrmJudge(FrmShowfparent,intindex) { InitializeComponent(); this.myParent=fparent; this.se=myParent.engineer[index]; } privatevoidFrmJudge_Load(objectsender,EventArgse) { //窗体加载,显示要评价的员工的姓名和得分等信息 this.txtName.Text=se.Name; this.txtPingJia.Text=se.Assess; this.txtPingFen.Text=se.MScore.ToString(); } //点击评分按钮响应事件 privatevoidbtnPingFen_Click(objectsender,EventArgse) { try { PMpm=newPM(); pm.Judge(se,this.txtPingJia.Text.Trim(),Int32.Parse(this.txtPingFen.Text.Trim())); //刷新主窗体 this.myParent.UpdateView(); this.Close(); } catch(Exceptionex) { MessageBox.Show("评分失败!"+ex.ToString()); } } privatevoidbtnCancel_Click(objectsender,EventArgse) { this.Close(); } } }

上述就是C#学习教程:基于C#编写经理评分系统分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/907752.html

(0)
上一篇 2021年10月25日
下一篇 2021年10月25日

精彩推荐