第二章項目經理評分

来源:http://www.cnblogs.com/wangdan123/archive/2017/03/15/6553505.html
-Advertisement-
Play Games

//程式員類(員工類) amespace MyOffice { //程式員類(員工類) public class SE { // 工號 public string ID { get; set; } // 年齡 public int Age { get; set; } ///姓名 public str ...


//程式員類(員工類)

amespace MyOffice

{

//程式員類(員工類)

public class SE
{

// 工號
public string ID { get; set; }

// 年齡
public int Age { get; set; }

///姓名
public string Name { get; set; }

// 性別
public Gender Gender { get; set; }

// 人氣值
private int _popularity = 0;

public int Popularity
{
get { return _popularity; }
set { _popularity = value; }
}


// 經理年度評分

private int _score = 0;

public int Score
{
get { return _score; }
set { _score = value; }
}

// 經理評價

private String _assess = "未評價";

public String Assess
{
get { return _assess; }
set { _assess = value; }
}

//public string SayHi()
//{
// string message = string.Format("大家好,我是 {0}, 今年 {1}歲,工號是 {2},我的人氣值高達 {3}!",this.Name,this.Age,this.ID,this.Popularity);
// return message;
//}

}

}

 

// 項目經理類

class PM
{
// ID
private string _id;
public string ID
{
set { _id = value; }
get { return _id; }
}

// 年齡

private int _age;
public int Age
{
get { return _age; }
set
{
if (value >= 30 && value <= 100)
{
_age = value;
}
else
{
_age = 30;
}
}
}


//姓名
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}


// 性別
private Gender _gender;
public Gender Gender
{
get { return _gender; }
set { _gender = value; }
}


//資歷

private int _yearOfExperience;
public int YearOfExperience
{
get { return _yearOfExperience; }
set { _yearOfExperience = value; }
}


// 問好
// <returns>問好的內容</returns>
public string SayHi()
{
string message;
message = string.Format(
"大家好,我是 {0} ,今年 {1} 歲,項目管理經驗 {2}年。",
this._name, this._age, this._yearOfExperience
);
return message;
}


// 項目經理評分

// <param name="se"></param>
public void Judge(SE se, String assess, int score)
{
se.Assess = assess;
se.Score = score;
}
}
}

//性別枚舉
public enum Gender
{
male,
female
}
}

//主窗體

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MyOffice
{
public partial class FrmJudge : Form
{
private FrmShow myParent; //主窗體

private SE se; //被評分的員工對象


public FrmJudge(FrmShow fparent,int index)
{
InitializeComponent();
this.myParent = fparent;
this.se = myParent.engineers[index];
}

//載入時填充信息

private void FrmJudge_Load(object sender, EventArgs e)
{
this.txtName.Text = se.Name;
this.txtAssess.Text = se.Assess;
this.txtScore.Text = se.Score.ToString();
}

//評分響應事件
private void btnOK_Click(object sender, EventArgs e)
{
try
{
PM pm = new PM();
pm.Judge(se,this.txtAssess.Text.Trim(),Int32.Parse(this.txtScore.Text.Trim()));
this.myParent.UpdateView(); //刷新主窗體
this.Close();
}
catch (Exception ex)
{
MessageBox.Show("評分失敗!" + ex.ToString());
}
}

//取消按鈕
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

 

/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.txtName = new System.Windows.Forms.TextBox();
this.txtScore = new System.Windows.Forms.TextBox();
this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.txtAssess = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(17, 30);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 12);
this.label1.TabIndex = 0;
this.label1.Text = "員工姓名";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(17, 70);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 12);
this.label2.TabIndex = 1;
this.label2.Text = "填寫評價";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(17, 128);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 12);
this.label3.TabIndex = 2;
this.label3.Text = "年度評分";
//
// txtName
//
this.txtName.Location = new System.Drawing.Point(90, 21);
this.txtName.Name = "txtName";
this.txtName.ReadOnly = true;
this.txtName.Size = new System.Drawing.Size(212, 21);
this.txtName.TabIndex = 3;
//
// txtScore
//
this.txtScore.Location = new System.Drawing.Point(90, 120);
this.txtScore.Name = "txtScore";
this.txtScore.Size = new System.Drawing.Size(212, 21);
this.txtScore.TabIndex = 5;
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(90, 160);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 7;
this.btnOK.Text = "評分";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(171, 160);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 8;
this.btnCancel.Text = "取消";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// txtAssess
//
this.txtAssess.Location = new System.Drawing.Point(90, 61);
this.txtAssess.Multiline = true;
this.txtAssess.Name = "txtAssess";
this.txtAssess.Size = new System.Drawing.Size(217, 53);
this.txtAssess.TabIndex = 9;
//
// FrmJudge
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(319, 204);
this.Controls.Add(this.txtAssess);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.txtScore);
this.Controls.Add(this.txtName);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "FrmJudge";
this.Text = "評分";
this.Load += new System.EventHandler(this.FrmJudge_Load);
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtName;
private System.Windows.Forms.TextBox txtScore;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.TextBox txtAssess;
}
}

 

 

//員工集合信息

public partial class FrmShow : Form
{
public SE[] engineers = new SE[3]; //員工集合信息


public FrmShow()
{
InitializeComponent();
this.Init(); //初始化員工集合信息
this.UpdateView(); //刷新顯示
}


// 員工信息初始化

public void Init()
{
SE jack = new SE();
jack.Name = "王小毛";
jack.Age = 26;
jack.Gender = Gender.male;
jack.ID = "111";

SE joe = new SE();
joe.Name = "周新雨";
joe.Age = 22;
joe.Gender = Gender.female;
joe.ID = "112";

SE ema = new SE();
ema.Name = "張燁";
ema.Age = 30;
ema.Gender = Gender.male;
ema.ID = "113";

engineers[0] = jack;
engineers[1] = joe;
engineers[2] = ema;
}

// 刷新ListView顯示
public void UpdateView()
{
lvAssess.Items.Clear(); //清空信息
for (int i = 0; i < engineers.Length; i++)
{
ListViewItem item = new ListViewItem();
item.Text = engineers[i].ID;
item.SubItems.Add(engineers[i].Name); //設置姓名
item.SubItems.Add(engineers[i].Age.ToString()); //設置年齡
item.SubItems.Add(engineers[i].Score.ToString()); //設置評分
item.SubItems.Add(engineers[i].Assess); //設置評價
this.lvAssess.Items.Add(item); //添加項

}
}


//雙擊執行評分
//<param name="sender"></param>
// <param name="e"></param>
private void lvAssess_DoubleClick(object sender, EventArgs e)
{
//獲取當前選中的員工對象
if (this.lvAssess.SelectedItems.Count == 0)
{
return;
}
int index = 0;
for(int i = 0; i<engineers.Length;i++)
{
if (engineers[i].ID == this.lvAssess.SelectedItems[0].Text.Trim())
{
index = i;
break;
}
}
//對選中對象評分
FrmJudge frm = new FrmJudge(this,index);
frm.Show();
}

}
}

 

namespace MyOffice
{
partial class FrmShow
{

//Required designer variable.

private System.ComponentModel.IContainer components = null;

//Clean up any resources being used.

//<param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code


// Required method for Designer support - do not modify
//the contents of this method with the code editor.

private void InitiaryalizeComponent()
{
this.lvAssess = new System.Windows.Forms.ListView();
this.cheaderName = new System.Windows.Forms.ColumnHeader();
this.cheaderID = new System.Windows.Forms.ColumnHeader();
this.cheaderAge = new System.Windows.Forms.ColumnHeader();
this.cheaderAsess = new System.Windows.Forms.ColumnHeader();
this.cheaderScore = new System.Windows.Forms.ColumnHeader();
this.SuspendLayout();
//
// lvAssess
//
this.lvAssess.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.cheaderID,
this.cheaderName,
this.cheaderAge,
this.cheaderScore,
this.cheaderAsess});
this.lvAssess.FullRowSelect = true;
this.lvAssess.GridLines = true;
this.lvAssess.Location = new System.Drawing.Point(12, 12);
this.lvAssess.Name = "lvAssess";
this.lvAssess.Size = new System.Drawing.Size(453, 230);
this.lvAssess.TabIndex = 0;
this.lvAssess.UseCompatibleStateImageBehavior = false;
this.lvAssess.View = System.Windows.Forms.View.Details;
this.lvAssess.DoubleClick += new System.EventHandler(this.lvAssess_DoubleClick);
//
// cheaderName
//
this.cheaderName.Text = "姓名";
//
// cheaderID
//
this.cheaderID.Text = "工號";
//
// cheaderAge
//
this.cheaderAge.Text = "年齡";
//
// cheaderAsess
//
this.cheaderAsess.DisplayIndex = 3;
this.cheaderAsess.Text = "評價";
//
// cheaderScore
//
this.cheaderScore.DisplayIndex = 4;
this.cheaderScore.Text = "年度得分";
//
// FrmShow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(477, 254);
this.Controls.Add(this.lvAssess);
this.Name = "FrmShow";
this.Text = "查看評分";
this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.ListView lvAssess;
private System.Windows.Forms.ColumnHeader cheaderID;
private System.Windows.Forms.ColumnHeader cheaderName;
private System.Windows.Forms.ColumnHeader cheaderAge;
private System.Windows.Forms.ColumnHeader cheaderAsess;
private System.Windows.Forms.ColumnHeader cheaderScore;
}
}

// 應用程式的主入口點。

static class Program
{

[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmShow());
}
}

 

 

 

 

 

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 之前要在linux下麵安裝nginx,弄了半天,終於搞定了,下麵給大家詳細一下安裝流程及安裝報錯解決方案: 安裝共分為5步搞定: 1.進入src目錄(下載存放目錄) cd /usr/local/src/ 2.wget下載:http://nginx.org/en/download.html(nginx ...
  • Windows 10 中包含了一個 WSL(Windows Subsystem for Linux)子系統,我們可以在其中運行未經修改過的原生 Linux ELF 可執行文件。利用它我們可以做很多事情,對開發人員和普通用戶都是如此。當然對開發人員的吸引力更大一些,因為這意味著在一些情況,不再需要使用... ...
  • 本文首發於:http://www.fengzheng.pub/archives/238.html 背景說明 伺服器為阿裡雲 ECS,操作系統為 CentOS 6.5。 部署配置說明 第一步,安裝nginx 之所以要先安裝 nginx,是因為下麵配置功能變數名稱解析的時候可以直接在瀏覽器看到效果,當然了,先配 ...
  • 序言 提到LVS,就從章文嵩博士開始吧,反正也不知道如何下筆來寫這一篇。章大博士,讀博時候創建這個lvs軟體項目,但是他提倡開源精神,在用戶的建議和反饋中,這個花了他兩周時間開發的開源軟體不斷得到改建和豐富。到1999年,該款軟體已在負載均衡領域中比較出名,章文嵩仍舊堅持開源,將源代碼分享給所有人。 ...
  • 前兩篇介紹了uboot 2013.01的配置原理以及大體的運行流程,本文將討論如何對uboot源碼進行配置,將一個可用的uboot燒錄到SD卡中。 定製自己的core board 市面上能買到的開發板的核心板基本都是基於官方參考板製作的,所以雖然標準操作是"定製"自己的core board,但鑒於我 ...
  • 經過了上一篇的配置,我們已經執行make就可以編譯出一個uboot.bin,但這還不夠,首先,此時的uboot並不符合三星晶元對bootloader的格式要求,其次,此時的uboot.bin也沒有結合我們的開發板進行配置,還無法使用。而要進行這樣的個性化配置,前提條件就是對uboot開機流程和編譯系 ...
  • 1、Linux內核與發行版 Linux本身指的是一個操作系統的內核,而內核是無法直接使用的,只有既包括內核又包括一些有用的應用程式的一個集合體,即Linux的發行版才是我們所需要的; Linux的發行版:Debian(Debian運行起來極其穩定,適合用於伺服器)、Gentoo(包含數量眾多的軟體包 ...
  • namespace 員工信息維護{ public partial class FrmMain : Form { public FrmMain() { InitializeComponent(); } //列表,用於保存 SE 對象 public List<SE> programmerList = n ...
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...