Esempio n. 1
0
        public static int Save(DrawingNumber gameToSave)
        {
            int returnValue;
            returnValue = DrawingNumberDAL.Save(gameToSave);

            return returnValue;
        }
Esempio n. 2
0
        private void ProcessForm()
        {
            StringBuilder formControlValues = new StringBuilder();

              int number = Number;
              string ballTypeText = BallList.SelectedItem.Text;
              int ballTypeValue = BallList.SelectedValue.ToInt();

              //notes:    set Game properties
              DrawingNumber numberToSave = new DrawingNumber();
              LotteryDrawing h = new LotteryDrawing();

              //notes:    game specific info
              numberToSave.DrawingNumberValue = number;
              numberToSave.BallType =  ballTypeValue.ToString();

              //notes:    detail specific info

              //notes:    call middle tier to save details
              DrawingNumberManager.Save(numberToSave);

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

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

              }
              else
              {
                  //notes:    INSERT was successful - redirect back
                  Response.Redirect("Drawing.aspx?LotteryId=" + numberToSave.DrawingNumberId.ToString());
              }
        }
Esempio n. 3
0
        public static int Save(DrawingNumber numberToSave)
        {
            int result = 0;
            ExecuteTypeEnum queryId = ExecuteTypeEnum.InsertItem;

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

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

                    myCommand.Parameters.AddWithValue("@QueryId", queryId);
                    myCommand.Parameters.AddWithValue("@DrawingTypeId", numberToSave.DrawingTypeId);
                    myCommand.Parameters.AddWithValue("@DrawingNumberValue", numberToSave.DrawingNumberValue);
                    myCommand.Parameters.AddWithValue("@LotteryDrawingId", numberToSave.LotteryDrawingId);

                    //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;
        }
Esempio n. 4
0
        private static DrawingNumber FillDataRecord(IDataRecord myDataRecord)
        {
            DrawingNumber myObject = new DrawingNumber();

            myObject.DrawingNumberId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("DrawingNumberId"));
            myObject.LotteryDrawingId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("LotteryDrawingId"));

            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("DrawingNumberValue")))
                myObject.DrawingNumberValue = myDataRecord.GetInt32(myDataRecord.GetOrdinal("DrawingNumberValue"));

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

            if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("DrawingTypeId")))
                myObject.DrawingTypeId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("DrawingTypeId"));

            return myObject;
        }