码迷,mamicode.com
首页 > 其他好文 > 详细

第七章课后作业

时间:2017-04-12 14:23:25      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:nbsp   win   partial   取消   glin   div   data   obj   auto   

技术分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace lesson7_2
{
    /// <summary>
    /// 测试工作类
    /// </summary>
    public class TestJob:Job
    {
        public TestJob(string type, string name, string description)
            : base(type, name, description)
        {
        }
        public TestJob() { }
        public int CaseNum { get; set; }
        public int FindBugs { get; set; }
        public int WorkDay { get; set; }
        //打开测试窗体
        public override void Execute(Form1 f,int index)
        {
            FrmTestExe frmtestExe = new FrmTestExe();
            frmtestExe.f = f;
            frmtestExe.index = index;
            frmtestExe.ShowDialog();
        }

        public override void Show()
        {
            MessageBox.Show("测试用例个数:" + CaseNum + "\n发现的Bug数量:" + FindBugs + "\n工作日:" + WorkDay, "指标完成情况", MessageBoxButtons.OK);
        }

    }
}
工作测试类
技术分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace lesson7_2
{
    //编码类
    public class CodeJob:Job
    {
        public int CodingLines { get; set; }
        public int Bugs { get; set; }
        public int WorkDay { get; set; }
        public CodeJob()
        {

        }
        public CodeJob(string type, string name, string description)
            : base(type, name,description)
        {

        }
        //打开编码窗体
        public override void Execute(Form1 f, int index)
        {
            FrmCodeExe frmCodeExe = new FrmCodeExe();
            frmCodeExe.f = f;
            frmCodeExe.index = index;
            frmCodeExe.ShowDialog();
        }
        public override void Show()
        {
            MessageBox.Show("有效编码行数:"+CodingLines+"\n遗留问题:"+Bugs+"\n工作日:"+WorkDay,"指标完成情况",MessageBoxButtons.OK);
        }
    }
}
编码类
技术分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace lesson7_2
{
    //辅助类
    public class Employee
    {
        public List<Job> Worklist { get; set; }

        public Employee(List<Job> worklist)
        {
            this.Worklist = worklist;
        }
    }
}
辅助类
技术分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace lesson7_2
{
    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(Form1 f, int index);

        public abstract void Show();
    }
}
Job类
技术分享
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 lesson7_2
{
    public partial class Form1 : Form
    {
       public  Employee emps;
        public Form1()
        {
            InitializeComponent();
            Init();
        }
        /// <summary>
        /// 绑定初始值
        /// </summary>
        public void Init()
        {
            List<Job> joblist = new List<Job>();
            joblist.Add(new CodeJob("编码","编码","实现购物车模块"));
            joblist.Add(new CodeJob("编码", "编码基类", "完成项目基类编码"));
            joblist.Add(new TestJob("测试", "压力测试", "测试项目实现模块"));

            emps = new Employee(joblist);
            this.dgvlist.AutoGenerateColumns = false;
            this.dgvlist.DataSource = emps.Worklist;

        }
        /// <summary>
        /// 绑定dgv
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tmsiExecute_Click(object sender, EventArgs e)
        {
            int index = this.dgvlist.CurrentRow.Index;
            emps.Worklist[index].Execute(this,index);
        }
        /// <summary>
        /// 显示完成情况
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 完成情况ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int index = this.dgvlist.CurrentRow.Index;
            emps.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 lesson7_2
{
    public partial class FrmTestExe : Form
    {
        TestJob testjob = new TestJob();
        public FrmTestExe()
        {
            InitializeComponent();
        }

        public int index;
        public Form1 f;
        //显示员工工作情况
        private void btninsert_Click(object sender, EventArgs e)
        {
            bool isError = false;
            try
            {
                ((TestJob)f.emps.Worklist[index]).FindBugs = int.Parse(txtbugcount.Text);
                ((TestJob)f.emps.Worklist[index]).CaseNum = int.Parse(txtcecount.Text);
                ((TestJob)f.emps.Worklist[index]).WorkDay = int.Parse(txtday.Text);
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
                isError = true;
            }
            if (!isError)
            {
                MessageBox.Show("提交成功!", "提示");
                this.Close();
            }
        }
        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnclear_Click(object sender, EventArgs e)
        {
            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 lesson7_2
{
    public partial class FrmCodeExe : Form
    {
        CodeJob job = new CodeJob();
        public FrmCodeExe()
        {
            InitializeComponent();
        }

        public int index;
        public Form1 f;
        //显示员工工作情况
        private void btninsert_Click(object sender, EventArgs e)
        {

            


            bool isError = false;
            try
            {
                ((CodeJob)f.emps.Worklist[index]).Bugs =int.Parse(txtquestion.Text);
                ((CodeJob)f.emps.Worklist[index]).CodingLines = int.Parse(txtrows.Text);
                ((CodeJob)f.emps.Worklist[index]).WorkDay = int.Parse(txtdays.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                isError = true;
                
            }
            if (!isError)
            {
                MessageBox.Show("提交成功!", "提示");
                this.Close();
            }
        }
        /// <summary>
        /// 取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnclear_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
编码窗体

 

第七章课后作业

标签:nbsp   win   partial   取消   glin   div   data   obj   auto   

原文地址:http://www.cnblogs.com/zhangxiaoyu123/p/6698928.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!