码迷,mamicode.com
首页 > 其他好文 > 详细

第18周作业

时间:2017-01-07 00:47:04      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:stringbu   trim   format   用户   ext   event   builder   tco   左右   

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

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

  积分规则

 若为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周作业

标签:stringbu   trim   format   用户   ext   event   builder   tco   左右   

原文地址:http://www.cnblogs.com/pxt--1202b/p/6257606.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!