private void BindDrawingNumbers() { int drawingNumbersId = Request.QueryString["DrawingNumbersId"].ToInt(); if (drawingNumbersId > 0) { DrawingNumbers drawingNumbersLookup = DrawingNumbersDAL.GetItem(drawingNumbersId); if (drawingNumbersLookup != null) { lblDrawingNumbersId.Text = drawingNumbersLookup.DrawingId.ToString(); lblBallTypeId.Text = drawingNumbersLookup.BallTypeId.ToString(); lblDrawingId.Text = drawingNumbersLookup.DrawingId.ToString(); lblNumber.Text = drawingNumbersLookup.Number.ToString(); } else { lblMessage.Text = "Drawing Numbers could not be found."; } } else { lblMessage.Text = "Invalid ID. Drawing Numbers record could not be found."; } }
public static DrawingNumbers GetItem(int drawingNumbersId) { DrawingNumbers tempItem = null; using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("usp_GetDrawingNumbers", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetItem); myCommand.Parameters.AddWithValue("@DrawingNumbersId", drawingNumbersId); myConnection.Open(); using (SqlDataReader myReader = myCommand.ExecuteReader()) { if (myReader.Read()) { tempItem = FillDataRecord(myReader); } myReader.Close(); } } } return(tempItem); }
private static DrawingNumbers FillDataRecord(IDataRecord myDataRecord) { DrawingNumbers myObject = new DrawingNumbers(); myObject.DrawingNumbersId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("DrawingNumbersId")); if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("BallTypeId"))) { myObject.BallTypeId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("BallTypeId")); } if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("DrawingId"))) { myObject.DrawingId = myDataRecord.GetInt32(myDataRecord.GetOrdinal("DrawingId")); } if (!myDataRecord.IsDBNull(myDataRecord.GetOrdinal("Number"))) { myObject.Number = myDataRecord.GetInt32(myDataRecord.GetOrdinal("Number")); } return(myObject); }