基於C#編寫經理評分系統的詳解(圖文)

來源:互聯網
上載者:User
最近接了這樣一個項目,要求使用c#編寫經理評分系統,需求,要顯示員工資訊,實現專案經理給員工評分功能,今天小編分步驟給大家介紹,需要的的朋友參考下

先寫需求:

01.顯示員工資訊

02.實現專案經理給員工評分的功能

第一步:

建立兩個類,員工類和專案經理類

定義屬性和方法

員工類:工號、年齡、姓名、人氣值、專案經理年度評分、經理評價

專案經理類:ID、年齡、姓名、性別、資曆,由於經理可以給員工評分,因此還有評分的方法

先上兩張圖再說:

查看表單FrmShow

評分表單FrmJudge

不說了,上代碼

首先是員工類


using System.Text;using System.Threading.Tasks;namespace 經理評分系統{  public class SE  {    //員工工號    public int EngineerId { get; set; }    //員工年齡    public int Age { get; set; }    //員工性別    public char Sex { get; set; }    //員工姓名    public string Name { get; set; }    //員工人氣值    public int PopularValue { get; set; }    //經理年度評分    public int MScore { get; set; }    //經理評價    public string Assess { get; set; }  }}

然後是經理類


using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 經理評分系統{  class PM  {    //經理ID    public int MId { get; set; }    //經理年齡    public int MAge{ get; set; }    //經理姓名    public string MName { get; set; }    //經理性別    public char MSex{get; set; }    //定義評分方法    public void Judge(SE se,String assess,int score)    {      se.Assess = assess;      se.MScore = score;    }  }}

接下來是查看表單中的代碼


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 經理評分系統{  public partial class FrmShow : Form  {    //定義員工數組    public SE[] engineer=new SE[3];    public FrmShow()    {      InitializeComponent();      Init();  //初始化SE集合資訊      UpdateView();    }    //初始化員工資訊    public void Init()     {      SE s1 = new SE();      s1.EngineerId = 111;      s1.Age = 26;      s1.Name = "王小毛";      s1.Assess = "未評價";      s1.MScore = 0;      engineer[0]=s1;      SE s2 = new SE();      s2.EngineerId = 112;      s2.Age = 22;      s2.Name = "周新雨";      s2.Assess = "未評價";      s2.MScore = 0;      engineer[1] = s2;      SE s3 = new SE();      s3.EngineerId = 113;      s3.Age = 30;      s3.Name = "張燁";      s3.Assess = "未評價";      s3.MScore = 0;      engineer[2] = s3;    }    //將資料繫結到listview對象的lvAssess上    public void UpdateView()    {      lvAssess.Items.Clear();//評價後對資料進行重新整理      for (int i = 0; i < engineer.Length;i++ )       {        ListViewItem item = new ListViewItem();        //將員工資訊綁定到listview中        item.Text = engineer[i].EngineerId.ToString();        item.SubItems.Add(engineer[i].Name);        item.SubItems.Add(engineer[i].Age.ToString());        item.SubItems.Add(engineer[i].MScore.ToString());        item.SubItems.Add(engineer[i].Assess);        this.lvAssess.Items.Add(item);      }    }    //雙擊ListView    private void lvAssess_DoubleClick(object sender, EventArgs e)    {      //擷取當前選中的對象      if(this .lvAssess.SelectedItems.Count==0)      {        return;//必須先選中一行      }      int index = 0;      for (int i = 0; i < engineer.Length;i++)      {        if(engineer[i].EngineerId.ToString()==this.lvAssess.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 經理評分系統{  public partial class FrmJudge : Form  {    //儲存父表單的執行個體    public FrmShow myParent;    //要評價的員工對象    private SE se;    //參數:父表單的執行個體、被評分的員工在員工數組中的位置    public FrmJudge(FrmShow fparent,int index)    {      InitializeComponent();      this.myParent = fparent;      this.se = myParent.engineer[index];    }    private void FrmJudge_Load(object sender, EventArgs e)    {      //表單載入,顯示要評價的員工的姓名和得分等資訊      this.txtName.Text = se.Name;      this.txtPingJia.Text = se.Assess;      this.txtPingFen.Text = se.MScore.ToString();    }    //點擊評分按鈕響應事件    private void btnPingFen_Click(object sender, EventArgs e)    {      try      {        PM pm = new PM();        pm.Judge(se,this.txtPingJia.Text.Trim(),Int32.Parse(this.txtPingFen.Text.Trim()));        //重新整理主表單        this.myParent.UpdateView();        this.Close();      }      catch (Exception ex)      {        MessageBox.Show("評分失敗!"+ex.ToString());      }    }    private void btnCancel_Click(object sender, EventArgs e)    {      this.Close();    }  }}
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.