using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Job
{
    public class CodeJob:Job
    {
        public CodeJob(string type, string name, string descrition) : base(type, name, descrition) { }
        public CodeJob() { }

        //有效代码行数
        public int CodingLines { get; set; }
        //目前没有解决的Bug个数
        public int Bugs { get; set; }
        //用时-工作日
        public int WorkDay { get; set; }

        //实现父类Job的抽象方法Execute,打开编码工作窗体
        public override void Execute(FrmWorkList fw,int index)
        {
            FrmCode frmCode = new FrmCode();
            frmCode.fw = fw;
            frmCode.index = index;
            frmCode.ShowDialog();
        }
        public override void Show()
        {
            MessageBox.Show("有效编码行数:" + CodingLines + "\n遗留问题:" + Bugs + "\n工作日:" + WorkDay, "指标完成情况", MessageBoxButtons.OK);
        }
    }
}
CodeJob类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Job
{
    public class Employee
    {
         //年龄
         public int Age { get; set; }
         //性别
         public Gender Gender { get; set; }
         //工号
         public string ID { get; set; }
         //姓名
         public string Name { get; set; }
         public List<Job> WorkList { get; set; }
         //无参构造函数
         public Employee()
         {
 
         }
         //有参构造函数
         public Employee( string name, List<Job> workList)
         {
             this.Name = name;
             this.WorkList = workList;
         }

    }
}
Employee
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Job
{
    public enum Gender
    {
        男,
        女
    }
}
枚举类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Job
{
    public abstract class Job
    {
        //工作类型
        public string Type { get; set; }
        //工作名称
        public string Name { get; set; }
        //工作描述
        public string Description { get; set; }

        public Job(string type,string name,string description)
        {
            this.Type = type;
            this.Name = name;
            this.Description = description;
        }
        public Job() { }
        //执行
        public abstract void Execute( FrmWorkList fw,int index);
        public abstract void Show();
    }
}
Job
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Job
{
    public class SE:Employee
    {
        //人气
         private int _pupularity;
 
         public int Pupularity
         {
             get { return _pupularity; }
             set { _pupularity = value; }
         }
         public SE(string name, List<Job> workList)
             : base(name, workList)
         {
 
         }
    }
}
SE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Job
{
    public class TestJob:Job
    {
        public TestJob(string type, string name, string descrition) : base(type, name, descrition) { }
        public TestJob() { }

        //编写测试用例个数
        public int CaseNum { get; set; }
        //发现的Bugs
        public int FindBugs { get; set; }
        //用时
        public int WorkDay { get; set; }

        //实现父类Job的抽象方法Execute,打开测试任务窗体
        public override void Execute(FrmWorkList fw,int index)
        {
            FrmTest frmTest = new FrmTest();
            frmTest.fw = fw;
            frmTest.index = index;
            frmTest.ShowDialog();
        }
        public override void Show()
        {
            MessageBox.Show("测试用例个数:" + CaseNum + "\n发现的Bug数量:" + FindBugs + "\n工作日:" + WorkDay, "指标完成情况", MessageBoxButtons.OK);
        }
    }
}
TestJob
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 Job
{
    public partial class FrmWorkList : Form
    {
        public FrmWorkList()
        {
            InitializeComponent();
            Init();
            UpdateJob();
            this.groupBox1.Text = empl.Name;
        }
        Employee empl;//定义员工对象
        public List<Job> jobList = new List<Job>();
        public void Init()
        {
            
            jobList.Add(new CodeJob("编码","编码","实现购物车模块"));
            jobList.Add(new CodeJob("编码", "编码基类", "完成项目基类编码"));
            jobList.Add(new TestJob("测试", "压力测试", "测试项目实现模块"));
            //实例化员工对象
            empl = new SE("王小毛",jobList);
        }
        //绑定工作列表
        public void UpdateJob()
        {
            this.dgvWorkList.DataSource = empl.WorkList;
        }

        //填写执行情况
        private void 执行ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //获取当行
            int index = this.dgvWorkList.CurrentRow.Index;
            //打开对应窗口,填写完成指标——重写父类方法Execute()
            empl.WorkList[index].Execute(this,index);
        }

        private void 测试ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmTest frmTest = new FrmTest();
            frmTest.ShowDialog();
        }

        private void 完成情况ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int index = this.dgvWorkList.CurrentRow.Index;
            empl.WorkList[index].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 Job
{
    public partial class FrmTest : Form
    {
        //测试工作对象
        TestJob job = new TestJob();
        public FrmTest()
        {
            InitializeComponent();
        }

        public FrmWorkList fw;
        public int index;
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            bool isError = false;
            try
            {
                var test = (TestJob)fw.jobList[index];
                test.CaseNum = Int32.Parse(this.txtCaseNum.Text.ToString());
                test.FindBugs = Int32.Parse(this.txtFindBugs.Text.ToString());
                test.WorkDay = Int32.Parse(this.txtWorkDay.Text.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                isError = true;
            }
            if (!isError)
            {
                MessageBox.Show("提交成功!", "提示");
                this.Close();
            }
        }
    }
}
测试窗体
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 Job
{
    public partial class FrmCode : Form
    {
        //编码工作对象
        CodeJob job = new CodeJob();
        public FrmCode()
        {
            InitializeComponent();
        }
        public FrmWorkList fw;
        public int index;
        //提交编码工作任务
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            bool isError = false;
            try
            {
                job.CodingLines = Int32.Parse(this.txtCoingLists.Text.ToString());
                job.Bugs = Int32.Parse(this.txtBugs.Text.ToString());
                job.WorkDay = Int32.Parse(this.txtWorkDay.Text.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                isError = true;
            }
            if (!isError)
            {
                MessageBox.Show("提交成功!","提示");
                this.Close();
            }
        }
    }
}
编码窗体

 

posted on 2017-04-12 17:03  Crazy丶忠祥  阅读(117)  评论(0编辑  收藏  举报