Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Centro Scommesse SNAI - Form1.cs

Form1.cs

Caricato da: Carmine
Scarica il programma completo

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace Scommesse
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.         }
  18.         double s = 1;
  19.         CheckBox[] check = new CheckBox[10];
  20.         RadioButton[] radio = new RadioButton[30];
  21.         int i,j=0;
  22.         int a = 1;
  23.         public void button1_Click(object sender, EventArgs e)
  24.         {
  25.                 iniz();
  26.                 if (Convert.ToInt32(prezzo.Text) == 0) MessageBox.Show("Prezzo non inserito");
  27.                 else
  28.                 {
  29.                         for (j = 0; j < 3; j++)
  30.                         {
  31.                             if (check[0].Checked)
  32.                             {
  33.                                 if (radio[j].Checked) { s = s * (Convert.ToDouble(radio[j].Text));}
  34.                             }
  35.                         }
  36.                         for (j = 3; j < 6; j++)
  37.                         {
  38.                             if (check[1].Checked)
  39.                             {
  40.                                 if (radio[j].Checked) { s = s * (Convert.ToDouble(radio[j].Text)); }
  41.                             }
  42.                         }
  43.                         for (j = 6; j < 9; j++)
  44.                         {
  45.                             if (check[2].Checked)
  46.                             {
  47.                                 if (radio[j].Checked) { s = s * (Convert.ToDouble(radio[j].Text)); }
  48.                             }
  49.                         }
  50.                         for (j = 9; j < 12; j++)
  51.                         {
  52.                             if (check[3].Checked)
  53.                             {
  54.                                 if (radio[j].Checked) { s = s * (Convert.ToDouble(radio[j].Text)); }
  55.                             }
  56.                         }
  57.                         for (j = 12; j < 15; j++)
  58.                         {
  59.                             if (check[4].Checked)
  60.                             {
  61.                                 if (radio[j].Checked) { s = s * (Convert.ToDouble(radio[j].Text)); }
  62.                             }
  63.                         }
  64.                         for (j = 15; j < 18; j++)
  65.                         {
  66.                             if (check[5].Checked)
  67.                             {
  68.                                 if (radio[j].Checked) { s = s * (Convert.ToDouble(radio[j].Text)); }
  69.                             }
  70.                         }
  71.                         for (j = 18; j < 21; j++)
  72.                         {
  73.                             if (check[6].Checked)
  74.                             {
  75.                                 if (radio[j].Checked) { s = s * (Convert.ToDouble(radio[j].Text)); }
  76.                             }
  77.                         }
  78.                         for (j = 21; j < 24; j++)
  79.                         {
  80.                             if (check[7].Checked)
  81.                             {
  82.                                 if (radio[j].Checked) { s = s * (Convert.ToDouble(radio[j].Text)); }
  83.                             }
  84.                         }
  85.                         for (j = 24; j < 27; j++)
  86.                         {
  87.                             if (check[8].Checked)
  88.                             {
  89.                                 if (radio[j].Checked) { s = s * (Convert.ToDouble(radio[j].Text)); }
  90.                             }
  91.                         }
  92.                         for (j = 27; j < 30; j++)
  93.                         {
  94.                             if (check[9].Checked)
  95.                             {
  96.                                 if (radio[j].Checked) { s = s * (Convert.ToDouble(radio[j].Text)); }
  97.                             }
  98.                         }
  99.                     if (a == 1) { s = s * Convert.ToInt32(prezzo.Text); a = 0; }
  100.                     textBox1.Text = s.ToString();
  101.                     textBox1.Text = String.Format("{0:F2}", s);
  102.                     button1.Enabled = false;
  103.                 }
  104.                        
  105.         }
  106.         private static Random m_Rand = new Random(DateTime.Now.Millisecond);
  107.         private static double RandomNumber(double min, double max)
  108.         {
  109.             return (max - min) * m_Rand.NextDouble() + min;
  110.         }
  111.        
  112.         private void button2_Click(object sender, EventArgs e)
  113.         {
  114.             iniz();
  115.             double rand = RandomNumber(1.10, 4.00);
  116.             for (i = 0; i < 30; i++)
  117.             {
  118.                 rand = RandomNumber(1.10, 4.00);
  119.                 radio[i].Text = rand.ToString();
  120.                 radio[i].Text = String.Format("{0:F2}", rand);
  121.             }
  122.             button2.Enabled = false;
  123.         }
  124.  
  125.         private void button3_Click(object sender, EventArgs e)
  126.         {
  127.             iniz();
  128.             button1.Enabled = true;
  129.             for (i = 0; i < 10; i++)
  130.             {
  131.                 check[i].Checked = false;
  132.             }
  133.             for (i = 0; i < 30; i++)
  134.             {
  135.                 radio[i].Checked = false;
  136.             }
  137.             prezzo.Text = "0";
  138.             s = 1;
  139.             a = 1;
  140.             textBox1.Text = "0";
  141.            
  142.         }
  143.  
  144.         private void iniz()
  145.         {
  146.             check[0] = this.checkBox1;
  147.             check[1] = this.checkBox2;
  148.             check[2] = this.checkBox3;
  149.             check[3] = this.checkBox4;
  150.             check[4] = this.checkBox5;
  151.             check[5] = this.checkBox6;
  152.             check[6] = this.checkBox7;
  153.             check[7] = this.checkBox8;
  154.             check[8] = this.checkBox9;
  155.             check[9] = this.checkBox10;
  156.             radio[0] = this.radioButton1;
  157.             radio[1] = this.radioButton2;
  158.             radio[2] = this.radioButton3;
  159.             radio[3] = this.radioButton4;
  160.             radio[4] = this.radioButton5;
  161.             radio[5] = this.radioButton6;
  162.             radio[6] = this.radioButton7;
  163.             radio[7] = this.radioButton8;
  164.             radio[8] = this.radioButton9;
  165.             radio[9] = this.radioButton10;
  166.             radio[10] = this.radioButton11;
  167.             radio[11] = this.radioButton12;
  168.             radio[12] = this.radioButton13;
  169.             radio[13] = this.radioButton14;
  170.             radio[14] = this.radioButton15;
  171.             radio[15] = this.radioButton16;
  172.             radio[16] = this.radioButton17;
  173.             radio[17] = this.radioButton18;
  174.             radio[18] = this.radioButton19;
  175.             radio[19] = this.radioButton20;
  176.             radio[20] = this.radioButton21;
  177.             radio[21] = this.radioButton22;
  178.             radio[22] = this.radioButton23;
  179.             radio[23] = this.radioButton24;
  180.             radio[24] = this.radioButton25;
  181.             radio[25] = this.radioButton26;
  182.             radio[26] = this.radioButton27;
  183.             radio[27] = this.radioButton28;
  184.             radio[28] = this.radioButton29;
  185.             radio[29] = this.radioButton30;
  186.         }
  187.  
  188.     }
  189. }