程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> 項目經理評分,項目經理評分表

項目經理評分,項目經理評分表

編輯:C#入門知識

項目經理評分,項目經理評分表


項目經理評分呢,用到了這些知識.

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     }

這樣就完事啦.慢慢品吧

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved