using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Scommesse
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double s = 1;
CheckBox
[] check
= new CheckBox
[10
];
RadioButton
[] radio
= new RadioButton
[30
];
int i,j=0;
int a = 1;
public void button1_Click(object sender, EventArgs e)
{
iniz();
if (Convert.ToInt32(prezzo.Text) == 0) MessageBox.Show("Prezzo non inserito");
else
{
for (j = 0; j < 3; j++)
{
{
if (radio
[j
].
Checked) { s
= s
* (Convert.
ToDouble(radio
[j
].
Text));}
}
}
for (j = 3; j < 6; j++)
{
{
if (radio
[j
].
Checked) { s
= s
* (Convert.
ToDouble(radio
[j
].
Text)); }
}
}
for (j = 6; j < 9; j++)
{
{
if (radio
[j
].
Checked) { s
= s
* (Convert.
ToDouble(radio
[j
].
Text)); }
}
}
for (j = 9; j < 12; j++)
{
{
if (radio
[j
].
Checked) { s
= s
* (Convert.
ToDouble(radio
[j
].
Text)); }
}
}
for (j = 12; j < 15; j++)
{
{
if (radio
[j
].
Checked) { s
= s
* (Convert.
ToDouble(radio
[j
].
Text)); }
}
}
for (j = 15; j < 18; j++)
{
{
if (radio
[j
].
Checked) { s
= s
* (Convert.
ToDouble(radio
[j
].
Text)); }
}
}
for (j = 18; j < 21; j++)
{
{
if (radio
[j
].
Checked) { s
= s
* (Convert.
ToDouble(radio
[j
].
Text)); }
}
}
for (j = 21; j < 24; j++)
{
{
if (radio
[j
].
Checked) { s
= s
* (Convert.
ToDouble(radio
[j
].
Text)); }
}
}
for (j = 24; j < 27; j++)
{
{
if (radio
[j
].
Checked) { s
= s
* (Convert.
ToDouble(radio
[j
].
Text)); }
}
}
for (j = 27; j < 30; j++)
{
{
if (radio
[j
].
Checked) { s
= s
* (Convert.
ToDouble(radio
[j
].
Text)); }
}
}
if (a == 1) { s = s * Convert.ToInt32(prezzo.Text); a = 0; }
textBox1.Text = s.ToString();
textBox1.Text = String.Format("{0:F2}", s);
button1.Enabled = false;
}
}
private static Random m_Rand
= new Random
(DateTime.
Now.
Millisecond);
private static double RandomNumber(double min, double max)
{
return (max - min) * m_Rand.NextDouble() + min;
}
private void button2_Click(object sender, EventArgs e)
{
iniz();
double rand = RandomNumber(1.10, 4.00);
for (i = 0; i < 30; i++)
{
rand = RandomNumber(1.10, 4.00);
radio[i].Text = rand.ToString();
radio[i].Text = String.Format("{0:F2}", rand);
}
button2.Enabled = false;
}
private void button3_Click(object sender, EventArgs e)
{
iniz();
button1.Enabled = true;
for (i = 0; i < 10; i++)
{
}
for (i = 0; i < 30; i++)
{
}
prezzo.Text = "0";
s = 1;
a = 1;
textBox1.Text = "0";
}
private void iniz()
{
check[0] = this.checkBox1;
check[1] = this.checkBox2;
check[2] = this.checkBox3;
check[3] = this.checkBox4;
check[4] = this.checkBox5;
check[5] = this.checkBox6;
check[6] = this.checkBox7;
check[7] = this.checkBox8;
check[8] = this.checkBox9;
check[9] = this.checkBox10;
radio[0] = this.radioButton1;
radio[1] = this.radioButton2;
radio[2] = this.radioButton3;
radio[3] = this.radioButton4;
radio[4] = this.radioButton5;
radio[5] = this.radioButton6;
radio[6] = this.radioButton7;
radio[7] = this.radioButton8;
radio[8] = this.radioButton9;
radio[9] = this.radioButton10;
radio[10] = this.radioButton11;
radio[11] = this.radioButton12;
radio[12] = this.radioButton13;
radio[13] = this.radioButton14;
radio[14] = this.radioButton15;
radio[15] = this.radioButton16;
radio[16] = this.radioButton17;
radio[17] = this.radioButton18;
radio[18] = this.radioButton19;
radio[19] = this.radioButton20;
radio[20] = this.radioButton21;
radio[21] = this.radioButton22;
radio[22] = this.radioButton23;
radio[23] = this.radioButton24;
radio[24] = this.radioButton25;
radio[25] = this.radioButton26;
radio[26] = this.radioButton27;
radio[27] = this.radioButton28;
radio[28] = this.radioButton29;
radio[29] = this.radioButton30;
}
}
}