コード例 #1
0
ファイル: Form1.cs プロジェクト: kralmachine/Loto-statistics
        private void ballButton_Click(object sender, EventArgs e)
        {
            BLL bll = new BLL();

            dataGrid.Columns.Clear();

            //Get selected balls statistics
            dataGrid.DataSource = bll.GetBallStats(ballsComboBox.SelectedItem.ToString());

            //Calculate total amount of draw for one ball
            int sum = 0;

            for (int i = 0; i < dataGrid.Rows.Count - 1; i++)
            {
                sum += (int)dataGrid[dataGrid.Columns[ballsComboBox.SelectedItem.ToString() + "SAYI"].Index, i].Value;
            }

            //Add a new column with a name that depending on ball
            dataGrid.Columns.Add(ballsComboBox.SelectedItem.ToString() + "ratio", ballsComboBox.SelectedItem.ToString() + "%");
            //Add the show ratios for each number on the ball
            for (int i = 0; i < dataGrid.Rows.Count - 1; i++)
            {
                dataGrid[ballsComboBox.SelectedItem.ToString() + "ratio", i].Value = Convert.ToDouble(dataGrid[dataGrid.Columns[ballsComboBox.SelectedItem.ToString() + "ratio"].Index - 1, i].Value) * 100 / sum;
            }
        }