1 public class SE 2 { 3 //员工类 4 private int id; 5 6 public int Id 7 { 8 get { return id; } 9 set { id = value; } 10 } 11 private string name; 12 13 public string Name 14 { 15 get { return name; } 16 set { name = value; } 17 } 18 private int age; 19 20 public int Age 21 { 22 get { return age; } 23 set { age = value; } 24 } 25 private string ping; 26 27 public string Ping 28 { 29 get { return ping; } 30 set { ping = value; } 31 } 32 private string fen; 33 34 public string Fen 35 { 36 get { return fen; } 37 set { fen = value; } 38 } 39 }
1 public class PM 2 { 3 //项目经理类 4 private string name; 5 6 public string Name 7 { 8 get { return name; } 9 set { name = value; } 10 } 11 12 private string ping; 13 14 public string Ping 15 { 16 get { return ping; } 17 set { ping = value; } 18 } 19 private string fen; 20 21 public string Fen 22 { 23 get { return fen; } 24 set { fen = value; } 25 } 26 public void Judge(SE se, String assess, int score) 27 { 28 29 } 30 }
1 public FrmShow() 2 { 3 InitializeComponent(); 4 this.Init();//初始化员工信息 5 this.UpdateView();//将员工信息绑定到listView1上 6 } 7 8 private void FrmShow_Load(object sender, EventArgs e) 9 { 10 11 } 12 //准备一个容器,可以容纳3个员工对象 13 SE[] engineers = new SE[3]; 14 /// <summary> 15 /// 初始化员工信息 16 /// </summary> 17 public void Init() 18 { 19 SE a = new SE(); 20 a.Id = 111; 21 a.Name = "王小毛"; 22 a.Age = 26; 23 a.Ping = "未评价"; 24 a.Fen = "0"; 25 engineers[0] = a; 26 27 SE b = new SE(); 28 b.Id = 112; 29 b.Name = "周新雨"; 30 b.Age = 22; 31 b.Ping = "未评价"; 32 b.Fen = "0"; 33 engineers[1] = b; 34 35 SE c= new SE(); 36 c.Id = 112; 37 c.Name = "张烨"; 38 c.Age = 30; 39 c.Ping = "未评价"; 40 c.Fen = "0"; 41 engineers[2] = c; 42 43 44 } 45 /// <summary> 46 /// 将员工信息绑定到listView1上 47 /// </summary> 48 public void UpdateView() 49 { 50 listView1.Items.Clear(); 51 for (int i = 0; i < engineers.Length; i++) 52 { 53 //一个item就是一个员工对象 54 ListViewItem item = new ListViewItem(engineers[i].Id.ToString()); 55 item.SubItems.Add(engineers[i].Name.ToString()); 56 item.SubItems.Add(engineers[i].Age.ToString()); 57 item.SubItems.Add(engineers[i].Ping.ToString()); 58 item.SubItems.Add(engineers[i].Fen.ToString()); 59 60 this.listView1.Items.Add(item); 61 } 62 } 63 64 private void listView1_DoubleClick(object sender, EventArgs e) 65 { 66 ListViewItem selectItem = listView1.SelectedItems[0]; 67 FrmJudge frm = new FrmJudge(); 68 frm.selectItem = selectItem; 69 frm.ShowDialog(); 70 }
1 public ListViewItem selectItem = null; 2 private void FrmJudge_Load(object sender, EventArgs e) 3 { 4 txtName.Text = selectItem.SubItems[1].Text; 5 txtName.ReadOnly = true; 6 } 7 private void btnPing_Click(object sender, EventArgs e) 8 { 9 selectItem.SubItems[3].Text = rtxtPing.Text; 10 selectItem.SubItems[4].Text = txtNian.Text; 11 this.Close(); 12 13 14 }