首页 > 代码库 > 个人作业

个人作业

  • 计划

            计划需要八天时间

  • 开发

            需求分析

                        作为排球比赛的现场工作人员,我需要统计每一名队员的得分及技术统计,以便于颁发最有价值成员奖确定赛会的最佳阵容

           生成设计文档

                       把每个人是怎么得分的用详细的数据记录下来

            设计复审

                        由小组成员讨论 负责进行

            代码规范

                        根据Visual Studio 2010规范写

            具体设计

                      

            具体编码

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

namespace 排球作业 {   

  public partial class Form1 : Form    

{         public Form1()         {             InitializeComponent();         }

        private void Form1_Load(object sender, EventArgs e)         {             // TODO: 这行代码将数据加载到表“paiqiuDataSet1.Table4”中。您可以根据需要移动或删除它。             this.table4TableAdapter.Fill(this.paiqiuDataSet1.Table4);             ComboBoxDataLoad();

        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)         {

        }         //rivate void Form1_Load(object sender, EventArgs e)        // {             // TODO: 这行代码将数据加载到表“students.Student”中。您可以根据需要移动或删除它。           

  //this.studentTableAdapter.Fill(this.students.Student);             //DataGridViewDataLoad();         //}     

    private void DataGridViewDataLoad(string sql = "select * from Table4")   

      {             //创建数据库连接             SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=paiqiu;Integrated Security=True");

            //创建一个sqldataadapter的对象适配器 用于检索和保存数据            

SqlDataAdapter adapter = new SqlDataAdapter(sql, con);        

     //创建一个存放于内存中的数据缓存             DataSet ds = new DataSet();         

    //打开数据库连接             con.Open();           

  adapter.Fill(ds);         

    con.Close();          

   dataGridView1.DataSource = ds.Tables[0];

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)         {

        }         private void ComboBoxDataLoad()         {        

     comboBox1.Items.Clear();          

   comboBox1.Items.Add("全部");         

    comboBox1.SelectedIndex = 0;          

   SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=paiqiu;Integrated Security=True");          

   string sql = "select distinct 队伍 from Table4";          

   SqlCommand cmd = new SqlCommand(sql,con);         

    con.Open();          

   SqlDataReader reader = cmd.ExecuteReader();           

  if (reader.HasRows)             {                 while (reader.Read())                 {                     comboBox1.Items.Add(reader[0]);                 }             }             reader.Close();      

      con.Close();         }

        private void button1_Click(object sender, EventArgs e)         {             string 队员 = textBox1.Text.Trim();             string 队伍 = comboBox1.Text.Trim();      

       StringBuilder sql = new StringBuilder("select * from Table4 where 1=1");        

     if (!String.IsNullOrEmpty(队员))             {                 sql.Append(" and 队员="+队员);             }             if (!string.IsNullOrEmpty(队伍))             {                 sql.Append(" and 队伍 like ‘%" + 队伍 + "%‘");             }             DataGridViewDataLoad(sql.ToString());                    }

        private void button2_Click(object sender, EventArgs e)         {             Form2 a = new Form2();             a.Show();             this.Hide();         }     } }

 

namespace 排球作业 {     public partial class Form2 : Form     {         public Form2()         {             InitializeComponent();         }

        private void button1_Click(object sender, EventArgs e)         {             string conn = @"Data Source=.;Initial Catalog=paiqiu;Integrated Security=True";             SqlConnection con = new SqlConnection(conn);             con.Open();             string sql = "select 队员 from Table4 order by 发球 desc";             SqlCommand cmd = new SqlCommand(sql,con);             SqlDataReader reader = cmd.ExecuteReader();             try             {                 reader.Read();                 string f = (string)reader[0].ToString();                 textBox1.Text = f;                 reader.Close();con.Close();                 con.Open();                 string sqa = "select 队员 from Table4 order by 扣球 desc";                 SqlCommand cma = new SqlCommand(sqa, con);                 SqlDataReader readera = cma.ExecuteReader();                 readera.Read();                 string k = (string)readera[0].ToString();                 textBox2.Text = k;                 readera.Close();con.Close();                 con.Open();                 string sqb = "select 队员 from Table4 order by 拦网 desc";                 SqlCommand cmb = new SqlCommand(sqb, con);                 SqlDataReader readerb = cmb.ExecuteReader();                 readerb.Read();                 string l = (string)readerb[0].ToString();                 textBox3.Text = l;                 readerb.Close();                 con.Close();                 con.Open();                 string sqc = "select 队员 from Table4 order by 一传 desc";                 SqlCommand cmc = new SqlCommand(sqc, con);                 SqlDataReader readerc = cmc.ExecuteReader();                 readerc.Read();                 string y = (string)readerc[0].ToString();                 textBox4.Text = y;                 readerc.Close();                 con.Close();                 con.Open();                 string sqd = "select 队员 from Table4 order by 防守 desc";                 SqlCommand cme = new SqlCommand(sqd, con);                 SqlDataReader readerd = cme.ExecuteReader();                 readerd.Read();                 string ff = (string)readerd[0].ToString();                 textBox5.Text = ff;                 readerd.Close();                 con.Close();                 con.Open();

                string sqf= "select 队员 from Table4 order by 得分 desc";                 SqlCommand cmf = new SqlCommand(sqf, con);                 SqlDataReader readerf = cmf.ExecuteReader();                 readerf.Read();                 string z = (string)readerf[0].ToString();                 textBox7.Text = z;                 //readerf.Close();                // con.Close();                                 reader.Close();             }            catch            {                            }             con.Close();         }

        private void Form2_Load(object sender, EventArgs e)         {             // TODO: 这行代码将数据加载到表“paiqiuDataSet2.Table4”中。您可以根据需要移动或删除它。             this.table4TableAdapter.Fill(this.paiqiuDataSet2.Table4);

        }             } }

代码复审

和小组成员一起进行了代码复审 代码可以正常运行

测试  

   无错误

报告

   计算工作量

        差不多一周的时间

 事后总结

      这是新学期的第一次迭代,感觉效率不高,不知道如何下手 过了个寒假对代码又陌生了  在接下来的时间 要继续打代码 手要勤快 要多想  多练习 希望以后自己能把代码好好练练 加油吧

 

个人作业