================================================实体================================================
-------------------------------------------员工类-------------------------------------------
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace SJ2.entity 8 { 9 /// <summary> 10 /// 员工类 11 /// </summary> 12 public class Empolyee 13 { 14 /// <summary> 15 /// 姓名 16 /// </summary> 17 public string Name { get; set; } 18 /// <summary> 19 /// 工作列表 20 /// </summary> 21 public List<Job> WorkList { get; set; } 22 public Empolyee(string name,List<Job> workList) 23 { 24 this.Name = name; 25 this.WorkList = workList; 26 } 27 } 28 }
-------------------------------------------父类工作类-------------------------------------------
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace SJ2.entity 8 { 9 /// <summary> 10 /// 工作类 11 /// </summary> 12 public abstract class Job 13 { 14 /// <summary> 15 /// 工作名称 16 /// </summary> 17 public string Name { get; set; } 18 /// <summary> 19 /// 工作类型 20 /// </summary> 21 public string Type { get; set; } 22 /// <summary> 23 /// 工作描述 24 /// </summary> 25 public string Desc { get; set; } 26 27 public Job(string name,string type,string desc) 28 { 29 this.Desc = desc; 30 this.Name = name; 31 this.Type = type; 32 } 33 public Job() 34 { 35 } 36 37 /// <summary> 38 /// 打开窗体 39 /// </summary> 40 public abstract void Execute(frmMain fm,int index); 41 42 /// <summary> 43 /// 打开提示框 44 /// </summary> 45 public abstract void Show(); 46 } 47 }
-------------------------------------------子类测试类-------------------------------------------
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 using System.Windows.Forms; 7 8 namespace SJ2.entity 9 { 10 /// <summary> 11 /// 测试类 12 /// </summary> 13 public class CeShi:Job 14 { 15 public CeShi(string name, string type, string desc) 16 : base(name, type, desc) 17 { 18 } 19 public CeShi() 20 { 21 } 22 23 /// <summary> 24 /// 测试用例个数 25 /// </summary> 26 public int CeShiNo { get; set; } 27 28 /// <summary> 29 /// f发现的BUG数量 30 /// </summary> 31 public int BugCount { get; set; } 32 33 /// <summary> 34 /// 所需工作日 35 /// </summary> 36 public int NeedDay { get; set; } 37 38 /// <summary> 39 /// 打开测试窗体 40 /// </summary> 41 public override void Execute(frmMain fm,int index) 42 { 43 frmCeShi fcs = new frmCeShi(); 44 //传相应信息 45 fcs.fm = fm; 46 fcs.index = index; 47 fcs.ShowDialog(); 48 } 49 50 /// <summary> 51 /// 打开提示框 52 /// </summary> 53 public override void Show() 54 { 55 StringBuilder sb = new StringBuilder(); 56 sb.Append("测试用例个数:" + CeShiNo + " 发现的BUG数量:" + BugCount + " 工作日:" + NeedDay); 57 MessageBox.Show(sb.ToString(),"指标完成情况"); 58 } 59 } 60 }
-------------------------------------------子类编码类-------------------------------------------
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 using System.Windows.Forms; 7 8 namespace SJ2.entity 9 { 10 /// <summary> 11 /// 编码类 12 /// </summary> 13 public class BianMa:Job 14 { 15 public BianMa(string name, string type, string desc) 16 : base(name, type, desc) 17 { 18 } 19 public BianMa() 20 { 21 } 22 23 /// <summary> 24 /// 有效编码行数 25 /// </summary> 26 public int YesRow { get; set; } 27 28 /// <summary> 29 /// 遗留问题 30 /// </summary> 31 public string Pro { get; set; } 32 33 /// <summary> 34 /// 所需工作日 35 /// </summary> 36 public int NeedDay { get; set; } 37 38 /// <summary> 39 /// 打开编码窗体 40 /// </summary> 41 public override void Execute(frmMain fm,int index) 42 { 43 frmBianMa fbm = new frmBianMa(); 44 //传相应信息 45 fbm.fm = fm; 46 fbm.index = index; 47 fbm.ShowDialog(); 48 } 49 50 /// <summary> 51 /// 打开提示框 52 /// </summary> 53 public override void Show() 54 { 55 StringBuilder sb = new StringBuilder(); 56 sb.Append("有效编码行数:" + YesRow + " 遗留问题:" + Pro + " 工作日:" + NeedDay); 57 MessageBox.Show(sb.ToString(), "指标完成情况"); 58 } 59 } 60 }
================================================窗体================================================
-------------------------------------------主窗体-------------------------------------------
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 using SJ2.entity; 2 using System; 3 using System.Collections.Generic; 4 using System.ComponentModel; 5 using System.Data; 6 using System.Drawing; 7 using System.Linq; 8 using System.Text; 9 using System.Threading.Tasks; 10 using System.Windows.Forms; 11 12 namespace SJ2 13 { 14 public partial class frmMain : Form 15 { 16 public frmMain() 17 { 18 InitializeComponent(); 19 } 20 /// <summary> 21 /// 员工 22 /// </summary> 23 public Empolyee empolyee ; 24 25 private void frmMain_Load(object sender, EventArgs e) 26 { 27 Init(); 28 BangGroupBoxText(); 29 BangList(); 30 } 31 32 /// <summary> 33 /// 初始化 34 /// </summary> 35 public void Init() 36 { 37 List<Job> lj =new List<Job>(); 38 Job job = new CeShi("压力测试", "测试", "测试项目"); 39 Job job1 = new BianMa("编码", "编码", "实现购物车模块"); 40 Job job2 = new BianMa("编码基类", "编码", "完成项目基类"); 41 lj.Add(job); 42 lj.Add(job1); 43 lj.Add(job2); 44 45 46 empolyee = new Empolyee("王小毛",lj); 47 } 48 49 /// <summary> 50 /// 绑定GroupBox名字 51 /// </summary> 52 public void BangGroupBoxText() 53 { 54 gbName.Text = empolyee.Name; 55 } 56 57 /// <summary> 58 /// 绑定列表 59 /// </summary> 60 public void BangList() 61 { 62 dgvList.DataSource = empolyee.WorkList; 63 } 64 65 /// <summary> 66 /// 单击执行 67 /// </summary> 68 /// <param name="sender"></param> 69 /// <param name="e"></param> 70 private void tsmiDo_Click(object sender, EventArgs e) 71 { 72 //找到选中行的索引 73 int index = this.dgvList.CurrentRow.Index; 74 //按照添加顺序用索引找对应方法,并传本窗体和索引过去 75 empolyee.WorkList[index].Execute(this,index); 76 } 77 78 private void 完成情况ToolStripMenuItem_Click(object sender, EventArgs e) 79 { 80 int index = this.dgvList.CurrentRow.Index; 81 empolyee.WorkList[index].Show(); 82 } 83 } 84 }
-------------------------------------------测试窗体-------------------------------------------
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 using SJ2.entity; 2 using System; 3 using System.Collections.Generic; 4 using System.ComponentModel; 5 using System.Data; 6 using System.Drawing; 7 using System.Linq; 8 using System.Text; 9 using System.Threading.Tasks; 10 using System.Windows.Forms; 11 12 namespace SJ2 13 { 14 public partial class frmCeShi : Form 15 { 16 public frmCeShi() 17 { 18 InitializeComponent(); 19 //name = fm.empolyee.WorkList[index].Name; 20 //type = fm.empolyee.WorkList[index].Type; 21 //des = fm.empolyee.WorkList[index].Desc; 22 } 23 //string name; 24 //string type; 25 //string des; 26 27 28 public frmMain fm; 29 public int index; 30 private void btnSubmit_Click(object sender, EventArgs e) 31 { 32 //按照传过来的信息更改对应内容 33 ((CeShi)fm.empolyee.WorkList[index]).NeedDay = int.Parse(txtNeedDay.Text); 34 ((CeShi)fm.empolyee.WorkList[index]).BugCount = int.Parse(txtBugCount.Text); 35 ((CeShi)fm.empolyee.WorkList[index]).CeShiNo = int.Parse(txtCeShiNo.Text); 36 37 MessageBox.Show("提交成功"); 38 this.Close(); 39 } 40 41 42 } 43 }
-------------------------------------------编码窗体-------------------------------------------
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 using SJ2.entity; 2 using System; 3 using System.Collections.Generic; 4 using System.ComponentModel; 5 using System.Data; 6 using System.Drawing; 7 using System.Linq; 8 using System.Text; 9 using System.Threading.Tasks; 10 using System.Windows.Forms; 11 12 namespace SJ2 13 { 14 public partial class frmBianMa : Form 15 { 16 public frmBianMa() 17 { 18 InitializeComponent(); 19 } 20 21 public frmMain fm; 22 public int index; 23 private void btnSubmit_Click(object sender, EventArgs e) 24 { 25 //按照传过来的信息更改对应内容 26 ((BianMa)fm.empolyee.WorkList[index]).NeedDay = int.Parse(txtNeedDay.Text); 27 ((BianMa)fm.empolyee.WorkList[index]).YesRow = int.Parse(txtYesRow.Text); 28 ((BianMa)fm.empolyee.WorkList[index]).Pro = txtPro.Text; 29 30 MessageBox.Show("提交成功"); 31 this.Close(); 32 } 33 } 34 }