private void gvBOSExternalEntity_RowStyle(object sender, RowStyleEventArgs e)
        {
            try
            {
                if (e.RowHandle > -1)
                {
                    if (ActiveViewOption != null)
                    {
                        if (sender is GridView view)
                        {
                            if (view.IsRowSelected(e.RowHandle))
                            {
                                return;
                            }
                        }
                        //DataTable table1 = TempDataTableCreator.CreateDataTableFromEntity(gvExample.GetRow(e.RowHandle));
                        //to represent the entity as the one on the scheduler, see if it is already an appointment, so check the scheduler
                        DataTable table     = new DataTable();
                        var       recInGrid = gvBOSExternalEntity.GetRow(e.RowHandle) as BOSEntity;
                        //look for the appointments with the ext ref as subject, and then extract the entity within the appointment with that reference
                        var appts = schedulerDataStorage.Appointments.Items.FindAll(a => (a.CustomFields["ENTITY"] is BOSEntity bosEnt) && bosEnt.ExtRefId == recInGrid.ExtRefId);
                        if (appts.Any())
                        {
                            Appointment appt = appts.FirstOrDefault(a => a.Start.Date == dateNavigator.SelectionStart.Date);
                            if (appt == null)
                            {
                                appt = appts.FirstOrDefault();
                            }

                            table = appt.CustomFields["ENTITY"].ConvertToDataTable();
                        }
                        else
                        {
                            table = recInGrid.ConvertToDataTable();
                        }

                        ApptLabel label = ActiveViewOption.GetApptLabel(table);

                        if (label != null)
                        {
                            e.Appearance.BackColor = Color.FromArgb(label.ColourRGB);
                            e.Appearance.ForeColor = Color.FromArgb(label.ForeColourRGB);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
#if DEBUG
                throw ex;
#endif
            }
        }
        private void gvBOSExternalEntity_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
        {
            try
            {
                if (e.RowHandle > -1)
                {
                    if (ActiveViewOption != null)
                    {
                        //DataTable table1 = TempDataTableCreator.CreateDataTableFromEntity(gvExample.GetRow(e.RowHandle));
                        DataTable  table  = gvBOSExternalEntity.GetRow(e.RowHandle).ConvertToDataTable();
                        ApptStatus status = ActiveViewOption.GetApptStatus(table);
                        e.DefaultDraw();
                        if (status != null)
                        {
                            e.Appearance.BackColor = Color.FromArgb(status.ColourRGB);

                            e.Appearance.FillRectangle(e.Cache, new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1));

                            if (e.Info.IsRowIndicator)
                            {
                                if (!(e.Info.ImageIndex < 0))
                                {
                                    ImageCollection ic        = e.Info.ImageCollection as ImageCollection;
                                    Image           indicator = ic.Images[e.Info.ImageIndex];
                                    e.Cache.Paint.DrawImage(e.Graphics, indicator, new Rectangle(e.Bounds.X + 4, e.Bounds.Y + 20, indicator.Width, indicator.Height));
                                }
                            }
                            e.Handled = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
#if DEBUG
                throw ex;
#endif
            }
        }