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

最后一次PSP

时间:2017-01-06 22:13:31      阅读:293      评论:0      收藏:0      [点我收藏+]

标签:技术分享   import   编码   lead   ima   count   change   exe   head   

PSP:

一、计划

        完成这个任务需要五天左右。

二、开发

   1.需求分析:

           作为一个排球比赛的现场工作人员,我需要统计每一名球员的得分以及技术统计(如:发球,拦网,一传等等),以便于颁发每场比赛的MVP,确定最佳阵容。

   2.生成设计文档:

          (1)通过现场工作人员的界面,当运动员得分时,通过datagridview控件增加或者更新数据,并且即时更新到数据库中,然后通过查询按钮进入比赛结束后运动员的总分及技术统计界面。

          (2)能够获取数据库中发球,扣球,拦网的得分,以及一传二传的成功数,还有自由人防守的成功数,然后进行降序排序,获取第一行的第一个数据,将得分最高的运动员的名字现实到文本框中,得出MVP。

                 然后得出最佳发球,扣球,拦网,一传,二传,自由人,实现在文本框中。

          (3)活动图技术分享

  3.设计复审

         同组人员一起复审,讨论了可行与不可行的地方,修改了部分功能。

  4.代码规范

         给目前的内容进行了一些合理的要求,以便进行开发。

  5.具体设计

         技术分享

技术分享技术分享

 

 

  6.具体编码

     

using System.Data.OleDb;
namespace 工作人员统计
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OleDbConnection conn;//声明一个OleDbConnection变量
OleDbDataAdapter adapter;//声明一个OleDbAdapter
DataSet ds = null;

private void Form1_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“统计表DataSet.Allathlete”中。您可以根据需要移动或删除它。
this.allathleteTableAdapter1.Fill(this.统计表DataSet.Allathlete);
// TODO: 这行代码将数据加载到表“workersDataSet1.Allathlete”中。您可以根据需要移动或删除它。
// this.allathleteTableAdapter.Fill(this.workersDataSet1.Allathlete);
// TODO: 这行代码将数据加载到表“workers.Allathletes”中。您可以根据需要移动或删除它。

//
conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Administrator\Desktop\统计表.mdb");
adapter = new OleDbDataAdapter("select * from Allathlete", conn);
ds = new DataSet();
adapter.Fill(ds, "Allathlete");
dataGridView1.DataSource = ds.Tables[0];
dataGridView1.RowHeadersVisible = false;

}

private void button1_Click(object sender, EventArgs e)
{
//连接数据库
conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Administrator\Desktop\统计表.mdb");
adapter = new OleDbDataAdapter("select * from Allathlete", conn);
ds = new DataSet();
adapter.Fill(ds,"Allathlete");
dataGridView1.DataSource = ds.Tables[0];
dataGridView1.RowHeadersVisible = false;

//建立一个DataTable类型的方法

}
private DataTable dbcon(string strOleDb)
{
conn.Open();
this.adapter = new OleDbDataAdapter(strOleDb,conn);
DataTable dtSelect = new DataTable();
int rnt = this.adapter.Fill(dtSelect);
conn.Close();
return dtSelect;
}

private void button2_Click(object sender, EventArgs e)
{
if (dbUpdate())
{
MessageBox.Show("更新成功");
}
}
private Boolean dbUpdate()
{
string strOleDb = "select * from Allathlete";
DataTable dtUpdate = new DataTable();
dtUpdate = this.dbcon(strOleDb);
dtUpdate.Rows.Clear();
DataTable dtShow = new DataTable();
dtShow = (DataTable)this.dataGridView1.DataSource;
for (int i = 0; i < dtShow.Rows.Count; i++)//循环遍历
{
dtUpdate.ImportRow(dtShow.Rows[i]);

}
try
{
this.conn.Open();
OleDbCommandBuilder cb = new OleDbCommandBuilder(this.adapter);
this.adapter.Update(dtUpdate);
this.conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
return false;
}
dtUpdate.AcceptChanges();
return true;
}

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


}
}

using System.Data.OleDb;

namespace 工作人员统计
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private void Form2_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“统计表DataSet3.Allathlete”中。您可以根据需要移动或删除它。
this.allathleteTableAdapter3.Fill(this.统计表DataSet3.Allathlete);
// TODO: 这行代码将数据加载到表“统计表DataSet2.Allathlete”中。您可以根据需要移动或删除它。
this.allathleteTableAdapter2.Fill(this.统计表DataSet2.Allathlete);
// TODO: 这行代码将数据加载到表“统计表DataSet1.Allathlete”中。您可以根据需要移动或删除它。
this.allathleteTableAdapter1.Fill(this.统计表DataSet1.Allathlete);
// TODO: 这行代码将数据加载到表“worker.Allathlete”中。您可以根据需要移动或删除它。
//this.allathleteTableAdapter.Fill(this.worker.Allathlete);


}

private void button3_Click(object sender, EventArgs e)
{
string conn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Administrator\Desktop\统计表.mdb";
OleDbConnection con = new OleDbConnection(conn);
// string sql = "select qiuyuan from Allathletes order by faqiu desc";
con.Open();
string sql = "select qiuyuan from Allathlete order by faqiu desc";
OleDbCommand cmd = new OleDbCommand(sql,con);
OleDbDataReader reader = cmd.ExecuteReader();
try
{
reader.Read();
string faqiu = (string)reader[0].ToString();
textBox1.Text = faqiu;
reader.Close();
con.Close();
con.Open();
string sqa = "select qiuyuan from Allathlete order by kouqiu desc";
OleDbCommand cma = new OleDbCommand(sqa, con);
OleDbDataReader readera = cma.ExecuteReader();
readera.Read();
string kouqiu = (string)readera[0].ToString();
textBox2.Text = kouqiu;
readera.Close();
con.Close();
con.Open();
string sqb = "select qiuyuan from Allathlete order by lanwang desc";
OleDbCommand cmb = new OleDbCommand(sqb, con);
OleDbDataReader readerb = cmb.ExecuteReader();
readerb.Read();
string lanwang = (string)readerb[0].ToString();
textBox3.Text = lanwang;
readerb.Close();
con.Close();
con.Open();
string sqc = "select qiuyuan from Allathlete order by yichuan desc";
OleDbCommand cmc = new OleDbCommand(sqc, con);
OleDbDataReader readerc = cmc.ExecuteReader();
readerc.Read();
string yichuan = (string)readerc[0].ToString();
textBox4.Text = yichuan;
readerc.Close();
con.Close();
con.Open();
string sqd = "select qiuyuan from Allathlete order by erchuan desc";
OleDbCommand cme = new OleDbCommand(sqd, con);
OleDbDataReader readerd = cme.ExecuteReader();
readerd.Read();
string erchuan = (string)readerd[0].ToString();
textBox5.Text = erchuan;
readerd.Close();
con.Close();
con.Open();
string sqf = "select qiuyuan from Allathlete order by ziyouren desc";
OleDbCommand cmf = new OleDbCommand(sqf, con);
OleDbDataReader readerf = cmf.ExecuteReader();
readerf.Read();
string ziyouren = (string)readerf[0].ToString();
//textBox1.Text = faqiu;
//textBox2.Text = kouqiu;
// textBox3.Text = lanwang;
// textBox4.Text = yichuan;
// textBox5.Text = erchuan;
textBox6.Text = ziyouren;
reader.Close();
}
catch
{
MessageBox.Show("没有比赛数据!");
}
con.Close();
}

private void button1_Click(object sender, EventArgs e)
{
string conn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Administrator\Desktop\统计表.mdb";
OleDbConnection con = new OleDbConnection(conn);
string sql = "select qiuyuan from Allathlete order by score desc";
con.Open();
OleDbCommand cmd = new OleDbCommand(sql,con);
OleDbDataReader reader = cmd.ExecuteReader();
reader.Read();
try
{
string mvp = (string)reader[0].ToString();
text.Text = mvp;
}
catch
{
MessageBox.Show("没有比赛数据!");
}
reader.Close();
con.Close();

}

private void label4_Click(object sender, EventArgs e)
{

}

private void button2_Click(object sender, EventArgs e)
{
text.Text = "";
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text= "";
}
}
}

  7.代码复审

     基本实现了想要的功能,没有复审。

  8.

    使用VS对代码进行测试,对代码进行重构,修复了部分问题。

 三、报告

   1.测试报告

       测试通过。

  2.计算工作量

时间:一星期

代码累计数:不确定

随笔累计数:不确定

 3.事后总结

   开发一个软件,有很多种方法,应该找到最简单实用的,还有代码实现功能,有些功能的实现用已有的代码无法实现,需要继续学习。 

最后一次PSP

标签:技术分享   import   编码   lead   ima   count   change   exe   head   

原文地址:http://www.cnblogs.com/wangyiheng/p/6257266.html

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