经理评分系统

//程序员类(员工类)

amespace MyOffice

{

//程序员类(员工类)

public class SE
{

// 工号
public string ID { get; set; }

// 年龄
public int Age { get; set; }

///姓名
public string Name { get; set; }

// 性别
public Gender Gender { get; set; }

// 人气值
private int _popularity = 0;

public int Popularity
{
get { return _popularity; }
set { _popularity = value; }
}


// 经理年度评分

private int _score = 0;

public int Score
{
get { return _score; }
set { _score = value; }
}

// 经理评价

private String _assess = "未评价";

public String Assess
{
get { return _assess; }
set { _assess = value; }
}

//public string SayHi() 
//{
// string message = string.Format("大家好,我是 {0}, 今年 {1}岁,工号是 {2},我的人气值高达 {3}!",this.Name,this.Age,this.ID,this.Popularity);
// return message;
//}

}

}

 

// 项目经理类

class PM
{
// ID
private string _id;
public string ID
{
set { _id = value; }
get { return _id; }
}

// 年龄

private int _age;
public int Age 
{
get { return _age; }
set 
{
if (value >= 30 && value <= 100)
{
_age = value;
}
else 
{
_age = 30;
}
}
}


//姓名
private string _name; 
public string Name
{
get { return _name; }
set { _name = value; }
}


// 性别
private Gender _gender; 
public Gender Gender
{
get { return _gender; }
set { _gender = value; }
}


//资历

private int _yearOfExperience; 
public int YearOfExperience
{
get { return _yearOfExperience; }
set { _yearOfExperience = value; }
}


// 问好
// <returns>问好的内容</returns>
public string SayHi() 
{
string message;
message = string.Format(
"大家好,我是 {0} ,今年 {1} 岁,项目管理经验 {2}年。",
this._name, this._age, this._yearOfExperience
);
return message;
}


// 项目经理评分

// <param name="se"></param>
public void Judge(SE se, String assess, int score)
{
se.Assess = assess;
se.Score = score;
}
}
}

//性别枚举
public enum Gender
{
male, 
female
}
}

//主窗体

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MyOffice
{
public partial class FrmJudge : Form
{
private FrmShow myParent; //主窗体

private SE se; //被评分的员工对象


public FrmJudge(FrmShow fparent,int index)
{
InitializeComponent();
this.myParent = fparent;
this.se = myParent.engineers[index];
}

//加载时填充信息

private void FrmJudge_Load(object sender, EventArgs e)
{
this.txtName.Text = se.Name;
this.txtAssess.Text = se.Assess;
this.txtScore.Text = se.Score.ToString();
}

//评分响应事件 
private void btnOK_Click(object sender, EventArgs e)
{
try
{
PM pm = new PM();
pm.Judge(se,this.txtAssess.Text.Trim(),Int32.Parse(this.txtScore.Text.Trim()));
this.myParent.UpdateView(); //刷新主窗体
this.Close();
}
catch (Exception ex)
{
MessageBox.Show("评分失败!" + ex.ToString());
}
}

//取消按钮
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

 

/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.txtName = new System.Windows.Forms.TextBox();
this.txtScore = new System.Windows.Forms.TextBox();
this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.txtAssess = new System.Windows.Forms.TextBox();
this.SuspendLayout();
// 
// label1
// 
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(17, 30);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 12);
this.label1.TabIndex = 0;
this.label1.Text = "员工姓名";
// 
// label2
// 
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(17, 70);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 12);
this.label2.TabIndex = 1;
this.label2.Text = "填写评价";
// 
// label3
// 
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(17, 128);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 12);
this.label3.TabIndex = 2;
this.label3.Text = "年度评分";
// 
// txtName
// 
this.txtName.Location = new System.Drawing.Point(90, 21);
this.txtName.Name = "txtName";
this.txtName.ReadOnly = true;
this.txtName.Size = new System.Drawing.Size(212, 21);
this.txtName.TabIndex = 3;
// 
// txtScore
// 
this.txtScore.Location = new System.Drawing.Point(90, 120);
this.txtScore.Name = "txtScore";
this.txtScore.Size = new System.Drawing.Size(212, 21);
this.txtScore.TabIndex = 5;
// 
// btnOK
// 
this.btnOK.Location = new System.Drawing.Point(90, 160);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 7;
this.btnOK.Text = "评分";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
// 
// btnCancel
// 
this.btnCancel.Location = new System.Drawing.Point(171, 160);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 8;
this.btnCancel.Text = "取消";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
// 
// txtAssess
// 
this.txtAssess.Location = new System.Drawing.Point(90, 61);
this.txtAssess.Multiline = true;
this.txtAssess.Name = "txtAssess";
this.txtAssess.Size = new System.Drawing.Size(217, 53);
this.txtAssess.TabIndex = 9;
// 
// FrmJudge
// 
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(319, 204);
this.Controls.Add(this.txtAssess);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.txtScore);
this.Controls.Add(this.txtName);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "FrmJudge";
this.Text = "评分";
this.Load += new System.EventHandler(this.FrmJudge_Load);
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtName;
private System.Windows.Forms.TextBox txtScore;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.TextBox txtAssess;
}
}

 

 

//员工集合信息

public partial class FrmShow : Form
{
public SE[] engineers = new SE[3]; //员工集合信息


public FrmShow()
{
InitializeComponent();
this.Init(); //初始化员工集合信息
this.UpdateView(); //刷新显示
}


// 员工信息初始化

public void Init()
{
SE jack = new SE();
jack.Name = "王小毛";
jack.Age = 26;
jack.Gender = Gender.male;
jack.ID = "111";

SE joe = new SE();
joe.Name = "周新雨";
joe.Age = 22;
joe.Gender = Gender.female;
joe.ID = "112";

SE ema = new SE();
ema.Name = "张烨";
ema.Age = 30;
ema.Gender = Gender.male;
ema.ID = "113";

engineers[0] = jack;
engineers[1] = joe;
engineers[2] = ema; 
}

// 刷新ListView显示
public void UpdateView() 
{
lvAssess.Items.Clear(); //清空信息
for (int i = 0; i < engineers.Length; i++)
{
ListViewItem item = new ListViewItem();
item.Text = engineers[i].ID;
item.SubItems.Add(engineers[i].Name); //设置姓名
item.SubItems.Add(engineers[i].Age.ToString()); //设置年龄
item.SubItems.Add(engineers[i].Score.ToString()); //设置评分
item.SubItems.Add(engineers[i].Assess); //设置评价
this.lvAssess.Items.Add(item); //添加项

}
}


//双击执行评分
//<param name="sender"></param>
// <param name="e"></param>
private void lvAssess_DoubleClick(object sender, EventArgs e)
{
//获取当前选中的员工对象
if (this.lvAssess.SelectedItems.Count == 0)
{
return;
}
int index = 0;
for(int i = 0; i<engineers.Length;i++)
{
if (engineers[i].ID == this.lvAssess.SelectedItems[0].Text.Trim())
{
index = i;
break;
}
}
//对选中对象评分
FrmJudge frm = new FrmJudge(this,index);
frm.Show();
}

}
}

 

namespace MyOffice
{
partial class FrmShow
{

//Required designer variable.

private System.ComponentModel.IContainer components = null;

//Clean up any resources being used.

//<param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code


// Required method for Designer support - do not modify
//the contents of this method with the code editor.

private void InitiaryalizeComponent()
{
this.lvAssess = new System.Windows.Forms.ListView();
this.cheaderName = new System.Windows.Forms.ColumnHeader();
this.cheaderID = new System.Windows.Forms.ColumnHeader();
this.cheaderAge = new System.Windows.Forms.ColumnHeader();
this.cheaderAsess = new System.Windows.Forms.ColumnHeader();
this.cheaderScore = new System.Windows.Forms.ColumnHeader();
this.SuspendLayout();
// 
// lvAssess
// 
this.lvAssess.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.cheaderID,
this.cheaderName,
this.cheaderAge,
this.cheaderScore,
this.cheaderAsess});
this.lvAssess.FullRowSelect = true;
this.lvAssess.GridLines = true;
this.lvAssess.Location = new System.Drawing.Point(12, 12);
this.lvAssess.Name = "lvAssess";
this.lvAssess.Size = new System.Drawing.Size(453, 230);
this.lvAssess.TabIndex = 0;
this.lvAssess.UseCompatibleStateImageBehavior = false;
this.lvAssess.View = System.Windows.Forms.View.Details;
this.lvAssess.DoubleClick += new System.EventHandler(this.lvAssess_DoubleClick);
// 
// cheaderName
// 
this.cheaderName.Text = "姓名";
// 
// cheaderID
// 
this.cheaderID.Text = "工号";
// 
// cheaderAge
// 
this.cheaderAge.Text = "年龄";
// 
// cheaderAsess
// 
this.cheaderAsess.DisplayIndex = 3;
this.cheaderAsess.Text = "评价";
// 
// cheaderScore
// 
this.cheaderScore.DisplayIndex = 4;
this.cheaderScore.Text = "年度得分";
// 
// FrmShow
// 
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(477, 254);
this.Controls.Add(this.lvAssess);
this.Name = "FrmShow";
this.Text = "查看评分";
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.ListView lvAssess;
private System.Windows.Forms.ColumnHeader cheaderID;
private System.Windows.Forms.ColumnHeader cheaderName;
private System.Windows.Forms.ColumnHeader cheaderAge;
private System.Windows.Forms.ColumnHeader cheaderAsess;
private System.Windows.Forms.ColumnHeader cheaderScore;
}
}

// 应用程序的主入口点。

static class Program
{

[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmShow());
}
}

  

posted @ 2017-03-15 13:34  易烊千鹿  阅读(339)  评论(0编辑  收藏  举报