private Booking AddBooking(DateTime TimeNow) { String rs = null; Booking b = null; try { int nights = 0; int breakfirst = 0; TimeSpan SubTime = DateTime.Parse(txtCheckOut.Text) - DateTime.Parse(txtCheckIn.Text); if (rbBreakYes.Checked) { if (SubTime.TotalHours % 24 != 0) { breakfirst = (int)SubTime.TotalHours / 24 + 1; } else { breakfirst = (int)SubTime.TotalHours / 24; } } if (rbNightsYes.Checked) { nights = (int)SubTime.TotalHours / 24; } Booking booking = new Booking() { RoomNumber = CurrentRoom.RoomNumber, CheckIn = DateTime.Parse(txtCheckIn.Text), CheckOut = DateTime.Parse(txtCheckOut.Text), Comment = txtComment.Text, Breakfirst = breakfirst, Nights = nights, BookTime = TimeNow, CustomerID = txtCusID.Text }; rs = ManagerDAL.AddNewBooking(booking); if (rs != null) { b = new Booking() { BookingID = rs, Breakfirst = breakfirst, Nights = nights }; } } catch (Exception ex) { MessageBox.Show(ex.Message); } return(b); }