
1 //=================父類=================// 2 using System; 3 using System.Collections.Generic; 4 using System.Linq; 5 using System.Text; 6 using System.Threading.Tasks; 7 8 namespace Sj2.Entity 9 { 10 /// <summary> 11 ///父類 :工作類 12 /// </summary> 13 public abstract class Job 14 { 15 public string Type { get; set; } //工作類型 16 17 public string Name { get; set; } //工作名稱 18 19 public string Description { get; set; } //工作描述 20 21 /// <summary> 22 /// 構造函數 23 /// </summary> 24 public Job(string type, string name, string description) 25 { 26 this.Name = name; 27 this.Type = type; 28 this.Description = description; 29 } 30 /// <summary> 31 /// 構造函數 32 /// </summary> 33 public Job() 34 { } 35 /// <summary> 36 /// 執行抽象方法 37 /// </summary> 38 public abstract void Execute(FrmCells na, int index); 39 40 /// <summary> 41 /// 抽象方法 42 /// </summary> 43 public abstract void Show(); 44 45 } 46 }

1 //=================員工類=================// 2 using System; 3 using System.Collections.Generic; 4 using System.Linq; 5 using System.Text; 6 using System.Threading.Tasks; 7 8 namespace Sj2.Entity 9 { 10 /// <summary> 11 /// 員工類 12 /// </summary> 13 public class SE 14 { 15 /// <summary> 16 /// 名稱 17 /// </summary> 18 public string Name { get; set; } 19 public List<Job> Lei { get; set; } 20 /// <summary> 21 /// 構造函數 22 /// </summary> 23 /// <param name="name"></param> 24 public SE(string name, List<Job> lei) 25 { 26 this.Name = name; 27 this.Lei = lei; 28 } 29 } 30 }

1 //=================編碼類=================// 2 using System; 3 using System.Collections.Generic; 4 using System.Linq; 5 using System.Text; 6 using System.Threading.Tasks; 7 using System.Windows.Forms; 8 9 namespace Sj2.Entity 10 { 11 /// <summary> 12 /// 編碼工作類 13 /// </summary> 14 public class CodeJob : Job 15 { 16 /// <summary> 17 /// 構造函數 18 /// </summary> 19 /// <param name="name"></param> 20 /// <param name="type"></param> 21 /// <param name="description"></param> 22 public CodeJob(string name, string type, string description) 23 : base(name, type, description) { } 24 25 /// <summary> 26 /// 構造函數 27 /// </summary> 28 public CodeJob() { } 29 30 /// <summary> 31 /// 有效編碼行數 32 /// </summary> 33 public int CodingLines { get; set; } 34 /// <summary> 35 /// 目前沒有解決的BUG個數 36 /// </summary> 37 public int Bugs { get; set; } 38 /// <summary> 39 /// 用時——工作日 40 /// </summary> 41 public int WorkDay { get; set; } 42 43 /// <summary> 44 /// 實現父類Job的抽象方法Execute(),打開編碼工作窗體 45 /// </summary> 46 public override void Execute(FrmCells na, int index) 47 { 48 49 FrmTypeBianma FrmBian = new FrmTypeBianma(); 50 FrmBian.na = na; 51 FrmBian.index = index; 52 FrmBian.ShowDialog(); 53 } 54 /// <summary> 55 /// Show()方法 56 /// </summary> 57 public override void Show() 58 { 59 MessageBox.Show("有效編碼行數:" + CodingLines + "\n遺留問題:" + Bugs + "\n工作日:" + WorkDay, "指標完成情況"); 60 } 61 } 62 }

1 //==========測試類===============// 2 using System; 3 using System.Collections.Generic; 4 using System.Linq; 5 using System.Text; 6 using System.Threading.Tasks; 7 using System.Windows.Forms; 8 9 namespace Sj2.Entity 10 { 11 /// <summary> 12 /// 測試工作類 13 /// </summary> 14 public class TestJob : Job 15 { 16 public TestJob(string name, string type, string description) 17 : base(name, type, description) 18 { } 19 /// <summary> 20 /// 構造函數 21 /// </summary> 22 public TestJob() { } 23 24 //編寫的用例測試個數 25 public int CaseNum { get; set; } 26 //發現的Bug 27 public int FindBugs { get; set; } 28 /// <summary> 29 ///用時 30 /// </summary> 31 public int WorkDay { get; set; } 32 33 /// <summary> 34 ///實現父類Job的抽象方法 Execute(),打開測試任務窗體 35 /// </summary> 36 public override void Execute(FrmCells na, int index) 37 { 38 FrmTypeTest frmtest = new FrmTypeTest(); 39 frmtest.ns = na; 40 frmtest.index = index; 41 frmtest.ShowDialog(); 42 } 43 /// <summary> 44 /// Show()方法 45 /// </summary> 46 public override void Show() 47 { 48 MessageBox.Show("測試用例個數:" + CaseNum + "\n發現Bug數量:" + FindBugs + "\n工作日:" + WorkDay, "指標完成情況"); 49 } 50 } 51 }

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 using Sj2.Entity; 11 12 namespace Sj2 13 { 14 public partial class FrmCells : Form 15 { 16 SE se; 17 SE se1; 18 public List<Job> list = new List<Job>(); 19 public FrmCells() 20 { 21 22 InitializeComponent(); 23 Init(); 24 UpdateJob(); 25 this.gbCells.Text = se.Name; 26 dgvInfo.AutoGenerateColumns = false; 27 } 28 29 /// <summary> 30 /// 初始員工工作列表 31 /// </summary> 32 public void Init() 33 { 34 list.Add(new CodeJob("編碼", "編碼", "實現購物車列表")); 35 list.Add(new CodeJob("編碼", "編碼基類", "完成項目基類編碼")); 36 list.Add(new TestJob("測試", "壓力測試", "測試項目已實現莫模塊")); 37 38 //初始員工信息 39 se = new SE("王小毛", list); 40 se1 = new SE("李磊", list); 41 } 42 /// <summary> 43 /// 綁定工作列表 44 /// </summary> 45 public void UpdateJob() 46 { 47 this.dgvInfo.DataSource = se.Lei; 48 } 49 /// <summary> 50 /// 執行情況 51 /// </summary> 52 /// <param name="sender"></param> 53 /// <param name="e"></param> 54 private void tmisZhiXin_Click(object sender, EventArgs e) 55 { 56 //獲取當前行 57 int index = this.dgvInfo.CurrentRow.Index; 58 //打開對應窗口,填寫完成指標——重寫父類的抽象方法Execute() 59 se.Lei[index].Execute(this, index); 60 } 61 /// <summary> 62 /// 執行完成情況 63 /// </summary> 64 /// <param name="sender"></param> 65 /// <param name="e"></param> 66 private void tmsiWanCheng_Click(object sender, EventArgs e) 67 { 68 //CodeJob co = new CodeJob(); 69 //co.Show(); 70 int index = this.dgvInfo.CurrentRow.Index; 71 list[index].Show(); 72 } 73 } 74 }

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 using Sj2.Entity; 11 12 namespace Sj2 13 { 14 public partial class FrmTypeBianma : Form 15 { 16 /// <summary> 17 /// 編碼窗體 18 /// </summary> 19 public FrmTypeBianma() 20 { 21 InitializeComponent(); 22 } 23 CodeJob job = new CodeJob(); 24 public FrmCells na; 25 public int index; 26 /// <summary> 27 /// 提交編碼工作任務 28 /// </summary> 29 /// <param name="sender"></param> 30 /// <param name="e"></param> 31 private void btnTj_Click(object sender, EventArgs e) 32 { 33 bool isError = false; 34 try 35 { 36 var d = (CodeJob)na.list[index]; 37 d.CodingLines = Int32.Parse(this.txtHangSu.Text.ToString()); 38 d.Bugs = Int32.Parse(this.txtWenti.Text.ToString()); 39 d.WorkDay = Int32.Parse(this.txtGongzr.Text.ToString()); 40 } 41 catch (Exception ex) 42 { 43 MessageBox.Show(ex.Message); 44 isError = true; 45 } 46 if (!isError) 47 { 48 MessageBox.Show("提交成功!", "提示"); 49 this.Close(); 50 } 51 } 52 53 54 } 55 }

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 using Sj2.Entity; 11 12 namespace Sj2 13 { 14 public partial class FrmTypeTest : Form 15 { 16 /// <summary> 17 /// 測試窗體 18 /// </summary> 19 public FrmTypeTest() 20 { 21 InitializeComponent(); 22 } 23 TestJob job = new TestJob(); 24 public FrmCells ns; 25 public int index; 26 //實例化對象 27 28 /// <summary> 29 /// 提交測試工作 30 /// </summary> 31 /// <param name="sender"></param> 32 /// <param name="e"></param> 33 private void btnTjTest_Click(object sender, EventArgs e) 34 { 35 bool isError = false; 36 try 37 { 38 var ds = (TestJob)ns.list[index]; 39 ds.CaseNum = Int32.Parse(txtHangSuTest.Text.ToString()); 40 ds.WorkDay = Int32.Parse(txtGongzrTest.Text.ToString()); 41 ds.FindBugs = Int32.Parse(txtWentiTest.Text.ToString()); 42 43 } 44 catch (Exception ex) 45 { 46 MessageBox.Show(ex.Message); 47 isError = true; 48 } 49 if (!isError) 50 { 51 MessageBox.Show("提交成功!", "提示"); 52 this.Close(); 53 } 54 } 55 56 } 57 }