Y
yue_shan
Unregistered / Unconfirmed
GUEST, unregistred user!
这个控件,你自已折腾吧
unit RoomPanel;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TRoomStatus = (rsEmpty, rsReserve, rsUsed, rsTransfer, rsCheckOut);
TRoomPanel = class(TCustomPanel)
private
{ Private declarations }
FRID: string;
// 房台号码
FRoomName: string;
// 房台名称
FCharge: Integer;
// 基本费用
FStatus: Integer;
// 房台状态
FStatusTime: TDateTime;
// 状态改变时间
FGuestName: string;
// 客人姓名
FIsMember: boolean;
// 是否会员
FPerson: Integer;
// 实际人数
FMaxPerson: Integer;
// 容纳人数
FGuestPicture: TPicture;
procedure SetRID(Value: string);
procedure SetRoomName(Value: string);
procedure SetStatus(Value: Integer);
procedure SetStatusTime(Value: TDateTime);
procedure SetGuestName(Value: string);
procedure SetGuestPicture(Value: TPicture);
procedure SetCharge(Value: Integer);
procedure SetIsMember(Value: boolean);
procedure SetPerson(Value: Integer);
procedure SetMaxPerson(Value: Integer);
protected
{ Protected declarations }
procedure Paint;
override;
public
{ Public declarations }
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
procedure Assign(Source: TPersistent);
override;
published
{ Published declarations }
property Color;
property Font;
property BevelInner;
property BevelOuter;
property BevelWidth;
property BorderStyle;
property BorderWidth;
property Hint;
property ShowHint;
property Visible;
property PopupMenu;
property OnClick;
property OnDblClick;
property GuestPicture: TPicture read FGuestPicture write SetGuestPicture;
property RID: string read FRID write SetRID;
property RoomName: string read FRoomName write SetRoomName;
property GuestName: string read FGuestName write SetGuestName;
property IsMember: boolean read FIsMember write SetIsMember;
property Person: Integer read FPerson write SetPerson;
property MaxPerson: Integer read FMaxPerson write SetMaxPerson;
property Charge: Integer read FCharge write SetCharge;
property Status: Integer read FStatus write SetStatus;
property StatusTime: TDateTime read FStatusTime write SetStatusTime;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TRoomPanel]);
end;
constructor TRoomPanel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FGuestPicture := TPicture.Create;
end;
destructor TRoomPanel.Destroy;
begin
FGuestPicture.Free;
inherited;
end;
procedure TRoomPanel.Assign(Source: TPersistent);
var
RoomSource: TRoomPanel;
begin
if Source is TRoomPanel then
begin
RoomSource := (Source as TRoomPanel);
Color := RoomSource.Color;
Font.Assign(RoomSource.Font);
BevelInner := RoomSource.BevelInner;
BevelOuter := RoomSource.BevelOuter;
BevelWidth := RoomSource.BevelWidth;
BorderStyle := RoomSource.BorderStyle;
BorderWidth := RoomSource.BorderWidth;
Hint := RoomSource.Hint;
ShowHint := RoomSource.ShowHint;
Visible := RoomSource.Visible;
PopupMenu := RoomSource.PopupMenu;
OnClick := RoomSource.OnClick;
OnDblClick := RoomSource.OnDblClick;
GuestPicture.Bitmap.Assign(RoomSource.GuestPicture.Bitmap);
RID := RoomSource.RID;
RoomName := RoomSource.RoomName;
GuestName := RoomSource.GuestName;
Status := RoomSource.Status;
StatusTime := RoomSource.StatusTime;
Width := RoomSource.Width;
Height := RoomSource.Height;
Charge := RoomSource.Charge;
IsMember := RoomSource.IsMember;
Person := RoomSource.Person;
MaxPerson := RoomSource.MaxPerson;
end else
inherited Assign(Source);
end;
procedure TRoomPanel.SetRID(Value: string);
begin
FRID := Value;
Invalidate;
end;
procedure TRoomPanel.SetRoomName(Value: string);
begin
FRoomName := Value;
Invalidate;
end;
procedure TRoomPanel.SetStatus(Value: Integer);
begin
FStatus := Value;
Invalidate;
end;
procedure TRoomPanel.SetStatusTime(Value: TDateTime);
begin
FStatusTime := Value;
Invalidate;
end;
procedure TRoomPanel.SetGuestName(Value: string);
begin
FGuestName := Value;
Invalidate;
end;
procedure TRoomPanel.SetGuestPicture(Value: TPicture);
begin
FGuestPicture.Assign(Value);
Invalidate;
end;
procedure TRoomPanel.SetCharge(Value: Integer);
begin
FCharge := Value;
Invalidate;
end;
procedure TRoomPanel.SetIsMember(Value: boolean);
begin
FIsMember := Value;
Invalidate;
end;
procedure TRoomPanel.SetMaxPerson(Value: Integer);
begin
FMaxPerson := Value;
Invalidate;
end;
procedure TRoomPanel.SetPerson(Value: Integer);
begin
FPerson := Value;
Invalidate;
end;
procedure TRoomPanel.Paint;
const
Indent = 4;
var
th, pw: Integer;
guest: string;
begin
inherited;
th := Canvas.TextHeight('hg字体');
pw := 32;
if Assigned(FGuestPicture.Bitmap) then
pw := FGuestPicture.Bitmap.Width + Indent * 2;
// Canvas.TextOut(pw, Indent + (th + 2) * 0, FRID);
Canvas.TextOut(pw, Indent + (th + 2) * 0, '[' + FRoomName + ']');
if Status > 0 then
begin
Canvas.TextOut(pw, Indent + (th + 2) * 1, FormatDateTime('hh:nn:ss', FStatusTime));
guest := FGuestName;
if FIsMember then
guest := '[会员]' + guest;
Canvas.TextOut( Indent, Indent + (th + 2) * 2, guest);
if Assigned(FGuestPicture.Bitmap) then
Canvas.Draw(Indent, Indent, FGuestPicture.Bitmap);
end;
if FCharge > 0 then
begin
Canvas.TextOut(Indent, Indent + (th + 2) * 3, Format('¥%d [%d/%d]', [FCharge, FPerson, FMaxPerson]));
end else
begin
Canvas.TextOut(Indent, Indent + (th + 2) * 3, Format('[%d/%d]', [FPerson, FMaxPerson]));
end;
end;
end.
unit RoomPanel;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TRoomStatus = (rsEmpty, rsReserve, rsUsed, rsTransfer, rsCheckOut);
TRoomPanel = class(TCustomPanel)
private
{ Private declarations }
FRID: string;
// 房台号码
FRoomName: string;
// 房台名称
FCharge: Integer;
// 基本费用
FStatus: Integer;
// 房台状态
FStatusTime: TDateTime;
// 状态改变时间
FGuestName: string;
// 客人姓名
FIsMember: boolean;
// 是否会员
FPerson: Integer;
// 实际人数
FMaxPerson: Integer;
// 容纳人数
FGuestPicture: TPicture;
procedure SetRID(Value: string);
procedure SetRoomName(Value: string);
procedure SetStatus(Value: Integer);
procedure SetStatusTime(Value: TDateTime);
procedure SetGuestName(Value: string);
procedure SetGuestPicture(Value: TPicture);
procedure SetCharge(Value: Integer);
procedure SetIsMember(Value: boolean);
procedure SetPerson(Value: Integer);
procedure SetMaxPerson(Value: Integer);
protected
{ Protected declarations }
procedure Paint;
override;
public
{ Public declarations }
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
procedure Assign(Source: TPersistent);
override;
published
{ Published declarations }
property Color;
property Font;
property BevelInner;
property BevelOuter;
property BevelWidth;
property BorderStyle;
property BorderWidth;
property Hint;
property ShowHint;
property Visible;
property PopupMenu;
property OnClick;
property OnDblClick;
property GuestPicture: TPicture read FGuestPicture write SetGuestPicture;
property RID: string read FRID write SetRID;
property RoomName: string read FRoomName write SetRoomName;
property GuestName: string read FGuestName write SetGuestName;
property IsMember: boolean read FIsMember write SetIsMember;
property Person: Integer read FPerson write SetPerson;
property MaxPerson: Integer read FMaxPerson write SetMaxPerson;
property Charge: Integer read FCharge write SetCharge;
property Status: Integer read FStatus write SetStatus;
property StatusTime: TDateTime read FStatusTime write SetStatusTime;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TRoomPanel]);
end;
constructor TRoomPanel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FGuestPicture := TPicture.Create;
end;
destructor TRoomPanel.Destroy;
begin
FGuestPicture.Free;
inherited;
end;
procedure TRoomPanel.Assign(Source: TPersistent);
var
RoomSource: TRoomPanel;
begin
if Source is TRoomPanel then
begin
RoomSource := (Source as TRoomPanel);
Color := RoomSource.Color;
Font.Assign(RoomSource.Font);
BevelInner := RoomSource.BevelInner;
BevelOuter := RoomSource.BevelOuter;
BevelWidth := RoomSource.BevelWidth;
BorderStyle := RoomSource.BorderStyle;
BorderWidth := RoomSource.BorderWidth;
Hint := RoomSource.Hint;
ShowHint := RoomSource.ShowHint;
Visible := RoomSource.Visible;
PopupMenu := RoomSource.PopupMenu;
OnClick := RoomSource.OnClick;
OnDblClick := RoomSource.OnDblClick;
GuestPicture.Bitmap.Assign(RoomSource.GuestPicture.Bitmap);
RID := RoomSource.RID;
RoomName := RoomSource.RoomName;
GuestName := RoomSource.GuestName;
Status := RoomSource.Status;
StatusTime := RoomSource.StatusTime;
Width := RoomSource.Width;
Height := RoomSource.Height;
Charge := RoomSource.Charge;
IsMember := RoomSource.IsMember;
Person := RoomSource.Person;
MaxPerson := RoomSource.MaxPerson;
end else
inherited Assign(Source);
end;
procedure TRoomPanel.SetRID(Value: string);
begin
FRID := Value;
Invalidate;
end;
procedure TRoomPanel.SetRoomName(Value: string);
begin
FRoomName := Value;
Invalidate;
end;
procedure TRoomPanel.SetStatus(Value: Integer);
begin
FStatus := Value;
Invalidate;
end;
procedure TRoomPanel.SetStatusTime(Value: TDateTime);
begin
FStatusTime := Value;
Invalidate;
end;
procedure TRoomPanel.SetGuestName(Value: string);
begin
FGuestName := Value;
Invalidate;
end;
procedure TRoomPanel.SetGuestPicture(Value: TPicture);
begin
FGuestPicture.Assign(Value);
Invalidate;
end;
procedure TRoomPanel.SetCharge(Value: Integer);
begin
FCharge := Value;
Invalidate;
end;
procedure TRoomPanel.SetIsMember(Value: boolean);
begin
FIsMember := Value;
Invalidate;
end;
procedure TRoomPanel.SetMaxPerson(Value: Integer);
begin
FMaxPerson := Value;
Invalidate;
end;
procedure TRoomPanel.SetPerson(Value: Integer);
begin
FPerson := Value;
Invalidate;
end;
procedure TRoomPanel.Paint;
const
Indent = 4;
var
th, pw: Integer;
guest: string;
begin
inherited;
th := Canvas.TextHeight('hg字体');
pw := 32;
if Assigned(FGuestPicture.Bitmap) then
pw := FGuestPicture.Bitmap.Width + Indent * 2;
// Canvas.TextOut(pw, Indent + (th + 2) * 0, FRID);
Canvas.TextOut(pw, Indent + (th + 2) * 0, '[' + FRoomName + ']');
if Status > 0 then
begin
Canvas.TextOut(pw, Indent + (th + 2) * 1, FormatDateTime('hh:nn:ss', FStatusTime));
guest := FGuestName;
if FIsMember then
guest := '[会员]' + guest;
Canvas.TextOut( Indent, Indent + (th + 2) * 2, guest);
if Assigned(FGuestPicture.Bitmap) then
Canvas.Draw(Indent, Indent, FGuestPicture.Bitmap);
end;
if FCharge > 0 then
begin
Canvas.TextOut(Indent, Indent + (th + 2) * 3, Format('¥%d [%d/%d]', [FCharge, FPerson, FMaxPerson]));
end else
begin
Canvas.TextOut(Indent, Indent + (th + 2) * 3, Format('[%d/%d]', [FPerson, FMaxPerson]));
end;
end;
end.