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

本周总结

时间:2016-12-25 23:46:39      阅读:247      评论:0      收藏:0      [点我收藏+]

标签:log   ext   文档   using   对象   turn   images   fill   交流   

计划:一个星期左右

.开发

用户故事:作为一个观众,我希望能看到队员的成绩,能看到单局比分和总比分,以便更加关心排球的成绩

(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)测试:无

 

本周总结

标签:log   ext   文档   using   对象   turn   images   fill   交流   

原文地址:http://www.cnblogs.com/zh1997/p/6220574.html

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