代码改变世界

个人作业

2016-12-18 14:57  太阳女神  阅读(123)  评论(0编辑  收藏  举报

1、个人项目耗时记录表 

2、代码部分

 

public class Match
{
public int id;//主键
public int h1j;//红队第一局得分
public int h2j;//红队第二局得分
public int h3j;//红队第三局得分
public int h4j;//红队第四局得分
public int h5j;//红队第五局得分
public int l1j;//蓝队第一局得分
public int l2j;//蓝队第二局得分
public int l3j;//蓝队第三局得分
public int l4j;//蓝队第四局得分
public int l5j;//蓝队第五局得分
}

public class dal
{
public Match Select(int id)
{
string strCon = "server=.;database=pqMatch;integrated security=true";
SqlConnection con = new SqlConnection(strCon);
string sql = "select * from Match where id="+id;
SqlCommand comm = new SqlCommand(sql, con);
con.Open();
Match mc = null;
SqlDataReader reader = comm.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
mc = new Match();
mc.id = 1;
mc.h1j =(int) reader["h1j"];
mc.h2j = (int)reader["h2j"];
mc.h3j = (int)reader["h3j"];
mc.h4j = (int)reader["h4j"];
mc.h5j = (int)reader["h5j"];
mc.l1j = (int)reader["l1j"];
mc.l2j = (int)reader["l2j"];
mc.l3j = (int)reader["l3j"];
mc.l4j = (int)reader["l4j"];
mc.l5j = (int)reader["l5j"];

}
}
reader.Close();
con.Close();
return mc;
}
}

public class bll
{
private dal dl = new dal();
public Match Select(int id)
{
return dl.Select(id);
}
}

private bll bl1 = new bll();
protected void Page_Load(object sender, EventArgs e)
{

}

protected void Button1_Click(object sender, EventArgs e)
{
if (!IsPostBack)
{
txt1h.Text = "";
txt2h.Text = "";
txt3h.Text = "";
txt4h.Text = "";
txt5h.Text = "";
txt1l.Text = "";
txt2l.Text = "";
txt3l.Text = "";
txt4l.Text = "";
txt5l.Text = "";
}
else
{
string id = Label1.Text.Trim();
Match mc = bl1.Select(Convert.ToInt32(id));
txt1h.Text = mc.h1j.ToString();
txt2h.Text = mc.h2j.ToString();
txt3h.Text = mc.h3j.ToString();
txt4h.Text = mc.h4j.ToString();
txt5h.Text = mc.h5j.ToString();
txt1l.Text = mc.l1j.ToString();
txt2l.Text = mc.l2j.ToString();
txt3l.Text = mc.l3j.ToString();
txt4l.Text = mc.l4j.ToString();
txt5l.Text = mc.l5j.ToString();
}
int ah=Convert.ToInt32(txt1h.Text);
int bh = Convert.ToInt32(txt2h.Text);
int ch = Convert.ToInt32(txt3h.Text);
int dh = Convert.ToInt32(txt4h.Text);
int eh = Convert.ToInt32(txt5h.Text);
int al = Convert.ToInt32(txt1l.Text);
int bl = Convert.ToInt32(txt2l.Text);
int cl = Convert.ToInt32(txt3l.Text);
int dl = Convert.ToInt32(txt4l.Text);
int el = Convert.ToInt32(txt5l.Text);
int zfh = 0;
int zfl = 0;
if (ah > al)
{
zfh++;
}
else
{
zfl++;
}
if (bh > bl)
{
zfh++;
}
else
{
zfl++;
}
if (ch > cl)
{
zfh++;
}
else
{
zfl++;
}
if (dh > dl)
{
zfh++;
}
else
{
zfl++;
}
if (eh > el)
{
zfh++;
}
else
{
zfl++;
}

 

}

3、执行结果