Exemplo n.º 1
0
        public void InsertWinningBet(LotteryWinningBet lotteryWinningBet)
        {
            using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource())
                using (OleDbCommand command = new OleDbCommand())
                {
                    command.CommandType = CommandType.Text;
                    command.CommandText = " INSERT INTO lottery_winning_bet " +
                                          "        (bet_id,         winning_amt, active, claim_status, num1,  num2,  num3,  num4,  num5,  num6)" +
                                          " VALUES (@lotteryBetID,  @winningAmt, true,   @claimStatus, @num1, @num2, @num3, @num4, @num5, @num6)";
                    command.Parameters.AddWithValue("@lotteryBetID", lotteryWinningBet.GetLotteryBetId());
                    command.Parameters.AddWithValue("@winningAmt", lotteryWinningBet.GetWinningAmount());
                    command.Parameters.AddWithValue("@claimStatus", lotteryWinningBet.IsClaimed());
                    command.Parameters.AddWithValue("@num1", lotteryWinningBet.GetNum1());
                    command.Parameters.AddWithValue("@num2", lotteryWinningBet.GetNum2());
                    command.Parameters.AddWithValue("@num3", lotteryWinningBet.GetNum3());
                    command.Parameters.AddWithValue("@num4", lotteryWinningBet.GetNum4());
                    command.Parameters.AddWithValue("@num5", lotteryWinningBet.GetNum5());
                    command.Parameters.AddWithValue("@num6", lotteryWinningBet.GetNum6());
                    command.Connection = conn;
                    conn.Open();
                    OleDbTransaction transaction = conn.BeginTransaction();
                    command.Transaction = transaction;
                    int result = command.ExecuteNonQuery();

                    if (result < 0)
                    {
                        transaction.Rollback();
                        throw new Exception(String.Format(ResourcesUtils.GetMessage("lot_dao_impl_msg10"), lotteryWinningBet.GetLotteryBetId()));
                    }
                    transaction.Commit();
                }
        }
        private void objectListViewBets_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            OLVListItem       eOlv = (OLVListItem)e.Item;
            LotteryWinningBet bet  = (LotteryWinningBet)eOlv.RowObject;

            e.Item.Tag = (eOlv.Checked == bet.IsClaimed()) ? null : MODIFIED_TAG;
            ColorListViewItemIfModified((OLVListItem)e.Item);
        }
 private void FillUpBetList()
 {
     objectListViewWinningBets.SetObjects(lotteryDataServices.GetLotteryWinningBets(dateTimePickerBets.Value));
     foreach (OLVListItem item in objectListViewWinningBets.Items)
     {
         LotteryWinningBet bet = (LotteryWinningBet)item.RowObject;
         item.Checked = bet.IsClaimed();
     }
 }
Exemplo n.º 4
0
        public void UpdateClaimStatus(LotteryWinningBet winBet)
        {
            using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource())
                using (OleDbCommand command = new OleDbCommand())
                {
                    command.CommandType = CommandType.Text;
                    command.CommandText = " UPDATE lottery_winning_bet SET claim_status = @claim_status " +
                                          " WHERE ID = @id AND active = true";
                    command.Parameters.AddWithValue("@claim_status", winBet.IsClaimed());
                    command.Parameters.AddWithValue("@id", winBet.GetID());
                    command.Connection = conn;
                    conn.Open();
                    OleDbTransaction transaction = conn.BeginTransaction();
                    command.Transaction = transaction;
                    int result = command.ExecuteNonQuery();

                    if (result < 0)
                    {
                        transaction.Rollback();
                        throw new Exception(String.Format(ResourcesUtils.GetMessage("lot_dao_impl_msg12"), winBet.GetID()));
                    }
                    transaction.Commit();
                }
        }