honag luc

honag luc

  • NA
  • 123
  • 8.9k

Error load meeting and time to datagridview

Mar 8 2023 10:11 AM

I have 2 table on api data: Booking{ Id, Status, Sort, CreatedDate,UpdatedAt, Title, ParticipatingLeaders, Content, UserCreatedName, UserCreatedEmail, UserCreatedPhoneNumber, DepartmentId, Start, Stop, LocationId, Request,RoomId, Date, CancelAt, SuccessAt,HostUser, LocationName, RoomName }

Room{ Id, Status, Sort, CreatedDate, CreatedAt, UpdatedAt, UpdatedBy, CodeNaame, Name, LocationId, Volumn, Items, Images }

After booking and save the meeting room, the data will be submitted to the Booking table. on form i create datagridview to view

meeting schedule and meeting room get the list of rooms in the Room api table and add new hour columns

add a new column that is the time and get the data to browse the Booking table to compare the start time and end time of the meeting

like code and picture. convert columns header is hour to compare and get the time range and load the color to know which room is meeting at which time

in the load event call the function: selectAreaColor() then got an error, but the load function does not call and book the room,

it can run and get the results as shown, but when starting to run and the load function calls, the error hope everyone can help, thanks a lot. when adding new run debug, it browses from column header at 08:00 to the end of column and booking table data runs ok and the load event, it browses the data from the booking table to the columns on the datagridview, so it crashes.

A meeting room has many meeting schedules, for example, there are 3 different meeting time frames and are on the same row, so how can I get the id of each meeting schedule? up to update

here is the code to get the display area of meeting time and meeting schedule

private void selectAreaColor()

{

string starttime ;

string stoptime ;

string selectedRoom ;

string selectedId ;

QueryRQ query = CreateQuery();

BookingIndexRS result = apiBooking.getBooking(query).Result;
//Loop through the BookingDetail table to get the required values Id, roomId, starttime,stoptime. but when it loads it gets all the fields in the table
//BookingDetail so when compared with Header time: 08:00,08:30....18:00 error

foreach (BookingDetail r in result.Data)

{

string idLocal = r.Id.ToString();

selectedId = idLocal + "";

string idroom = r.RoomId.ToString();

selectedRoom = idroom + "";

string start = r.Start.ToString();

starttime = start;

string stop = r.Stop.ToString();

stoptime = stop;

string getDate =(r.Date.ToString());

// Get the start time and end time inputs and the selected meeting room

DateTime startTime = DateTime.ParseExact(starttime, "HH:mm", null);

DateTime stopTime = DateTime.ParseExact(stoptime, "HH:mm", null);

foreach (DataGridViewRow row in grdRoom.Rows)

{

if (row.Cells["Id"].Value.ToString() == selectedRoom)

{

int rowIndex = row.Index;

// Loop through the columns and compare the start and end times with the time slots

for (int i = 1; i < grdRoom.Columns.Count; i++)

{

DateTime columnTime = DateTime.ParseExact(grdRoom.Columns[i].HeaderText, "HH:mm", CultureInfo.InvariantCulture);//event load here error while add new not error, but call on event load is error

string _HeaderText = grdRoom.Columns[i].Name.ToString();

if (startTime == columnTime)//|| endTime == columnTime

{

grdRoom.Rows[rowIndex].Cells[_HeaderText].Style.BackColor = Color.Blue;

if (startTime == stopTime)

return;

else

startTime = startTime.AddMinutes(30);

}

}

}

}

}

}


Answers (1)