• 第五组作业


    个人软件阶段 估计时间(min) 实际时间(min)
    计划 300 280
    ·估计完成需要的时间 300 280
    开发 250 240
    ·需求分析 30 30
    ·生成设计文档 20 20
    ·设计复审 30 30
    ·代码规范 20 20
    ·具体设计 40 40
    ·具体编码 50 40
    ·代码复审 20 20
    ·测试 40 40
    报告 50 40
    ·测试报告 20 10
    ·计算工作量 10 10
    ·事总结后 20 20

    代码如下:

     private void cmbLoad()
            {
                cmbName.Items.Clear();

                string sql = "select game from paiqiu";
                SqlDataReader reader = SqlHelper.ExecuteReader(sql);
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        cmbName.Items.Add(reader[0]);
                    }
                }
                reader.Close();
            }
            private void dgvLoad()
            {
                string sql = "select * from paiqiu";
                dgvGame.DataSource = SqlHelper.ExecuteDataTable(sql);
            }
            private void Form2_Load(object sender, EventArgs e)
            {
                cmbLoad();
                dgvLoad();
            }

            private void select_Click(object sender, EventArgs e)//单个查询
            {
                StringBuilder sql = new StringBuilder("select * from paiqiu where 1=1");
                if (!string.IsNullOrEmpty(cmbName.Text))
                {
                    sql.Append(" and game='" + cmbName.Text + "'");
                }
                SqlDataReader reader= SqlHelper.ExecuteReader(sql.ToString());
                if (reader.HasRows)
                {
                    dgvGame.DataSource = SqlHelper.ExecuteDataTable(sql.ToString());
                }
                else
                {
                    MessageBox.Show("没有查询到比赛记录!");
                }
            }

            private void lblWrite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)//跳转计分页面
            {
                this.Close();
                writeHistory0 a = new writeHistory0();
                a.Show();
            }

            private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
            {
                 Application.Exit();
            }

     StringBuilder sb = new StringBuilder();
            public string bisai(string str)
            {
                return name.Text = str;
            }
            public void TeamA(string str)
            {
                teamA.Text = str;
            }
            public void TeamB(string str)
            {
                teamB.Text = str;
            }
            public writeHistory1()
            {
                InitializeComponent();
            }
            string one=null, two=null, three=null, four=null, five=null;

            private void A_Click(object sender, EventArgs e)//甲方加分
            {
                sb.AppendFormat("甲方:{0}得1分 ",teamA.Text);
                int a=int.Parse(scoreA.Text) + 1;
                int b=int.Parse(scoreB.Text);
                int i=Convert.ToInt32( lblNum.Text.Substring(1, 1));
                int sa = Convert.ToInt32(lblA.Text);
                scoreA.Text = a.ToString();
                if (i < 5)
                {
                    if (a >= 25 && a - b >= 2)
                    {
                        string str = string.Format("本局甲方:{0}胜", teamA.Text);
                        MessageBox.Show(str);
                        scoreA.Text = "0";
                        scoreB.Text = "0";
                        sa++; i++;
                        lblA.Text = (sa).ToString();
                        lblNum.Text = "第" + i + "局";
                        sb.AppendFormat("第{0}局  {1}:{2}={3}:{4}  本局{5}胜 ", i - 1, teamA.Text, teamB.Text, a, b, teamA.Text);
                        switch(i-1)
                        {
                            case 1:one=string.Format("{0}:{1}",a,b); break;
                            case 2:two=string.Format("{0}:{1}",a,b); break;
                            case 3:three=string.Format("{0}:{1}",a,b); break;
                            case 4:four=string.Format("{0}:{1}",a,b); break;
                        }
                    }
                }
                else
                {
                    if(a>=15&&a-b>=2)
                    {
                        sb.AppendFormat("第{0}局  {1}:{2}={3}:{4}  本局{5}胜 ", i - 1, teamA.Text, teamB.Text, a, b, teamA.Text);
                        string str = string.Format("本局甲方:{0}胜", teamA.Text);
                        MessageBox.Show(str);
                        sa++;
                        lblA.Text = (sa).ToString();
                        five=string.Format("{0}:{1}",a,b);
                    }
                }
                if (sa == 3) {
                   
                    sb.AppendFormat("本场比赛甲方:{0}胜 比赛结束",teamA.Text);
                    string str=string.Format("本场比赛{0}胜",teamA.Text);
                    win.Text = str;
                    win.Visible = true;
                    A.Visible = false;
                    B.Visible = false;
                    insert(teamA.Text);
                }
                textBox1.Text = sb.ToString();
            }
           
            private void B_Click(object sender, EventArgs e)//乙方加分
            {
                sb.AppendFormat("乙方:{0}得1分 ",teamB.Text);
                int a = int.Parse(scoreB.Text) + 1;
                int b = int.Parse(scoreA.Text);
                int i = Convert.ToInt32(lblNum.Text.Substring(1, 1));
                int sa = Convert.ToInt32(lblB.Text);
                scoreB.Text =a.ToString();
                if (i < 5)
                {
                    if (a >= 25 && a - b >= 2)
                    {
                        string str = string.Format("本局乙方:{0}胜",teamB.Text);
                        MessageBox.Show(str);
                        scoreA.Text = "0";
                        scoreB.Text = "0";
                        sa++; i++;
                        lblB.Text = (sa).ToString();
                        lblNum.Text = "第" + i + "局";
                        sb.AppendFormat("第{0}局  {1}:{2}={3}:{4}  本局{5}胜 ", i - 1, teamA.Text, teamB.Text, b, a, teamB.Text);
                        switch (i - 1)
                        {
                            case 1: one = string.Format("{0}:{1}", b, a); break;
                            case 2: two = string.Format("{0}:{1}", b, a); break;
                            case 3: three = string.Format("{0}:{1}", b, a); break;
                            case 4: four = string.Format("{0}:{1}", b, a); break;
                        }
                    }
                }
                else
                {
                    if (a >= 15 && a - b >= 2)
                    {
                        sb.AppendFormat("第{0}局  {1}:{2}={3}:{4}  本局{5}胜 ", i-1,teamA.Text,teamB.Text ,b, a,teamB.Text);
                        string str = string.Format("本局乙方:{0}胜", teamB.Text);
                        MessageBox.Show(str);
                        sa++;
                        lblB.Text = (sa).ToString();
                        five = string.Format("{0}:{1}", b, a);
                    }
                }
                if (sa == 3) {
                    sb.AppendFormat("本场比赛乙方:{0}胜 比赛结束", teamB.Text);
                    string str = string.Format("本场比赛{0}胜", teamB.Text);
                    win.Text = str;
                    win.Visible = true;
                    A.Visible = false;
                    B.Visible = false;
                    insert(teamB.Text);
                }
                textBox1.Text = sb.ToString();
            }

            private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)//记录显示
            {
                if (textBox1.Visible == false)
                {
                    textBox1.Visible = true;
                }
                else
                {
                    textBox1.Visible = false;
                }
            }

            private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)//比赛重置
            {
                this.Close();
                writeHistory0 a = new writeHistory0();
                a.Show();
             
            }

            private void Form1_Load(object sender, EventArgs e)
            {
                sb.AppendFormat("比赛名称:{0} 甲方:{1}  乙方:{2} ",name.Text, teamA.Text, teamB.Text);
                textBox1.Text = sb.ToString();
            }

            private void lblIndex_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)//跳转到查询
            {
                this.Close();
                historySelect a = new historySelect();
                a.Show();
            }

            private void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)//退出
            {
                Application.Exit();
            }
            public void insert(string win) //记录插入
            {
                    string sql = "insert into paiqiu(game,teamA,teameB,one,two,three,four,five,win) values(@game,@teamA,@teameB,@one,@two,@three,@four,@five,@win)";
                    SqlParameter[] sp = {
                                            new SqlParameter("@game",name.Text),
                                            new SqlParameter("@teamA",teamA.Text),
                                            new SqlParameter("@teameB",teamB.Text),
                                            new SqlParameter("@one",one),
                                            new SqlParameter("@two",two),
                                            new SqlParameter("@three",three),
                                            new SqlParameter("@four",four==null?DBNull.Value:(object)four),
                                            new SqlParameter("@five",five==null?DBNull.Value:(object)five),
                                            new SqlParameter("@win",win)
                                        };
                    SqlHelper.ExecuteNonQuery(sql,sp);
            }

  • 相关阅读:
    练习题
    java关键字
    循环结构
    第一天的学习
    爬虫的简单介绍
    Windows10 专业版秘钥激活
    flask补充
    Flask框架
    小程序登录、授权、支付
    赃读、不可重复读 和 幻读
  • 原文地址:https://www.cnblogs.com/ljc960321/p/6194485.html
Copyright © 2020-2023  润新知