码迷,mamicode.com
首页 > 其他好文 > 详细

项目经理评分

时间:2016-02-20 16:06:57      阅读:304      评论:0      收藏:0      [点我收藏+]

标签:

项目经理评分呢,用到了这些知识.

1.怎么进行方法调用? 2.值类型和应用类型的使用 3.对象数组 4.窗体间传递数据

窗体如下:

技术分享

当你运行员工列表的窗体时,数据会自动在窗体上.

当你双击某一个员工的信息时,弹出评分窗体

技术分享

评分窗体,你可以填数据.当你按评分按钮时,数据会在员工列表窗体上更新.

实现的主要思路:

1.创建SE类

属性:

 1  public class SE
 2     {
 3         private string assess;
 4 
 5         public string Assess
 6         {
 7             get { return assess; }
 8             set { assess = value; }
 9         }
10         private int score;
11 
12         public int Score
13         {
14             get { return score; }
15             set { score = value; }
16         }
17      
18         public int Id { get; set; }
19         public string Name { get; set; }
20         public int Age { get; set; }
21     
22     }

2.创建PM类

1   public  class PM
2     {
3         //assess:评估
4       public void Judge(SE se,string assess,int score) {
5           se.Assess = assess;
6           se.Score = score;
7       
8       }
9     }

3.在员工列表窗体的主要代码

 1   public partial class FrmShow : Form
 2     {
 3         public FrmShow()
 4         {
 5             InitializeComponent();
 6             this.UpdateView();
 7         }
 8         public SE[] engineers = new SE[3];
 9      //绑定数据
10         public void UpdateView() {
11             lvlist.Items.Clear();
12             engineers[0] = new SE();
13             engineers[0].Id = 111;
14             engineers[0].Name = "王小毛";
15             engineers[0].Age = 26;
16             engineers[0].Assess = "未评价";
17             engineers[0].Score = 0;
18             engineers[1] = new SE();
19             engineers[1].Id = 112;
20             engineers[1].Name = "周新雨";
21             engineers[1].Age = 22;
22             engineers[1].Assess = "未评价";
23             engineers[1].Score = 0;
24             engineers[2] = new SE();
25             engineers[2].Id = 113;
26             engineers[2].Name = "张烨";
27             engineers[2].Age = 30;
28             engineers[2].Assess = "未评价";
29             engineers[2].Score = 0;
30             for (int i = 0; i < engineers.Length; i++)
31             {
32                 ListViewItem item = new ListViewItem();
33                 ListViewItem lv = new ListViewItem(engineers[i].Id.ToString());
34                 lv.SubItems.Add(engineers[i].Name);
35                 lv.SubItems.Add(engineers[i].Age.ToString());
36                 lv.SubItems.Add(engineers[i].Assess);
37                 lv.SubItems.Add(engineers[i].Score.ToString());
38                 this.lvlist.Items.Add(lv);
39                 lvlist.Items.Add(item);               
40             }      
41         }
42         //双击listview控件时,弹出Frmjudege窗体
43         private void lvlist_DoubleClick(object sender, EventArgs e)
44         {
45             //获取当前选中的SE德尔对象
46             if (this.lvlist.SelectedItems.Count==0)
47             {
48                 return;//必须先选中一行
49                 
50             }
51             int index = 0;
52             for (int i = 0; i < engineers.Length; i++)
53             {
54                 if (engineers[i].Id.Equals(this.lvlist.SelectedItems[0].Text.Trim()))
55                 {
56                     index = i;
57                     break;
58                 }
59             }  
60            //对选中对象评分
61             FrmJudge frm = new FrmJudge(this,index);
62             frm.Show();
63             
64         }

4.在评分窗体 的代码

 1  public partial class FrmJudge : Form
 2     {
 3         public FrmJudge()
 4         {
 5             InitializeComponent();
 6         }
 7         //保存父窗体的实例
 8         private FrmShow myParent;
 9         //要评价的员工对象
10         private SE se;
11         public FrmJudge(FrmShow fparent,int index) {
12             InitializeComponent();
13             this.myParent = fparent;
14             this.se=myParent.engineers[index];
15         }       
16         private void FrmJudge_Load(object sender, EventArgs e)
17         {
18             //窗体加载,显示要评价的员工的姓名和得分
19             this.txtname.Text = se.Name;
20             this.txtmark.Text = se.Assess;
21             this.txtScore.Text = se.Score.ToString();
22         }
23 
24         private void btnScore_Click(object sender, EventArgs e)
25         {
26             //se.Score =Convert.ToInt32( txtScore.Text);
27             //se.Assess = txtmark.Text;
28             try
29             {
30                 PM pm = new PM();
31                 pm.Judge(se, this.txtmark.Text.Trim(), Int32.Parse(this.txtScore.Text.Trim()));
32                 this.myParent.UpdateView();//刷新主窗体
33                 this.Close();
34             }
35             catch (Exception)
36             {
37                 MessageBox.Show("评分失败!");
38             }
39         }
40         //取消
41         private void btnCancel_Click(object sender, EventArgs e)
42         {
43             this.Close();
44         }
45 
46     }

这样就完事啦.慢慢品吧

项目经理评分

标签:

原文地址:http://www.cnblogs.com/weiguangyi/p/5203367.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!