protected IList <DrawNumber> GetAllDrawNumbers()
        {
            var a = new List <DrawNumber>();

            using (var b = Cc())
            {
                b.Open();
                var c = A(X.C, b);
                using (var d = C(c))
                {
                    int e = B(d, "DrawId");
                    int f = B(d, "Number");
                    int g = B(d, "Position");

                    while (d.Read())
                    {
                        var j = new DrawNumber
                        {
                            DrawId   = d.GetInt32(e),
                            Number   = d.GetInt32(f),
                            Position = d.IsDBNull(g) ? null : (int?)d.GetInt32(g)
                        };
                        a.Add(j);
                    }
                }
            }
            return(a);
        }
 public DrawNumberBuilder(Random random)
 {
     _random     = random ?? new Random();
     _drawNumber = new DrawNumber
     {
         Number   = _random.Next(1, int.MaxValue),
         Position = null
     };
 }
Esempio n. 3
0
 private void ShowSpecificDrawPanel()
 {
     GameSelectionPanel.Visibility = Visibility.Collapsed;
     DrawSelectionPanel.Visibility = Visibility.Collapsed;
     lastDrawPanel.Visibility      = Visibility.Collapsed;
     specificDrawPanel.Visibility  = Visibility.Visible;
     drawByDatePanel.Visibility    = Visibility.Collapsed;
     menuPanel.Visibility          = Visibility.Visible;
     OpapResults     = null;
     DrawNumber.Text = "";
     DrawNumber.Focus();
     specificDrawResultsPanel.Visibility = Visibility.Collapsed;
 }
Esempio n. 4
0
        /// <summary>
        /// Add number visualisation
        /// </summary>
        /// <param name="num"></param>
        /// <param name="sequenceVisualList"></param>
        /// <param name="countersHolder"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        private static DrawNumber GetNumberApearance(int num, DrawSequenceVisualList sequenceVisualList, CountersHolder countersHolder, VikingLottoNumbers item)
        {
            DrawNumber drawNumber = new DrawNumber();

            if (item.NumCollection.Contains(num))
            {
                drawNumber.No = "Images/W_No/w" + num.ToString() + ".png";
            }
            else
            {
                drawNumber.No = "Images/No/" + countersHolder.NotDrawCounter.ToString() + ".png";
            }

            return(drawNumber);
        }
Esempio n. 5
0
    void Start()
    {
        Instance      = this;
        draw          = new DrawNumber();
        tmp           = 0;
        ScorePlayer_1 = 0;
        ScorePlayer_2 = 0;

        // Set margin by screen size
        if (((float)Screen.height / (float)Screen.width) < 1.7f)
        {
            marginLeft  = 25f;
            marginRight = 25f;
        }
        else
        {
            marginLeft  = 40f;
            marginRight = 40f;
        }

        // Sound
        SoundClick1 = (AudioSource)gameObject.AddComponent <AudioSource>();
        SoundClick2 = (AudioSource)gameObject.AddComponent <AudioSource>();
        SoundResult = (AudioSource)gameObject.AddComponent <AudioSource>();

        AudioClip ClickAudioClip_1;

        ClickAudioClip_1 = (AudioClip)Resources.Load("Audio/Click_Number1");
        SoundClick1.clip = ClickAudioClip_1;
        SoundClick1.loop = false;

        AudioClip ClickAudioClip_2;

        ClickAudioClip_2 = (AudioClip)Resources.Load("Audio/Click_Number2");
        SoundClick2.clip = ClickAudioClip_2;
        SoundClick2.loop = false;

        AudioClip ResultAudioClip;

        ResultAudioClip  = (AudioClip)Resources.Load("Audio/Winner");
        SoundResult.clip = ResultAudioClip;
        SoundResult.loop = false;

        isSoundON = UIManagerScript.Instance.isSoundON;
        isMusicON = UIManagerScript.Instance.isMusicON;

        ShowListNumber();
    }
Esempio n. 6
0
        public void CreateDrawFor(LotteryGame lotteryGame)
        {
            Draw newDraw = new Draw()
            {
                LotteryGameId = lotteryGame.Id,
                LotteryGame   = lotteryGame,
                Date          = DateTime.Now
            };

            int                number;
            ArrayList          checkNumbers = new ArrayList();
            IList <DrawNumber> numbers      = new List <DrawNumber>();

            for (int i = 1; i <= lotteryGame.NumberOfNumbersInADraw; i++)
            {
                Random rnd = new Random();
                number = rnd.Next(1, lotteryGame.MaximumNumber);
                if (checkNumbers.Contains(number))
                {
                    do
                    {
                        number = rnd.Next(1, lotteryGame.MaximumNumber);
                    } while (checkNumbers.Contains(number));

                    checkNumbers.Add(number);
                }
                else
                {
                    checkNumbers.Add(number);
                }

                var nummer = new DrawNumber()
                {
                    DrawId = i, Number = number, Position = i
                };
                numbers.Add(nummer);
            }

            newDraw.DrawNumbers = numbers;

            drawRepository.Add(newDraw);
        }
Esempio n. 7
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            IList <DrawNumber> drawNumbers = value as IList <DrawNumber>;
            var query = drawNumbers.OrderBy(s => s.Position);

            drawNumbers = query.ToList();
            string numbers = null;

            for (int i = 0; i < drawNumbers.Count; i++)
            {
                DrawNumber number = drawNumbers[i];
                if (i < drawNumbers.Count - 1)
                {
                    numbers += number.Number + ", ";
                }
                else
                {
                    numbers += number.Number;
                }
            }

            return(numbers);
        }
Esempio n. 8
0
        public static void InitDatabase()
        {
            #region initial excel connection
            string          FilePath   = "../../Database/lotto.xlsx";
            string          connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FilePath + ";Extended Properties=Excel 12.0";
            OleDbConnection ExcelConn  = new OleDbConnection(connString);
            DataSet         Dset       = new DataSet();
            #endregion

            #region get data from excel file
            try
            {
                ExcelConn.Open();
                OleDbCommand     cmd = new OleDbCommand("SELECT * FROM [Sheet1$]", ExcelConn);
                OleDbDataAdapter Ad  = new OleDbDataAdapter(cmd);
                Ad.Fill(Dset);
            }
            catch { }
            finally
            {
                ExcelConn.Close();
            }
            foreach (DataRow row in Dset.Tables[0].Rows)
            {
                DrawNumber addNumber = new DrawNumber(
                    Convert.ToInt16(row[0].ToString()),
                    Convert.ToDateTime(row[1].ToString()),
                    Convert.ToByte(row[2].ToString()),
                    Convert.ToByte(row[3].ToString()),
                    Convert.ToByte(row[4].ToString()),
                    Convert.ToByte(row[5].ToString()),
                    Convert.ToByte(row[6].ToString()),
                    Convert.ToByte(row[7].ToString()),
                    Convert.ToByte(row[8].ToString())
                    );
                GlobalVar.DrawResult.Add(addNumber);
            }
            #endregion

            #region Create and add result data to SQL server
            List <DateTime> DrawDate = new List <DateTime>();
            DateTime        StarDate = new DateTime(2012, 03, 23);
            while (DateTime.Compare(StarDate, DateTime.Now) <= 0)
            {
                DrawDate.Add(StarDate);
                StarDate = StarDate.AddDays(7);
            }
            SqlConnection MyConnection = new SqlConnection(GlobalVar.ConnectionStringSQL);
            SqlCommand    MyCommand    = new SqlCommand();
            MyCommand.Connection = MyConnection;
            MyConnection.Open();
            MyCommand.CommandText = "DROP TABLE DrawResult";
            MyCommand.ExecuteNonQuery();
            MyCommand.CommandText = "create table DrawResult ( ID smallint NOT NULL Primary key identity(1,1), DrawDate Date, Num1 tinyint Default 0, Num2 tinyint Default 0, Num3 tinyint Default 0, Num4 tinyint Default 0, Num5 tinyint Default 0, EURnum1 tinyint Default 0, EURnum2 tinyint Default 0 )";
            MyCommand.ExecuteNonQuery();
            MyCommand.Parameters.Add(new SqlParameter("@DrDate", System.Data.SqlDbType.Date));
            foreach (DateTime DrDate in DrawDate)
            {
                MyCommand.CommandText         = "INSERT INTO DrawResult (DrawDate) VALUES (@DrDate)";
                MyCommand.Parameters[0].Value = DrDate;
                MyCommand.ExecuteNonQuery();
            }
            #endregion

            #region Create and add statistic to SQL server
            foreach (DrawNumber Result in GlobalVar.DrawResult)
            {
                DrawDateContext.UpdateDrawNumber(Result, GlobalVar._DataService);
            }

            MyCommand.CommandText = "DROP TABLE SumStatistic";
            MyCommand.ExecuteNonQuery();


            MyCommand.CommandText = "create table SumStatistic ( ID smallint NOT NULL Primary key identity(1,1), DrawSum int Default 0, NumberGroup tinyint Default 0, AppearCount smallint Default 0 ); ";
            MyCommand.ExecuteNonQuery();

            MyCommand.Parameters.Add(new SqlParameter("@DrawSum", System.Data.SqlDbType.Int));
            MyCommand.Parameters.Add(new SqlParameter("@NumberGroup", System.Data.SqlDbType.TinyInt));
            MyCommand.Parameters.Add(new SqlParameter("@AppearCount", System.Data.SqlDbType.SmallInt));
            for (int i = 0; i < 2; i++)
            {
                int[,] SumVal = CalculateSum(GlobalVar.DrawResult)[i];
                for (int t = 0; t < SumVal.GetLength(0); t++)
                {
                    MyCommand.CommandText = "INSERT INTO SumStatistic (DrawSum,NumberGroup,AppearCount) VALUES (@DrawSum,@NumberGroup,@AppearCount)";
                    MyCommand.Parameters["@DrawSum"].Value     = SumVal[t, 0];
                    MyCommand.Parameters["@NumberGroup"].Value = i;
                    MyCommand.Parameters["@AppearCount"].Value = SumVal[t, 1];
                    MyCommand.ExecuteNonQuery();
                }
            }
            #endregion
        }
Esempio n. 9
0
 private string FenDrawNumber()
 {
     return(DrawNumber.ToString());
 }
Esempio n. 10
0
    // Use this for initialization
    void Start()
    {
        Instance = this;

        // Set margin by screen size
        if (((float)Screen.height / (float)Screen.width) < 1.7f)
        {
            marginLeft  = 25f;
            marginRight = 25f;
        }
        else
        {
            marginLeft  = 40f;
            marginRight = 40f;
        }
        marginTop    = 150f;
        marginBottom = 25f;

        // Disable PanelChoice
        PanelChoice.SetActive(false);

        draw      = gameObject.AddComponent <DrawNumber>();
        btnScript = gameObject.AddComponent <ButtonPrefab>();

        // Load Best Score of each level
        BestScoreLV_0 = PlayerPrefs.GetInt(saveBestScoreLV_0, 0);
        BestScoreLV_1 = PlayerPrefs.GetInt(saveBestScoreLV_1, 0);
        BestScoreLV_2 = PlayerPrefs.GetInt(saveBestScoreLV_2, 0);
        BestScoreLV_3 = PlayerPrefs.GetInt(saveBestScoreLV_3, 0);
        BestScoreLV_4 = PlayerPrefs.GetInt(saveBestScoreLV_4, 0);
        Gold          = PlayerPrefs.GetInt(saveGold, 0);

        // Set time for each level
        if (PanelChoiceScript.Instance.Choice_Level == 0)
        {
            numberCount = 90;
            TimeLevel   = 16;
            time        = TimeLevel;
        }

        if (PanelChoiceScript.Instance.Choice_Level == 1)
        {
            numberCount = 100;
            TimeLevel   = 16;
            time        = TimeLevel;
        }

        if (PanelChoiceScript.Instance.Choice_Level == 2)
        {
            numberCount = 100;
            TimeLevel   = 11;
            time        = TimeLevel;
        }

        // Level 2
        if (PanelChoiceScript.Instance.Choice_Level == 3)
        {
            numberCount = 100;
            TimeLevel   = 501;
            time        = TimeLevel;

            ImgClock.gameObject.SetActive(false);
            ImgClockLV3.gameObject.SetActive(true);
            TxttimeLV3.gameObject.SetActive(true);
        }

        // Level 4
        Generate_ListRanDomNumber();
        count = 0;
        if (PanelChoiceScript.Instance.Choice_Level == 4)
        {
            numberCount           = 100;
            TxtcurrentNumber.text = ListRandomNumber[0].ToString();
            TimeLevel             = 16;
            time = TimeLevel;
        }

        runTime   = true;
        resetTime = false;

        // Sound
        SoundClick     = gameObject.AddComponent <AudioSource>();
        SoundResult    = gameObject.AddComponent <AudioSource>();
        SoundResult100 = gameObject.AddComponent <AudioSource>();

        isSoundON = UIManagerScript.Instance.isSoundON;
        isMusicON = UIManagerScript.Instance.isMusicON;

        AudioClip ClickAudioClip;

        ClickAudioClip  = (AudioClip)Resources.Load("Audio/Click_Number1");
        SoundClick.clip = ClickAudioClip;
        SoundClick.loop = false;

        AudioClip ResultAudioClip;

        ResultAudioClip  = (AudioClip)Resources.Load("Audio/Result");
        SoundResult.clip = ResultAudioClip;
        SoundResult.loop = false;

        AudioClip Result100AudioClip;

        Result100AudioClip  = (AudioClip)Resources.Load("Audio/Winner");
        SoundResult100.clip = Result100AudioClip;
        SoundResult100.loop = false;

        // Show numbers
        ShowListNumber();
    }