Error load meeting and time to datagridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hoangluc19
    New Member
    • Mar 2023
    • 5

    #1

    Error load meeting and time to datagridview

    I have 2 table on api data: Booking{ Id, Status, Sort, CreatedDate,Upd atedAt, Title, ParticipatingLe aders, Content, UserCreatedName , UserCreatedEmai l, UserCreatedPhon eNumber, DepartmentId, Start, Stop, LocationId, Request,RoomId, Date, CancelAt, SuccessAt,HostU ser, 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

    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.getB ooking(query).R esult;

    foreach (BookingDetail r in result.Data)

    {

    string idLocal = r.Id.ToString() ;

    selectedId = idLocal + "";

    string idroom = r.RoomId.ToStri ng();

    selectedRoom = idroom + "";

    string start = r.Start.ToStrin g();

    starttime = start;

    string stop = r.Stop.ToString ();

    stoptime = stop;

    string getDate =(r.Date.ToStri ng());

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

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

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

    foreach (DataGridViewRo w 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.ParseE xact(grdRoom.Co lumns[i].HeaderText, "HH:mm", CultureInfo.Inv ariantCulture);//event load here error

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

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

    {

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

    if (startTime == stopTime)

    return;

    else

    startTime = startTime.AddMi nutes(30);

    }

    }

    }

    }

    }

    }
  • juditd
    New Member
    • Sep 2026
    • 3

    #2
    really good good web page

    Comment

    • juditd
      New Member
      • Sep 2026
      • 3

      #3
      like code and picture.

      Comment

      Working...