var
beds,used:integer;
roomsn,direction:string;//房号/朝向
textrect,panelRect:TRect;
begin
inherited;
with DBCtrlGrid do
begin
//取数据
with datasource.DataSet do
begin
roomsn := FieldByname('Do_Room_sn').AsString ;
end;
//确定重绘区域
panelRect.TopLeft := Canvas.PenPos;
panelRect.Bottom := PanelHeight ;
panelRect.Right := PanelWidth ;
Canvas.Font.Assign( Self.Font);
if ( beds > 0 ) and (used = 0 ) then
begin//当前房间是空房
Canvas.Brush.Color := $00FF00;//绿 底色
Canvas.Pen.Color := $FF00FF;
Canvas.Font.Color := $FF00FF;// 字体为反色
end
else if ( Beds > 0 ) and ( used < beds ) then
begin//当前房间没有住满的色
Canvas.Brush.Color := clYellow;// $FFFF00;//黄 底色
Canvas.Pen.Color := clYellow;
Canvas.Font.Color := not clYellow;// 字体为反色
end
else
begin//住满的房
Canvas.Brush.Color := Clred;// $FF0000;//红 底色
Canvas.Pen.Color := clred;//not $FF0000;
Canvas.Font.Color := $FFFF00;// 字体为反色
end;//dbctrlgrid.canvas
//画格
Canvas.Rectangle(panelRect);
//画房号号等信息
OffsetRect(panelRect , PanelWidth div 10 ,PanelHeight div 10);
Canvas.TextRect( panelRect ,panelRect.Left , panelrect.Top , '房号:'+roomsn );
OffsetRect(panelRect , 0, PanelHeight div 5 );
end;//dbctrlgrid
end;