{
int a = 0, rnd1 = 0, b = 0;
public Form1()
{
InitializeComponent();
label1.Text = "電腦";
label2.Text = "玩家1";
textBox1.DataBindings.Add("Text", bindingSource1, "name", true);
textBox2.DataBindings.Add("Text", bindingSource1, "sex", true);
textBox3.DataBindings.Add("Text", bindingSource1, "stu_no", true);
textBox5.DataBindings.Add("Text", bindingSource1, "秒數", true);
textBox4.DataBindings.Add("Text", bindingSource1, "輸贏", true);
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button7_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
Random rnd = new Random();
rnd1 = rnd.Next(1, 4);
button2.BackColor = System.Drawing.Color.FromName("White");
button3.BackColor = System.Drawing.Color.FromName("White");
button1.BackColor = System.Drawing.Color.FromName("White");
textBox4.Text = "";
}
private void timer1_Tick(object sender, EventArgs e)
{
Random rnd = new Random();
rnd1 = rnd.Next(1, 4);
b = b + 1;
textBox5.Text = b.ToString();
}
private void button4_Click(object sender, EventArgs e)
{
a = 1;
if (rnd1 == 1)
{
button2.BackColor = System.Drawing.Color.FromName("Black");
button3.BackColor = System.Drawing.Color.FromName("Black");
button1.BackColor = System.Drawing.Color.FromName("White");
}
if (rnd1 == 2)
{
button1.BackColor = System.Drawing.Color.FromName("Black");
button3.BackColor = System.Drawing.Color.FromName("Black");
button2.BackColor = System.Drawing.Color.FromName("White");
}
if (rnd1 == 3)
{
button1.BackColor = System.Drawing.Color.FromName("Black");
button2.BackColor = System.Drawing.Color.FromName("Black");
button3.BackColor = System.Drawing.Color.FromName("White");
}
timer1.Enabled = false;
if ( rnd1 ==3)
{
textBox4.Text = "You WIN";
}
if (a == rnd1)
{
textBox4.Text = "平手唷";
}
if ( rnd1 ==2 )
{
textBox4.Text = "Loser";
}
}
private void button5_Click(object sender, EventArgs e)
{
a = 2;
if (rnd1 == 1)
{
button2.BackColor = System.Drawing.Color.FromName("Black");
button3.BackColor = System.Drawing.Color.FromName("Black");
button1.BackColor = System.Drawing.Color.FromName("White");
}
if (rnd1 == 2)
{
button1.BackColor = System.Drawing.Color.FromName("Black");
button3.BackColor = System.Drawing.Color.FromName("Black");
button2.BackColor = System.Drawing.Color.FromName("White");
}
if (rnd1 == 3)
{
button1.BackColor = System.Drawing.Color.FromName("Black");
button2.BackColor = System.Drawing.Color.FromName("Black");
button3.BackColor = System.Drawing.Color.FromName("White");
}
timer1.Enabled = false;
if (a > rnd1 )
{
textBox4.Text = "You WIN";
}
if (a == rnd1)
{
textBox4.Text = "平手唷";
}
if (a < rnd1 || (a == 3 && rnd1 == 1))
{
textBox4.Text = "Loser";
}
}
private void button6_Click(object sender, EventArgs e)
{
a = 3;
if (rnd1 == 1)
{
button2.BackColor = System.Drawing.Color.FromName("Black");
button3.BackColor = System.Drawing.Color.FromName("Black");
button1.BackColor = System.Drawing.Color.FromName("White");
}
if (rnd1 == 2)
{
button1.BackColor = System.Drawing.Color.FromName("Black");
button3.BackColor = System.Drawing.Color.FromName("Black");
button2.BackColor = System.Drawing.Color.FromName("White");
}
if (rnd1 == 3)
{
button1.BackColor = System.Drawing.Color.FromName("Black");
button2.BackColor = System.Drawing.Color.FromName("Black");
button3.BackColor = System.Drawing.Color.FromName("White");
}
timer1.Enabled = false;
if (rnd1==2 )
{
textBox4.Text = "You WIN";
}
if (a == rnd1)
{
textBox4.Text = "平手唷";
}
if (rnd1==1 )
{
textBox4.Text = "Loser";
}
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: 這行程式碼會將資料載入 'db2DataSet.猜拳1' 資料表。您可以視需要進行移動或移除。
this.猜拳1TableAdapter.Fill(this.db2DataSet.猜拳1);
// TODO: 這行程式碼會將資料載入 'db2DataSet.person' 資料表。您可以視需要進行移動或移除。
this.personTableAdapter1.Fill(this.db2DataSet.person);
// TODO: 這行程式碼會將資料載入 'db2DataSet.猜拳' 資料表。您可以視需要進行移動或移除。
this.猜拳TableAdapter2.Fill(this.db2DataSet.猜拳);
// TODO: 這行程式碼會將資料載入 '_db1__1_DataSet1.猜拳' 資料表。您可以視需要進行移動或移除。
this.猜拳TableAdapter1.Fill(this._db1__1_DataSet1.猜拳);
// TODO: 這行程式碼會將資料載入 '_db1__1_DataSet.猜拳' 資料表。您可以視需要進行移動或移除。
this.猜拳TableAdapter.Fill(this._db1__1_DataSet.猜拳);
// TODO: 這行程式碼會將資料載入 'db1DataSet.DataTable2' 資料表。您可以視需要進行移動或移除。
this.dataTable2TableAdapter.Fill(this.db1DataSet.DataTable2);
// TODO: 這行程式碼會將資料載入 'db1DataSet.DataTable1' 資料表。您可以視需要進行移動或移除。
this.dataTable1TableAdapter.Fill(this.db1DataSet.DataTable1);
// TODO: 這行程式碼會將資料載入 'db1DataSet.record' 資料表。您可以視需要進行移動或移除。
this.recordTableAdapter.Fill(this.db1DataSet.record);
// TODO: 這行程式碼會將資料載入 'db1DataSet.person' 資料表。您可以視需要進行移動或移除。
this.personTableAdapter.Fill(this.db1DataSet.person);
}
private void button8_Click(object sender, EventArgs e)
{
}
private void button9_Click(object sender, EventArgs e)
{
bindingSource1.MoveFirst();
}
private void button10_Click(object sender, EventArgs e)
{
bindingSource1.MovePrevious();
}
private void button11_Click(object sender, EventArgs e)
{
bindingSource1.MoveNext();
}
private void button12_Click(object sender, EventArgs e)
{
bindingSource1.MoveLast();
}
private void button13_Click(object sender, EventArgs e)
{
try
{
bindingSource1.AddNew();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void button14_Click(object sender, EventArgs e)
{
try
{
bindingSource1.EndEdit();
personTableAdapter.Update(db1DataSet);
MessageBox.Show("資料更新成功");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
沒有留言:
張貼留言