Use C # To write the manager scoring system,

Source: Internet
Author: User

Use C # To write the manager scoring system,

Write requirements first:

01. Display employee information

02. enable the project manager to score employees

Step 1:

Create two classes: employee and Project Manager

Define attributes and Methods

Employees: employee ID, age, name, popularity, annual project manager score, and manager evaluation

Project managers: ID, age, name, gender, and qualifications. As managers can score employees, there are also scoring methods.

Let's talk about the above two images:

View the form FrmShow

 

 

Score form FrmJudge

 

Don't talk about it. Go to the code

First, employees

1 using System. text; 2 using System. threading. tasks; 3 4 namespace manager scoring system 5 {6 public class SE 7 {8 9 // employee ID 10 public int EngineerId {get; set ;} 11 // employee Age 12 public int Age {get; set ;}13 // employee gender 14 public char Sex {get; set ;} 15 // employee Name 16 public string Name {get; set;} 17 // employee popularity 18 public int PopularValue {get; set ;} 19 // manager's annual score 20 public int MScore {get; set ;}21 // manager rating 22 public string Assess {get; set ;}23 24} 25}

Then the manager class

1 using System; 2 using System. collections. generic; 3 using System. linq; 4 using System. text; 5 using System. threading. tasks; 6 7 namespace manager scoring system 8 {9 class PM10 {11 // manager ID12 public int MId {get; set ;}13 // manager age 14 public int MAge {get; set;} 15 // manager name 16 public string MName {get; set;} 17 // manager gender 18 public char MSex {get; set ;} 19 20 // define the scoring method 21 public void Judge (SE se, String assess, int score) 22 {23 se. assess = assess; 24 se. MScore = score; 25} 26} 27}

Next, view the code in the form.

1 using System; 2 using System. collections. generic; 3 using System. componentModel; 4 using System. data; 5 using System. drawing; 6 using System. linq; 7 using System. text; 8 using System. threading. tasks; 9 using System. windows. forms; 10 11 namespace manager scoring system 12 {13 public partial class FrmShow: Form14 {15 // defines the employee array 16 public SE [] engineer = new SE [3]; 17 public FrmShow () 18 {19 InitializeComponent (); 20 Init (); // initialize SE set information 21 UpdateView (); 22} 23 24 // initialize employee information 25 public void Init () 26 {27 SE s1 = new SE (); 28 s1.EngineerId = 111; 29 s1.Age = 26; 30 s1.Name = "Wang xiaomao"; 31 s1.Assess = "not evaluated"; 32 s1.MScore = 0; 33 engineer [0] = s1; 34 35 SE s2 = new SE (); 36 s2.EngineerId = 112; 37 s2.Age = 22; 38 s2.Name = "weekly Xinyu"; 39 s2.Assess = "not evaluated"; 40 s2.MScore = 0; 41 engineer [1] = s2; 42 43 SE s3 = new SE (); 44 s3.EngineerId = 113; 45 s3.Age = 30; 46 s3.Name = "Zhang Ye"; 47 s3.Assess = "not evaluated"; 48 s3.MScore = 0; 49 engineer [2] = s3; 50 51 52} 53 54 // bind data to the lvAssess of the listview object 55 public void UpdateView () 56 {57 lvAssess. items. clear (); // refresh the data after Review 58 for (int I = 0; I <engineer. length; I ++) 59 {60 ListViewItem item = new ListViewItem (); 61 // bind employee information to 62 items in listview. text = engineer [I]. engineerId. toString (); 63 item. subItems. add (engineer [I]. name); 64 item. subItems. add (engineer [I]. age. toString (); 65 item. subItems. add (engineer [I]. MScore. toString (); 66 item. subItems. add (engineer [I]. assess); 67 this. lvAssess. items. add (item); 68} 69} 70 // double-click ListView71 private void lvAssess_DoubleClick (object sender, EventArgs e) 72 {73 // get the currently selected object 74 if (this. lvAssess. selectedItems. count = 0) 75 {76 return; // you must first select a row 77} 78 int index = 0; 79 for (int I = 0; I <engineer. length; I ++) 80 {81 if (engineer [I]. engineerId. toString () = this. lvAssess. selectedItems [0]. text. trim () 82 {83 index = I; 84 break; 85} 86} 87 // The selected object scored 88 FrmJudge frm = new FrmJudge (this, index); 89 frm. show (); 90} 97} 98}

Finally, the code written in the score form of the Manager

1 using System; 2 using System. collections. generic; 3 using System. componentModel; 4 using System. data; 5 using System. drawing; 6 using System. linq; 7 using System. text; 8 using System. threading. tasks; 9 using System. windows. forms; 10 11 namespace manager scoring system 12 {13 public partial class FrmJudge: Form14 {15 // Save the instance of the parent Form 16 public FrmShow myParent; 17 // The employee object to be evaluated 18 private SE; 19 20 // parameter: the instance of the parent form, and the scored employee in the employee Array Location 21 public FrmJudge (FrmShow fparent, int index) 22 {23 InitializeComponent (); 24 this. myParent = fparent; 25 this. se = myParent. engineer [index]; 26} 27 private void FrmJudge_Load (object sender, EventArgs e) 28 {29 // form loading, display the Name and score of the employee to be evaluated 30 this.txt Name. text = se. name; 31 this.txt PingJia. text = se. assess; 32 this.txt PingFen. text = se. MScore. toString (); 33 34} 35 // click the score button to respond to the event 36 private void btnPingFen_Clic K (object sender, EventArgs e) 37 {38 try39 {40 PM = new pm (); 41 pm.judge(se,this.txtpingjia.text.trim(,int32.parse(this.txt PingFen. text. trim (); 42 // refresh the main form 43 this. myParent. updateView (); 44 this. close (); 45} 46 catch (Exception ex) 47 {48 MessageBox. show ("rating failed! "+ Ex. toString (); 49} 50} 51 52 private void btnCancel_Click (object sender, EventArgs e) 53 {54 this. close (); 55} 56 57 58} 59}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.