首页 > 代码库 > 第18周作业

第18周作业

      用户故事:作为一名赛事组织人员,我需要每场比赛的结果及比赛积分,

以便对比赛队伍进行排名。

  积分规则

 若为3:0或3:1,胜者得3分,负者不得分。

  若为3:2,胜者2分,负者1分。

  计划:大概花了5天左右,先做需求分析和代码编写,

然后进行代码复审。。

 

 

  界面

技术分享

 

代码

public partial class Form1 : Form
{
 Action action = new Action();

public void INSERT()
{
Model q = new Model();
q.IDA = textBox1.Text.Trim().ToString();
q.IDB = textBox2.Text.Trim().ToString();
q.ONE = txtCount1.Text.Trim().Substring(4, 4);
q.TWO = txtCount2.Text.Trim().Substring(4, 4);
q.THREE = txtCount3.Text.Trim().Substring(4, 4);
if (txtCount4.Text =="")
{
q.FOUR = null;
}
else
{
q.FOUR = txtCount4.Text.Trim().Substring(4, 4);
}
if (txtCount5.Text =="")
{
q.FIVE= null;
}
else
{
q.FIVE = txtCount5.Text.Trim().Substring(4, 4);
}

q.SUM = txtH1.Text.ToString() + ":" + txtL1.Text.ToString();
q.Detail = sb.ToString();
action.InsertPK(M);
}

public Form1()
{
InitializeComponent();

}

int i = 1;
StringBuilder sb = new StringBuilder();
private void btnH_Click(object sender, EventArgs e)
{
int H = Convert.ToInt32(txtH.Text);
int L = Convert.ToInt32(txtL.Text);
int H1 = Convert.ToInt32(txtH1.Text);
int L1 = Convert.ToInt32(txtL1.Text);
txtH.Text = (H+1).ToString();
sb.AppendFormat("第{0}个球 {1}:{2}\r\n",H+1,H+1,L);
if (H >= 24 && (H - L) > 0)
{
txtH1.Text = (Convert.ToInt32(txtH1.Text) + 1).ToString();
if((H1+L1)==0){
txtCount1.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 1)
{
txtCount2.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 2)
{
txtCount3.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 3)
{
txtCount4.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 4)
{
txtCount5.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
txtH.Text = "0";
txtL.Text = "0";

if (txtH1.Text == "3")
{
MessageBox.Show(textBox1.Text+"胜利");
INSERT();
txtH.Text = "0";
txtH1.Text = "0";
txtL.Text = "0";
txtL1.Text = "0";
txtCount1.Clear();
txtCount2.Clear();
txtCount3.Clear();
txtCount4.Clear();
txtCount5.Clear();

}
}
if (H1 + L1 > 3)
{
if (H >= 14 && (H - L) > 1)
{
txtH1.Text = (Convert.ToInt32(txtH1.Text) + 1).ToString();

if ((H1 + L1) == 4)
{
txtCount5.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text + "\r\n";
}
txtH.Text = "0";
txtL.Text = "0";

if (txtH1.Text == "3")
{
MessageBox.Show(textBox1.Text + "胜利");
INSERT();
txtH.Text = "0";
txtH1.Text = "0";
txtL.Text = "0";
txtL1.Text = "0";
txtCount1.Clear();
txtCount2.Clear();
txtCount3.Clear();
txtCount4.Clear();
txtCount5.Clear();
i = 1;
}
}
}
}

private void btnL_Click(object sender, EventArgs e)
{

int H = Convert.ToInt32(txtH.Text);
int L = Convert.ToInt32(txtL.Text);
int H1 = Convert.ToInt32(txtH1.Text);
int L1 = Convert.ToInt32(txtL1.Text);
txtL.Text = (L+1).ToString();
sb.AppendFormat("第{0}个球 {1}:{2}\r\n", L + 1, H, L+1);
if (L>= 24&&(L-H )>0)
{
txtL1.Text = (Convert.ToInt32(txtL1.Text) + 1).ToString();
if((H1+L1)==0){
txtCount1.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
} if ((H1 + L1) == 1)
{
txtCount2.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 2)
{
txtCount3.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 3)
{
txtCount4.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
if ((H1 + L1) == 4)
{
txtCount5.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
txtH.Text = "0";
txtL.Text = "0";

if (txtL1.Text=="3")
{
MessageBox.Show(textBox2.Text + "胜利");
INSERT();
txtH.Text = "0";
txtH1.Text = "0";
txtL.Text = "0";
txtL1.Text = "0";
txtCount1.Clear();
txtCount2.Clear();
txtCount3.Clear();
txtCount4.Clear();
txtCount5.Clear();
}
}
if(H1+L1>3)
{
if (L >= 14 && (L - H) > 1)
{
txtL1.Text = (Convert.ToInt32(txtL1.Text) + 1).ToString();
if((H1+L1)==4){
txtCount5.Text += "第" + (i++) + "局:" + txtH.Text + ":" + txtL.Text;
}
txtH.Text = "0";
txtL.Text = "0";

if (txtL1.Text == "3")
{
MessageBox.Show(textBox2.Text + "胜利");
INSERT();
txtH.Text = "0";
txtH1.Text = "0";
txtL.Text = "0";
txtL1.Text = "0";
txtCount1.Clear();
txtCount2.Clear();
txtCount3.Clear();
txtCount4.Clear();
txtCount5.Clear();
i = 1;
}
}
}

}
private void btnH1_Click(object sender, EventArgs e)
{
if (int.Parse(txtH.Text) > 0)
{
txtH.Text = (Convert.ToInt32(txtH.Text) - 1).ToString();
}
}

private void btn_Click(object sender, EventArgs e)
{
if (int.Parse(txtH.Text) > 0)
{
txtL.Text = (Convert.ToInt32(txtL.Text) - 1).ToString();
}
}

 

private void button1_Click(object sender, EventArgs e)
{
paiming p = new paiming();
p.Show();
}


 





}
}

 

第18周作业