本周PSP流程进度

一计划

(1)估计这个任务需要多少时间:8天

 二开发

(1)需求分析:作为一名观众,我希望了解每一场的比赛成绩,以便加深对自己喜爱球队的了解,以及赛况。

(2)生成设计文档:

(3)设计复审(和同学交流讨论)

 (4)代码规范:无

 (5)具体设计:

class SqlHelper

{

 private static readonly string constr = ConfigurationManager.ConnectionStrings["connectionStr"].ConnectionSt

 public static int ExecuteNonQuery(string sql, params SqlParameter[] pms)

 {//使用using关键字定义一个范围,在范围结束时骸自动调用这个类实例的Dispose处理

       using (SqlConnection con = new SqlConnection(constr))

 {  //创建执行DSql命令对象

 using (SqlCommand cmd = new SqlCommand(sql, con))

   {

 if (pms != null)

 {

 cmd.Parameters.AddRange(pms);

  }

 con.Open();

  }

   }

  }

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

  { 

  using (SqlConnection con = new SqlConnection(constr))

  {

  using (SqlCommand cmd = new SqlCommand(sql, con))

 {

  if (pms != null)

   {

   cmd.Parameters.AddRange(pms);

   }

    con.Open();

    return cmd.ExecuteScalar();

  }

   }

  }

   //执行返回SqlDataReader

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

 {

 SqlConnection con = new SqlConnection(constr);

 using (SqlCommand cmd = new SqlCommand(sql, con))

 {

 if (pms != null)

    {

  cmd.Parameters.AddRange(pms);

    }

    try

       {

    con.Open();

   return cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);

   }

  catch (Exception)

{

   con.Close();

   con.Dispose();

   throw;

   }

   }

 }

  //执行返回DataTable

public static DataTable ExecuteDataTable(string sql, params SqlParameter[] pms)

  {

  DataTable dt = new DataTable();

  using (SqlDataAdapter adapter = new SqlDataAdapter(sql, constr))

 {

if (pms != null)

  {

  adapter.SelectCommand.Parameters.AddRange(pms);

  }

  adapter.Fill(dt);

}

 return dt;

 }

  }

class Info

 {

  public string Name { get; set; }

public int First { get; set; }

 public int Second { get; set; }

 public int Third { get; set; }

 public int Fourth { get; set; }

 public int Fifth { get; set; }

  public int Score { get; set; }

 }

  private void Select1_Click_1(object sender, EventArgs e)

 {

  string sql = "select * from Bifen where Name=@Name";

  SqlParameter[] paras = new SqlParameter[]

   {

  new SqlParameter("@Name",Name),

 };

 using (SqlDataReader reader = SqlHelper.ExecuteReader(sql, paras))

{

   if (reader.Read())

 {

   Info bf = new Info();

   bf.Name = (string)reader["Name"];

  bf.Second = reader.GetInt32(1);

  bf.Third = reader.GetInt32(2);

  bf.Fourth = reader.GetInt32(3);

  bf.Fifth = reader.GetInt32(4);

   bf.Score = reader.GetInt32(5);

  }

 }  

  }

private void button1_Click(object sender, EventArgs e)

{

if(comboBox1.selectIndex==0)

{

txtbox1.Text = bf.first.ToString();

}

 private void button1_Click(object sender, EventArgs e)      

{            

 if (comboBox2.Text=="恒大:霹雳火"&&comboBox1.Text == "第一局") { textBox1.Text = "25:15"; }          

 if (comboBox2.Text == "恒大:霹雳火" && comboBox1.Text == "第二局") { textBox1.Text = "25:18"; }           

if (comboBox2.Text == "恒大:霹雳火" && comboBox1.Text == "第三局") { textBox1.Text = "20:25"; }          

 if (comboBox2.Text == "恒大:霹雳火" && comboBox1.Text == "第四局") { textBox1.Text = "21:25"; }           

  if (comboBox2.Text == "恒大:霹雳火" && comboBox1.Text == "第五局") { textBox1.Text = "15:13"; }           

    }  

 private void button2_Click(object sender, EventArgs e)       

 {            

if (comboBox2.Text == "恒大:霹雳火”) { textBox2.Text = "3:2"; }          

  if (comboBox2.Text == "恒大:霹雳火") { textBox2.Text = "3:1"; }      

  }  

 (6)代码复审:无

 (7)测试:无

 进行到此处,未完待续......

原文地址:https://www.cnblogs.com/sdl1305702018/p/6219585.html