using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyOffice
{
public class SE
{
private string id;
public string Id
{
get { return id; }
set { id = value; }
}
private int age;
public int Age
{
get { return age; }
set { age = value; }
}
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 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; }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyOffice
{
class PM
{
private int id;
public int Id
{
get { return id; }
set { id = value; }
}
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 year;
public int Year
{
get { return year; }
set { year = value; }
}
public string SayHi()
{
string message;
message = string.Format("大家好,我是{0},今年{1}岁,项目管理经验{2}年",this.name,this.age,this.year);
return message;
}
//项目经理评分的方法
public void Judge(SE se,string assess,int score)
{
se.Assess = assess;
se.Score = score;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyOffice
{
public enum Gender
{
男,女
}
}
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 MyOffice
{
public partial class FrmShow : Form
{
public SE[] se = new SE[3];
public FrmShow()
{
InitializeComponent();
this.Init();
this.UpdateView();
}
public void Init()
{
SE se1 = new SE();
se1.Name = "郭靖";
se1.Age = 18;
se1.Gender =Gender.男;
se1.Id = "111";
se[0] = se1;
SE se2 = new SE();
se2.Name = "黄蓉";
se2.Age = 18;
se2.Gender = Gender.女;
se2.Id = "222";
se[1] = se2;
SE se3 = new SE();
se3.Name = "李白";
se3.Age = 20;
se3.Gender =Gender.男;
se3.Id = "333";
se[2] = se3;
}
public void UpdateView()
{
listView1.Items.Clear();
for (int i = 0; i < se.Length;i++ )
{
ListViewItem item = new ListViewItem();
item.Text = se[i].Id;
item.SubItems.Add(se[i].Name);
item.SubItems.Add(se[i].Age.ToString());
item.SubItems.Add(se[i].Score.ToString());
item.SubItems.Add(se[i].Assess);
this.listView1.Items.Add(item);
}
}
private void FrmShow_Load(object sender, EventArgs e)
{
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void listView1_DoubleClick(object sender, EventArgs e)
{
if(this.listView1.SelectedItems.Count==0){
return;
}
int index = 0;
for (int i = 0; i < se.Length;i++ )
{
if(se[i].Id==this.listView1.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 MyOffice
{
public partial class FrmJudge : Form
{
private FrmShow myParent;
private SE se;
public FrmJudge()
{
InitializeComponent();
}
public FrmJudge(FrmShow fparent,int index)
{
InitializeComponent();
this.myParent = fparent;
this.se = myParent.se[index];
}
private void FrmJudge_Load(object sender, EventArgs e)
{
this.textBox1.Text = se.Name;
this.textBox2.Text = se.Assess;
this.textBox3.Text = se.Score.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
PM pm=new PM();
pm.Judge(se, this.textBox2.Text.Trim(), Int32.Parse(this.textBox3.Text.Trim()));
this.myParent.UpdateView();
this.Close();
}
catch(Exception ex)
{
MessageBox.Show("评分失败!"+ex.ToString());
}
}
private void button2_Click(object sender, EventArgs e)
{
DialogResult resuilt = MessageBox.Show("是否要取消","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Information);
Application.Exit();
}
}
}