Ejemplo n.º 1
0
        private static int SaveGame(LotteryGameDetail detailsToSave)
        {
            LotteryGameValue tempGame = new LotteryGameValue();
            tempGame.LotteryGameId = detailsToSave.LotteryGameId;

            if (detailsToSave.GameName != null)
                tempGame.GameName = detailsToSave.GameName;

            if (detailsToSave.GameNameAbbrev != null)
                tempGame.GameNameAbbrev = detailsToSave.GameNameAbbrev;

            return LotteryGameManager.Save(tempGame);
        }
Ejemplo n.º 2
0
        public static int Save(LotteryGameDetail detailsToSave)
        {
            LotteryGameDetail game = new LotteryGameDetail();
            game.LotteryGameId = detailsToSave.LotteryGameId;

            int lotteryGameId = SaveGame(detailsToSave);
            detailsToSave.LotteryGameId = lotteryGameId;

            if (detailsToSave.GameDescription != null)
                game.GameDescription = detailsToSave.GameDescription;

            if (detailsToSave.HowToPlay != null)
                game.HowToPlay = detailsToSave.HowToPlay;

            if (detailsToSave.Cost != null)
                game.Cost = detailsToSave.Cost;

            return DetailsDAL.Save(detailsToSave);
        }
Ejemplo n.º 3
0
        public static int Save(LotteryGameDetail detailsToSave)
        {
            int result = 0;
            ExecuteTypeEnum queryId = ExecuteTypeEnum.InsertItem;

            // notes:       check for valid LotteryGameId - if exists then UPDATE , else INSERT
            if (detailsToSave.LotteryGameDetailId > 0)
                queryId = ExecuteTypeEnum.UpdateItem;

            using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("usp_ExecuteLotteryGameDetail", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    myCommand.Parameters.AddWithValue("@QueryId", queryId);
                    myCommand.Parameters.AddWithValue("@LotteryGameId", detailsToSave.LotteryGameId);

                    if (detailsToSave.GameDescription != null)
                        myCommand.Parameters.AddWithValue("@GameDescription", detailsToSave.GameDescription);
                    if (detailsToSave.HowToPlay != null)
                        myCommand.Parameters.AddWithValue("@HowToPlay", detailsToSave.HowToPlay);
                    if (detailsToSave.Cost != null)
                        myCommand.Parameters.AddWithValue("@Cost", detailsToSave.Cost);

                    //notes:    add return output parameter to command object
                    myCommand.Parameters.Add(HelperDAL.GetReturnParameterInt("ReturnValue"));

                    myConnection.Open();
                    myCommand.ExecuteNonQuery();

                    //notes:    get return value from stored procedure and return Id
                    result = (int)myCommand.Parameters["@ReturnValue"].Value;
                }
                myConnection.Close();
            }
            return result;
        }
Ejemplo n.º 4
0
        private static LotteryGameDetail FillDataRecord(IDataRecord myDataRecord)
        {
            LotteryGameDetail myObject = new LotteryGameDetail();

            myObject.LotteryGameDetailId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("LotteryGameDetailId"));
            myObject.LotteryGameId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("LotteryGameId"));

            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("GameDescription")))
                myObject.GameDescription = myDataRecord.GetString(myDataRecord.GetOrdinal("GameDescription"));

            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("HowToPlay")))
                myObject.HowToPlay = myDataRecord.GetString(myDataRecord.GetOrdinal("HowToPlay"));

            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Cost")))
                myObject.Cost = myDataRecord.GetString(myDataRecord.GetOrdinal("Cost"));

            return myObject;
        }
Ejemplo n.º 5
0
        private void ProcessForm()
        {
            StringBuilder formControlValues = new StringBuilder();

            string Win = Win1.Text;
            string odd = Odd.Text;
            string match = Match.Text;

            //notes:    set Game properties
            LotteryGameDetail detailToSave = new LotteryGameDetail();

            //notes:    game specific info
            //detailToSave.GameName = gameName;
               // detailToSave.GameNameAbbrev = gameNameAbbrev;

            //notes:    detail specific info
            //detailToSave.HowToPlay = howToPlay;
            //detailToSave.GameDescription = gameDescription;
            //detailToSave.Cost = cost;

            //notes:    call middle tier to save details
            DetailsManager.Save(detailToSave);

            //notes:    set Id's from hidden fields
            //detailToSave.LotteryGameId = LotteryGameId.Value.ToInt();

            // Output
            if (detailToSave.LotteryGameId > 0)
            {
                base.DisplayPageMessage(PageMessage, "Update was successful.");

            }
            else
            {
                //notes:    INSERT was successful - redirect back
                Response.Redirect("LotteryBasic.aspx?LotteryId=" + detailToSave.LotteryGameId.ToString());
            }
        }