18th Week personal Assignments

Source: Internet
Author: User

1. How long does it take to estimate the task

5-6 days

2. Demand Analysis

Homework A volleyball coach, I want to know the technical score of each team member, in order to train the players later.

3. Design Documentation

The coach knows the technical score of each player through a query.

4. Design Review

Review of the procedures to be prepared

5. Code specification

6. Specific design

Activity Chart:

7. Specific code

Code:

private void DGV (String sql = "SELECT * from Volleyballer")
{
Datagridview1.datasource = sqlhelper.executedatatable (sql);
}
private void Comb ()
{
ComboBox1.Items.Clear ();
COMBOBOX1.ITEMS.ADD ("Please select a member to query");
String sql = "SELECT name from Volleyballer";
using (SqlDataReader reader=sqlhelper.executereader (SQL))
{
if (reader. HasRows)
{
while (reader. Read ())
{
COMBOBOX1.ITEMS.ADD (Reader[0]);
}
}
}
}

Click events

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 ());
}
}

SqlHelper class

Execution returns a table

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;
}

}

Execution returns a single value

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 ();
}
}
}

Run interface

Run results

8. Summary afterwards

The basic implementation of this task has not been implemented with a specific three-tier architecture, and is intended to be implemented in a three-tier architecture and is ready to add some new functionality

18th Week personal Assignments

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.