Example #1
0
 public WinnerViewModel(WinnerInfo winnerInfo)
 {
     UserId    = winnerInfo.UserId;
     Position  = winnerInfo.Position;
     Amount    = winnerInfo.Amount;
     HandScore = winnerInfo.HandScore;
     Hand      = ((PokerScores)HandScore).ToString();
 }
Example #2
0
        private void btnStartOrStop_Click(object sender, EventArgs e)
        {
            if (btnStartOrStop.Text == "继续摇奖")
            {
                ClearLabel(everyNum);
                btnStartOrStop.Text = "停止";
                toolStripMenuItem1_Click(sender, e);
                //b = true;
                axMusicPlay.Ctlcontrols.stop();
            }
            else
            {
                //取值插入数据库
                b = false;
                for (int i = 0; i < everyNum; i++)
                {
                    if (ths != null && ths[i] != null)
                    {
                        ths[i].Abort();
                    }
                }

                using (SQLiteConnection connection = new SQLiteConnection(SQLiteHelper.Conn))
                {
                    connection.Open();
                    using (DbTransaction dbTrans = connection.BeginTransaction())
                    {
                        using (DbCommand cmd = connection.CreateCommand())
                        {
                            try
                            {
                                for (int j = 0; j < everyNum; j++)
                                {
                                    Label      label      = FindControl(j.ToString()) as Label;
                                    WinnerInfo winnerInfo = new WinnerInfo();

                                    if (prizeCurrent == 0)
                                    {
                                        winnerInfo.PrizeID = Convert.ToInt32(dtPrize.Rows[prizeCurrent]["ID"]);
                                    }
                                    else
                                    {
                                        winnerInfo.PrizeID = Convert.ToInt32(dtPrize.Rows[prizeCurrent - 1]["ID"]);//prizeCurrent有++操作,所以此处要-1
                                    }
                                    winnerInfo.WinnerName  = label.Text;
                                    winnerInfo.WinnerPhone = string.Empty;

                                    cmd.CommandText = "INSERT INTO Winners(PrizeID,Winner,WinnerPhone) VALUES (@PrizeID,@Winner,@WinnerPhone)";
                                    cmd.Parameters.Add(new SQLiteParameter("@PrizeID", winnerInfo.PrizeID));
                                    cmd.Parameters.Add(new SQLiteParameter("@Winner", winnerInfo.WinnerName));
                                    cmd.Parameters.Add(new SQLiteParameter("@WinnerPhone", winnerInfo.WinnerPhone));
                                    cmd.ExecuteNonQuery();
                                    listStr.Remove(winnerInfo.WinnerName);
                                }
                                dbTrans.Commit();
                                btnStartOrStop.Text = "继续摇奖";
                            }
                            catch (Exception ex)
                            {
                                dbTrans.Rollback();
                                MessageBox.Show("该次名单保存失败!!" + ex.Message);
                            }
                        }
                    }
                }
                axMusicPlay.URL = ConfigHelper.GetValue("StopMusic");//ConfigurationManager.AppSettings["StopMusic"].ToString();
                axMusicRoll.Ctlcontrols.pause();
            }
        }