zoukankan      html  css  js  c++  java
  • 第十八周作业

    第十八周作业

    ·计划

        估计这个任务需要5-6天

    ·开发

       *需求分析

                  用户故事:作为一个排球教练,我希望知道每个队员的技术得分情况,以便后期对每个队员的训练计划进行调整。

       *生成设计文档 

                              任务:教练通过选择想要查询的队员名字来查询本队某队员的技术得分。

       *设计复审:

                        将编写的程序进行生成,进行设计复审。看看是否生成错误,如果错误进行修改。

       *代码规范:

                       利用VS对该程序进行代码规范。

       *具体设计

                            

          *具体编码:

    配置文件:

     App.config:

    <configuration>
    <connectionStrings>
    <add name="itcast" connectionString="server=.;initial catalog=itcast;integrated security=true;"/>
    </connectionStrings>
    </configuration>

     

    class SqlHelper
    {
    private static readonly string constr = ConfigurationManager.ConnectionStrings["itcast"].ConnectionString;
    public static int ExecuteNonQuery(string sql, params SqlParameter[] pams)
    {

    using (SqlConnection conn = new SqlConnection(constr))
    {
    using (SqlCommand comm = new SqlCommand(sql, conn))
    {
    if (pams != null)
    {
    comm.Parameters.AddRange(pams);
    }
    conn.Open();
    return comm.ExecuteNonQuery();
    }
    }

    }

    public static DataTable ExecuteDataTable(string sql, params SqlParameter[] pams)
    {
    DataTable dt = new DataTable();

    using (SqlDataAdapter adapter = new SqlDataAdapter(sql, constr))
    {
    if (pams != null)
    {
    adapter.SelectCommand.Parameters.AddRange(pams);
    }
    adapter.Fill(dt);
    }
    return dt;
    }

    public static SqlDataReader ExecuteReader(string sql, params SqlParameter[] pams)
    {

    SqlConnection conn = new SqlConnection(constr);
    using (SqlCommand comm = new SqlCommand(sql, conn))
    {
    if (pams != null)
    {
    comm.Parameters.AddRange(pams);

    }
    try
    {
    conn.Open();
    return comm.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
    }
    catch (Exception)
    {
    conn.Close();
    conn.Dispose();
    throw;
    }
    }
    }

    public static object ExecuteScalar(string sql, params SqlParameter[] pams)
    {

    using (SqlConnection conn = new SqlConnection(constr))
    {
    using (SqlCommand comm = new SqlCommand(sql, conn))
    {
    if (pams != null)
    {
    comm.Parameters.AddRange(pams);
    }
    conn.Open();
    return comm.ExecuteScalar();
    }
    }
    }
    }

    private void Form1_Load(object sender, EventArgs e)
    {
    comb();
    dgv();
    }
    private void dgv(string sql = "select * from VolleyBaller")
    {
    dataGridView1.DataSource = SqlHelper.ExecuteDataTable(sql);
    }
    private void comb()
    {
    comboBox1.Items.Clear();
    comboBox1.Items.Add("请选择你的队员名字");
    comboBox1.SelectedIndex = 0;
    string sql = "select name from VolleyBaller";
    using(SqlDataReader reader=SqlHelper.ExecuteReader(sql))
    {
    if (reader.HasRows)
    {
    while (reader.Read())
    {
    comboBox1.Items.Add(reader[0]);
    }
    }
    }
    }

    private void button1_Click(object sender, EventArgs e)
    {
    string name = comboBox1.Text.Trim();
    StringBuilder sql=new StringBuilder("select * from VolleyBaller where 1=1");
    if(!string.IsNullOrEmpty(name))
    {
    sql.Append(" and name like '%" + name + "%'");
    }

    dgv(sql.ToString());
    }

         程序执行出来的截图:

                        数据库截图:

                         

                          首次加载的图片:

                                

                              教练查询执行的结果:

                                          

                      *代码复审:和同学对该程序进行讨论,对该程序进行指正,以及对该程序的看法和意见。

                   *测试: 对该程序进行自己测试,然后进行修改和提交。

               ·报告 

                *测试报告:

                                 由于对测试过程了解的还不太好,一直没有测试通过。接下来要进一步深入了解UI测试步骤,然后 对该程序进行继续测试。

                 *计算工作量:五天。

                 *事后总结:对于这个程序我用了WindowForm做的,实现了设计需要实现的。计划:这个程序没有用三层架构接下来要用三层架构来实现。还有这个用户故事有点容易,接下来我应该实现对方的技术得分,让教练进行对比,来看看自己的不足和长处。

                

     

               

        

  • 相关阅读:
    UVA 12545 Bits Equalizer
    UVA 1610 Party Games
    UVA 1149 Bin Packing
    UVA 1607 Gates
    UVA 12627 Erratic Expansion
    UVA10562-Undraw the Trees(递归)
    UVA10129-Play on Words(欧拉路径)
    UVA816-Abbott's Revenge(搜索进阶)
    UVA1103-Ancient Messages(脑洞+dfs)
    UVA839-Not so Mobile
  • 原文地址:https://www.cnblogs.com/jxx-123/p/6253743.html
Copyright © 2011-2022 走看看