Delphi专题 ·

一个老外用Delphi VCL写的餐馆系统界面

一个老外用Delphi VCL写的餐馆系统界面 Delphi专题 第1张

原文出处

https://www.youtube.com/watch?v=n3DdhkiXV20

主要代码

procedure TfrmPrincipal.btn11Click(Sender: TObject);
begin
  FiltarStatus(TSpeedButton(Sender).Tag);  
end;

procedure TfrmPrincipal.btn3Click(Sender: TObject);
begin
  CarregarMesas;
end;

procedure TfrmPrincipal.CarregarMesas;
var
  i: Integer;
begin
  FDMemTable1.Close;
  FDMemTable1.CreateDataSet;
  FDMemTable1.Open;
  for i := 1 to 16 do
  begin
    FDMemTable1.Append;
    FDMemTable1DESCRICAO.AsString := '表 '+ FormatFloat('00', i);
    FDMemTable1STATUS.AsInteger := Random(4);
    FDMemTable1TOTAL.AsFloat := 1 * Random(9);
    FDMemTable1DATAHORA.AsDateTime := now;
    FDMemTable1.Post;
  end;
end;

procedure TfrmPrincipal.DBCtrlGrid1PaintPanel(DBCtrlGrid: TDBCtrlGrid; Index: Integer);
begin
  //lbl10.Caption := 'Iniciar';
  lbl6.Caption := FDMemTable1DESCRICAO.AsString;
  lbl11.Caption := FormatFloat('R$ ###,###,#0.00', FDMemTable1TOTAL.asfloat);
  lbl8.Caption := '开放时间:'+ FormatDateTime('hh', Now - FDMemTable1DATAHORA.AsDateTime) + '小时前';

  case(FDMemTable1STATUS.AsInteger)of
    0:
    begin
      shp8.Brush.Color := clGreen;
      shp5.Brush.Color := clGreen;
      lbl9.Caption := '空闲';
    end;
    1:
    begin
      shp8.Brush.Color := clRed;
      shp5.Brush.Color := clRed;
      lbl9.Caption := '繁忙';
      //lbl10.Caption := 'Resumo';
    end;
    2:
    begin
      shp8.Brush.Color := $000080FF;
      shp5.Brush.Color := $000080FF;
      lbl9.Caption := '保留';
    end;
    3:
    begin 
      shp8.Brush.Color := clGray;
      shp5.Brush.Color := clGray;
      lbl9.Caption := '完工';
    end;
  end;
end;

procedure TfrmPrincipal.FiltarStatus(ATag: Integer);
begin
  if(ATag >= 0)then
  begin  
    FDMemTable1.Filtered := False;
    FDMemTable1.Filter := 'STATUS = '+ATag.ToString;
    FDMemTable1.Filtered := True;
  end
  else
  begin  
    FDMemTable1.Filtered := False;
    FDMemTable1.Filter := '';
    FDMemTable1.Filtered := True;  
  end;    
end;

procedure TfrmPrincipal.FormCreate(Sender: TObject);
begin
  CarregarMesas;
end;

相关下载

点击下载

参与评论