㈠, Planning
① estimate how long this task will take: 3 days
㈡, development
① Demand Analysis: 0.5h
As a volleyball enthusiast (athlete, Spectator)
Want to know the score of the match,
In order to master the game. (The result of the outcome is accurate to the score)
(Query results only, not cumulative bonus points)
Presentation layer: ① Audience
(Code implementation: WinForm form)
Business layer: Judging
Data Source:--→db
② Creating a design document: 3h
③ Design Review (and colleague Audit design document) 0.5h
④ Code specification (to develop appropriate specifications for current development)
⑤ Specific Design: 1h
Save the score in the database, select a field in the form control, and show the score.
Because you don't use code, you can't write a complete program. So this blog content can only be said to be a job, not called the program.
⑥ Specific code: 1day
Class SqlHelper
{//Get connection string
private static readonly String constr = configurationmanager.connectionstrings["ConnectionStr"]. ConnectionString;
ExecuteNonQuery () method
ExecuteScalar () method
ExecuteReader () method
Executedatatable () method
public static int ExecuteNonQuery (String sql, params sqlparameter[] PMS)
{
Use the Using keyword to define a range that automatically calls the Dispose object of this class instance at the end of the range
using (SqlConnection con = new SqlConnection (CONSTR))
{
To create the Execute Dsql Command object
using (SqlCommand cmd = new SqlCommand (sql, con))
{
Determine if the SQL parameter was passed
if (PMS! = null)
{
Add arguments to the Parameters collection
Cmd. Parameters.addrange (PMS);
}
Con. Open ();
return CMD. ExecuteNonQuery ();
}
}
}
Execution that returns a single value.
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 ();
}
}
}
Perform a return 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
}
}
}
Perform a return 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 [email protected]";
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 ();
}
if (combobox1.selectindex==1)
{
Txtbox1. Text = Bf.second.ToString ();
}
if (combobox1.selectindex=2)
{
Txtbox1. Text = Bf.third.ToString ();
}
if (combobox1.selectindex=3)
{
Txtbox1. Text = Bf.fourth.ToString ();
}
if (combobox1.selectindex=4)
{
Txtbox1. Text = Bf.fifth.ToString ();
}
private void Button2_Click (object sender, EventArgs e)
{
Txtbox2. Text = Bf.score.ToString ();
}
⑦ Code review: 30min
⑧ Testing (self-test, code modification, submission code): 40min
㈢, reporting
① Test Report: 30min
② Calculation workload: 20min
③ after the summary, and proposed process Improvement plan: 2h
Volleyball game procedure (personal work)