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