首页 > 代码库 > 员工执行
员工执行
{ //父类工作类 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 descrition) { this.Type = type; this.Name = name; this.Description = descrition; } public Job() { } //执行 public abstract void Execute(); //显示 public abstract string Show(); } --------------------------------------------------------- public class TestJob:Job { public TestJob(string type, string name, string desc):base(type, name, desc){} public TestJob(){} //编写的测试类用例的个数 public int CaseNum{get;set;} //发现的Bugs public int FindBugs{get;set;} //用时 public int WorkDay{get;set;} //实现父类Job的抽象方法Execte(),打开测试任务窗体 public override void Execute() { FrmTestExe frm=new FrmTestExe(); frm.ShowDialog(); } public override string Show() { this.CaseNum = 200; this.Description = "代码"; this.FindBugs = 9; this.WorkDay = 5; string info = string.Format("编写用例个数:{0}\n发现的Bug数量:{1}\n工作日:{2}", this.Name, this.CaseNum, this.FindBugs, this.WorkDay); return info; } } ------------------------------------------------------------------------------------- namespace Frmjobs { //编写工作类 public class CodeJob:Job { public CodeJob(string type, string name, string desc) : base(type, name, desc) { } public CodeJob() { } //有效的编码行数 public int CodingLines { get; set;} //目前没有解决的Bug个数 public int Bugs { get; set;} //用时-工作日 public int WorkDay { get; set;} //实现父类job的抽象方法Execute(),打开编码工作窗体 public override void Execute() { FrmcodeExe frmcodeexe = new FrmcodeExe(); frmcodeexe.ShowDialog(); } //显示 public override string Show() { this.CodingLines = 1000; this.Description = "代码"; this.Bugs = 9; this.WorkDay = 5; string info = string.Format("有效编码行数{0}\n遗留问题:{1}\n工作日:{2}\n", this.CodingLines, this.Bugs, this.WorkDay); return info; } } } -------------------------------------------------------------------------------------- public enum Gender { 男, 女 } ------------------------------------------------------------------------------------ namespace Frmjobs { public class Employee { public Employee(string id, int age, string name, Gender gender, List<Job> list) { this.ID = id; this.Age = age; this.Name = name; this.Gender = gender; this.WorkList = list; } public Employee() { } /// <summary> /// 工号 /// </summary> protected string ID { get; set; } /// <summary> /// 年龄 /// </summary> protected int Age { get; set; } /// <summary> /// 姓名 /// </summary> public string Name { get; set; } /// <summary> /// 性别 /// </summary> protected Gender Gender { get; set; } /// <summary> /// 工作列表 /// </summary> public List<Job> WorkList{ get; set; } public virtual string DoWork() { return "工作列表"; } } } ---------------------------------------------------------------------------------------- namespace Frmjobs { /// <summary> /// 程序员类 /// </summary> public class SE:Employee { public SE(string id, string name, int age, Gender gender, int popularity, List<Job> list) : base(id, age, name, gender, list) { this.Popularity = popularity; } public SE() { } /// <summary> /// 人气值 /// </summary> private int _popularity; public int Popularity { get { return _popularity; } set { _popularity = value; } } /// <summary> /// 工作 /// </summary> /// <returns></returns> public override string DoWork() { StringBuilder sb = new StringBuilder(); sb.Append(this.Name+"\n"); for (int i = 0; i < this.WorkList.Count;i++ ) { sb.Append((i+1)+"、"+WorkList[i].Name+":"+WorkList[i].Description+"\n"); } return sb.ToString(); } } } ------------------------------------------------------------------------------------ namespace Frmjobs { public class Pm:Employee { public Pm(string id, string name, int age, Gender gender, int yearOfExperience, List<Job> list):base(id, age, name, gender,list) { this.YearOfExperience = yearOfExperience; } public Pm() { } /// <summary> /// 资历 /// </summary> private int _yearOfExperience; public int YearOfExperience { get { return _yearOfExperience; } set { _yearOfExperience = value; } } //工作 public override string DoWork() { string message = this.Name + ":管理员工完成工作内容!"; return message; } } } --------------------------------------------------------------------------------------- namespace Frmjobs { public partial class FrmTestExe : Form { public FrmTestExe() { InitializeComponent(); } //测试工作对象 TestJob job = new TestJob(); //提交的事件 private void btn_tijaio_Click(object sender, EventArgs e) { bool isError = false; try { job.CaseNum = Int32.Parse(this.txt_CaseNum.Text.Trim()); job.FindBugs = Int32.Parse(this.txt_sum.Text.Trim()); job.WorkDay = Int32.Parse(this.txt_day.Text.Trim()); } catch (Exception ex) { MessageBox.Show(ex.Message); isError = true; } if(!isError) { MessageBox.Show("提交成功","提示"); //关闭窗体 this.Close(); } } //加载事件 private void FrmTestExe_Load(object sender, EventArgs e) { txt_CaseNum.Text = "200"; txt_sum.Text = "6"; txt_day.Text = "25"; } } } ----------------------------------------------------------------------------------- namespace Frmjobs { public partial class FrmcodeExe : Form { public FrmcodeExe() { InitializeComponent(); } //编码工作对象 CodeJob job = new CodeJob(); //提交编码工作任务 private void btn_tijaio_Click(object sender, EventArgs e) { bool iserror = false; try { job.CodingLines = Int32.Parse(this.txt_Day.Text.Trim()); job.Bugs = Int32.Parse(this.txt_Bugs.Text.Trim()); job.WorkDay = Int32.Parse(this.txt_Day.Text.Trim()); } catch (Exception ex) { MessageBox.Show(ex.Message); iserror = true; } if(!iserror) { MessageBox.Show("提交成功","提示"); //关闭窗体 this.Close(); } } //加载的事件 private void FrmcodeExe_Load(object sender, EventArgs e) { this.txt_Rowst.Text = "1000"; this.txt_Bugs.Text = "6"; this.txt_Day.Text = "25"; } } } ---------------------------------------------------------------------------------------- namespace Frmjobs { public partial class Frmjobs : Form { public Frmjobs() { InitializeComponent(); } Employee employee; //加载的事件 private void Frmjobs_Load(object sender, EventArgs e) { dgv_list.AutoGenerateColumns = false; Init(); UpdateJob(); this.groupBox1.Text = employee.Name; } //初始化某员工 public void Init() { List<Job> job = new List<Job>(); job.Add(new CodeJob("编码","编码","实现购物车模块")); job.Add(new CodeJob("编码","编码基类","完成项目基类编码")); job.Add(new TestJob("测试","压力测试","测试项目已实现模块")); //实例化员工对象 employee = new SE("1120","王小毛",24,Gender.男,100,job); } //绑定工作列表 public void UpdateJob() { this.dgv_list.DataSource = employee.WorkList; } //执行的事件 private void con_zhixin_Click(object sender, EventArgs e) { //获取当前行 int index = this.dgv_list.CurrentRow.Index; //打开对应窗口,填写完成指标---多态 employee.WorkList[index].Execute(); } //显示完成情况 private void con_wancheng_Click(object sender, EventArgs e) { //获取当前行 int index = this.dgv_list.CurrentRow.Index; string info = employee.WorkList[index].Show(); MessageBox.Show(info,"指标完成情况"); } } }
员工执行
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。