zoukankan      html  css  js  c++  java
  • 18周冲刺及总结

    排球比赛计分,现场工作人员

    1.  估计时间:一周左右。

    2.  开发

    需求分析:

    作为一个排球比赛的现场工作人员,我需要统计每一名

    队员的得分及技术统计,以便颁发每场比赛的最有价值球员奖,

    以及确定赛会的最佳阵容。

    设计文档:

    在界面可以通过datagridview或txtbox控件队球员信息进行操作,可以同步到数据库中。通过botton按钮查询分数和统计页面。从数据库中获取运动员分数并进行排序,得出最高分。并显示到页面上。

    设计复审:

    自己。

    代码规范:

    用到access和c#对设计进行具体操作;

    具体设计:

    界面:

     

    后台代码;

    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:UsersAdministratorDesktop统计表.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:UsersAdministratorDesktop统计表.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:UsersAdministratorDesktop统计表.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:UsersAdministratorDesktop统计表.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= "";
    }
    }
    }

    代码复审:

    测试:

    当前功能可以实现。

    工作量统计:

    数据库40%代码50%界面10%;

    事后总结:

    对于数据库的操作较为生疏,后台代码运行时也有困难。比较上次,这次至少知道了整个流程。对于三层架构不能熟练使用。具体功能的实现要多于其他人交流。以上就是这次的总结。

  • 相关阅读:
    (转)编写高质量高效率的SharePoint应用程序
    转:我眼中的Visual Studio 2010架构工具
    Windows 7 x64/Windows 2008 : The ‘Microsoft.Jet.OLEDB.4.0′ provider is not registered on the local machine.
    转:构建高性能ASP.NET站点之一 剖析页面的处理过程(前端)
    HTML5 到底是什么?
    使用eval()解析JSON格式字符串应注意的问题
    使用HTML5进行地理位置定位。误差在+500m
    LAST DAY
    javacript获取obj的长度
    通过 JSON 字符串来创建对象
  • 原文地址:https://www.cnblogs.com/wuhao123/p/6257325.html
Copyright © 2011-2022 走看看