>Decimal bookingNo = 4000001; > BookingRow bRow = bookings.GetBookingRow(bookingNo); >bookings is null I expect - put a breakpoint and use the debugger
>internal BookingRow GetBookingRow(Decimal bookingNo) > { > BookingRow bookingRow = null; > using (SqlCommand sqlCommand = new SqlCommand()) > { > sqlCommand.CommandText = @"SELECT * > FROM dbo.b_sched > WHERE booking_id = @booking_id;"; > > sqlCommand.CommandType = CommandType.Text; > sqlCommand.Parameters.Add("@booking_id", SqlDbType.BigInt).Value = bookingNo; > > DataSet ds; > String messageText =""; > Int32 statusCode = 0; > if (database.ExecuteSqlCommand(sqlCommand, out ds, ref messageText, ref statusCode)) > { > if (1 == ds.Tables[0].Rows.Count) > bookingRow = new BookingRow(ds.Tables[0].Rows[0]); > } > } > return bookingRow; > }>
>/// <summary> > /// Booking Row class > /// </summary> > public class BookingRow > { > public Decimal BookingId {get; set;} > public String Resource { get; set; } > public String RequiredResource { get; set; } > public Int16 Quantity { get; set; } > public Byte Sex { get; set; } > public String SexName { get; set; } > public Byte Experience { get; set; } > public Boolean Locked { get; set; } > public Byte InstructorType { get; set; } > public DateTime? StartTime { get; set; } > public DateTime? EndTime { get; set; } > public String PayStatus {get;set;} > > public String Notes { get; set; } > public List<Byte> PreferenceLevels = new List<Byte>(); > > public List<Boolean> CriteriaBit = new List<Boolean>(); > public Int16 Criteria1 { get; set; } > public Int32 Criteria4 {get; set;} > public Decimal Criteria5 { get; set; } > public Byte Criteria6 { get; set; } > public Byte Criteria7 { get; set; } > public Dictionary<String, String> Levels = new Dictionary<String, String>(StringComparer.OrdinalIgnoreCase); > > public BookingRow() > { > > } > > public BookingRow(DataRow row) > { > BookingId = row.Field<Decimal>("booking_id"); > Resource = row.Field<String>("resource1"); > Quantity = row.Field<Int16>("quantity"); > RequiredResource = row.Field<String>("resrc_req1"); > PayStatus = row.Field<String>("pay_status"); > Locked = row.Field<Boolean>("locked"); > InstructorType = row.Field<Byte>("instr_type"); > Experience = row.Field<Byte>("experience"); > StartTime = row.Field<DateTime?>("start_time"); > EndTime = row.Field<DateTime?>("end_time"); > > Sex = row.Field<Byte>("sex"); > if (Sex > 1) > SexName = "Male"; > else > SexName = "Female"; > > Levels.Add("alpine", row.Field<String>("tch_level")); > Levels.Add("snowboard", row.Field<String>("snb_level")); > Levels.Add("telemark", row.Field<String>("tele_level")); > Levels.Add("other", row.Field<String>("misc_level")); > Notes = row.Field<String>("notes"); > > Criteria1 = row.Field<Int16>("criteria1"); > Criteria4 = row.Field<Int32>("criteria4"); > Criteria6 = row.Field<Byte>("criteria6"); > Criteria7 = row.Field<Byte>("criteria7"); > > for (int i = 1; i <= 12; i++) > { > if (i >=2 && i<=3) > CriteriaBit.Add(row.Field<Boolean>(String.Format("criteria{0}", i))); > > > PreferenceLevels.Add(row.Field<Byte>(String.Format("prev_lvl{0}", i))); > } > } > }>