⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mc_gd_infor.pas

📁 异洲酒店管理系统
💻 PAS
字号:
unit MC_GD_InFor;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids, DBGrids, StdCtrls, Db, DBTables, Buttons;

type
  TGD_inFor = class(TForm)
    GroupBox1: TGroupBox;
    DBGrid1: TDBGrid;
    GroupBox2: TGroupBox;
    StringGrid1: TStringGrid;
    Query1: TQuery;
    DataSource1: TDataSource;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    GroupBox3: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    GroupBox4: TGroupBox;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BitBtn3Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure StringGrid1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  GD_inFor: TGD_inFor;

implementation

uses MC_DCFY_LR;

{$R *.DFM}

procedure TGD_inFor.FormClose(Sender: TObject; var Action: TCloseAction);
begin
     GD_inFor.Release;
     GD_inFor:=Nil;
end;

procedure TGD_inFor.BitBtn3Click(Sender: TObject);
begin
     Close;
end;

procedure TGD_inFor.FormShow(Sender: TObject);
begin
     StringGrid1.Cells[1,0]:='挂单编号';
     StringGrid1.Cells[2,0]:='房间号';     
end;

procedure TGD_inFor.StringGrid1Click(Sender: TObject);
var a,b,c:integer;
begin
if Length(StringGrid1.Cells[1,StringGrid1.Row])<>0 then
   begin
   //--------------------------------------------------
        With Query1 do
             begin
                  //---------------------------------------
                  close;
                  SQL.Clear;
                  SQl.Add('Select 房台名称 From 房间台号信息表 Where 编号=:A');
                  ParamByname('A').AsString:=StringGrid1.Cells[2,StringGrid1.Row];
                  Open;
                  Label8.Caption:=FieldByName('房台名称').AsString;
                  //---------------------------------------
                  Close;
                  SQL.Clear;
                  SQL.Add('Select 服务员编号,服务员姓名,点单日期 From 挂单菜谱 Where 挂单编号=:A');
                  paramByName('A').asString:=StringGrid1.Cells[1,StringGrid1.Row];
                  Open;
                  Label2.Caption:=FieldByName('服务员编号').AsString;
                  Label4.Caption:=FieldByName('服务员姓名').AsString;
                  Label6.Caption:=FieldByName('点单日期').AsString;
                  //---------------------------------------
                  Close;
                  SQL.Clear;
                  SQL.Add('Select Sum(合计) From 挂单菜谱 Where 挂单编号=:A');
                  paramByName('A').asString:=StringGrid1.Cells[1,StringGrid1.Row];
                  Open;
                  label18.Caption:=Fields[0].AsString;
                  //---------------------------------------
                  Close;
                  SQL.Clear;
                  SQL.Add('Select Sum(合计) From 挂单菜谱 Where 挂单编号=:A and 状态=:B');
                  ParamByname('A').AsString:=StringGrid1.Cells[1,StringGrid1.Row];
                  ParamByName('B').AsString:='点单';
                  Open;
                  Label12.Caption:=Fields[0].AsString;
                  //---------------------------------------
                  Close;
                  SQL.Clear;
                  SQL.Add('Select Count(名称) From 挂单菜谱 Where 挂单编号=:A and 状态=:B');
                  ParamByname('A').AsString:=StringGrid1.Cells[1,StringGrid1.Row];
                  ParamByName('B').AsString:='点单';
                  Open;
                  Label10.Caption:=Fields[0].AsString;
                  //---------------------------------------
                  Close;
                  SQL.Clear;
                  SQL.Add('Select Count(名称) From 挂单菜谱 Where 挂单编号=:A and 状态=:B');
                  ParamByname('A').AsString:=StringGrid1.Cells[1,StringGrid1.Row];
                  ParamByName('B').AsString:='赠单';
                  Open;
                  Label14.Caption:=Fields[0].AsString;
                  //---------------------------------------
                  Close;
                  SQL.Clear;
                  SQL.Add('Select Sum(合计) From 挂单菜谱 Where 挂单编号=:A and 状态=:B');
                  ParamByname('A').AsString:=StringGrid1.Cells[1,StringGrid1.Row];
                  ParamByName('B').AsString:='赠单';
                  Open;
                  Label16.Caption:=Fields[0].AsString;
                  //---------------------------------------
                  Close;
                  SQL.Clear;
                  SQL.Add('Select * From 挂单菜谱 Where 挂单编号=:A');
                  ParamByName('A').AsString:=StringGrid1.Cells[1,StringGrid1.Row];
                  Open;
             end;
   //--------------------------------------------------
   end;
end;

procedure TGD_inFor.BitBtn2Click(Sender: TObject);
var a,b,c:integer;
begin
     if Length(StringGrid1.Cells[1,StringGrid1.Row])<>0 then
     if MessageDlg('确认删除(挂单编号)=['+StringGrid1.Cells[1,StringGrid1.Row]+']的挂单信息?'
        ,mtCustom,[mbYes,mbNo],0)=mrYes then
        begin
             //-----------------------------------------------------------------
             Query1.Close;
             Query1.SQL.Clear;
             Query1.SQL.Add('Delete 挂单菜谱 Where 挂单编号=:A');
             Query1.ParamByname('A').AsString:=StringGrid1.Cells[1,StringGrid1.Row];
             Query1.ExecSQL;
             //-----------------------------------------------------------------
             For a:=StringGrid1.Row to StringGrid1.RowCount-2 do
             begin
                  if Length(StringGrid1.Cells[1,a])<>0 then
                     begin
                          StringGrid1.Cells[1,a]:=StringGrid1.Cells[1,a+1];
                          StringGrid1.Cells[2,a]:=StringGrid1.Cells[2,a+1];                          
                     end
                  else Break;
             end;
             //-----------------------------------------------------------------
             StringGrid1.Row:=1;
                if Length(StringGrid1.Cells[1,StringGrid1.Row])<>0 then
                   begin
                   //--------------------------------------------------
                        With Query1 do
                             begin
                                  //---------------------------------------
                                  close;
                                  SQL.Clear;
                                  SQl.Add('Select 房台名称 From 房间台号信息表 Where 编号=:A');
                                  ParamByname('A').AsString:=StringGrid1.Cells[2,StringGrid1.Row];
                                  Open;
                                  Label8.Caption:=FieldByName('房台名称').AsString;
                                  //---------------------------------------
                                  Close;
                                  SQL.Clear;
                                  SQL.Add('Select 服务员编号,服务员姓名,点单日期 From 挂单菜谱 Where 挂单编号=:A');
                                  paramByName('A').asString:=StringGrid1.Cells[1,StringGrid1.Row];
                                  Open;
                                  Label2.Caption:=FieldByName('服务员编号').AsString;
                                  Label4.Caption:=FieldByName('服务员姓名').AsString;
                                  Label6.Caption:=FieldByName('点单日期').AsString;
                                  //---------------------------------------
                                  Close;
                                  SQL.Clear;
                                  SQL.Add('Select Sum(合计) From 挂单菜谱 Where 挂单编号=:A');
                                  paramByName('A').asString:=StringGrid1.Cells[1,StringGrid1.Row];
                                  Open;
                                  label18.Caption:=Fields[0].AsString;
                                  //---------------------------------------
                                  Close;
                                  SQL.Clear;
                                  SQL.Add('Select Sum(合计) From 挂单菜谱 Where 挂单编号=:A and 状态=:B');
                                  ParamByname('A').AsString:=StringGrid1.Cells[1,StringGrid1.Row];
                                  ParamByName('B').AsString:='点单';
                                  Open;
                                  Label12.Caption:=Fields[0].AsString;
                                  //---------------------------------------
                                  Close;
                                  SQL.Clear;
                                  SQL.Add('Select Count(名称) From 挂单菜谱 Where 挂单编号=:A and 状态=:B');
                                  ParamByname('A').AsString:=StringGrid1.Cells[1,StringGrid1.Row];
                                  ParamByName('B').AsString:='点单';
                                  Open;
                                  Label10.Caption:=Fields[0].AsString;
                                  //---------------------------------------
                                  Close;
                                  SQL.Clear;
                                  SQL.Add('Select Count(名称) From 挂单菜谱 Where 挂单编号=:A and 状态=:B');
                                  ParamByname('A').AsString:=StringGrid1.Cells[1,StringGrid1.Row];
                                  ParamByName('B').AsString:='赠单';
                                  Open;
                                  Label14.Caption:=Fields[0].AsString;
                                  //---------------------------------------
                                  Close;
                                  SQL.Clear;
                                  SQL.Add('Select Sum(合计) From 挂单菜谱 Where 挂单编号=:A and 状态=:B');
                                  ParamByname('A').AsString:=StringGrid1.Cells[1,StringGrid1.Row];
                                  ParamByName('B').AsString:='赠单';
                                  Open;
                                  Label16.Caption:=Fields[0].AsString;
                                  //---------------------------------------
                                  Close;
                                  SQL.Clear;
                                  SQL.Add('Select * From 挂单菜谱 Where 挂单编号=:A');
                                  ParamByName('A').AsString:=StringGrid1.Cells[1,StringGrid1.Row];
                                  Open;
                             end;
                   //--------------------------------------------------
                   end;
             //-----------------------------------------------------------------
        end;
end;

procedure TGD_inFor.BitBtn1Click(Sender: TObject);
var a,b,c: integer;
    d: Real;
begin
     if Length(StringGrid1.Cells[1,StringGrid1.Row])<>0 then
     if MessageDlg('确认调入(挂单编号)=['+StringGrid1.Cells[1,StringGrid1.Row]+']的挂单信息?'
        ,mtCustom,[mbYes,mbNo],0)=mrYes then
        begin
             //-----------------------------------------------------------------
             For a:=1 to 50 do
             begin
                  if Length(DCFY_LR.DCGrid.Cells[1,a])=0 then
                     begin
                          b:=a;
                          Break;
                     end;
             end;
             Query1.First;
             While not Query1.Eof do
             begin
                  DCFY_LR.DCGrid.Cells[1,a]:=Query1.FieldByName('编号').AsString;
                  DCFY_LR.DCGrid.Cells[2,a]:=Query1.FieldByName('名称').AsString;
                  DCFY_LR.DCGrid.Cells[3,a]:=Query1.FieldByName('类型').AsString;
                  DCFY_LR.DCGrid.Cells[4,a]:=Query1.FieldByName('单位').AsString;
                  DCFY_LR.DCGrid.Cells[5,a]:=Query1.FieldByName('数量').AsString;
                  DCFY_LR.DCGrid.Cells[6,a]:=Query1.FieldByName('价格').AsString;
                  DCFY_LR.DCGrid.Cells[7,a]:=Query1.FieldByName('状态').AsString;
                  DCFY_LR.DCGrid.Cells[8,a]:=Query1.FieldByName('合计').AsString;
                  if a=50 then
                     begin
                          ShowMessage('点菜已满!!');
                     end
                  else
                     begin
                          a:=a+1;
                          Query1.Next;
                     end;
             end;
             //-----------------------------------------------------------------
             D:=0;
             For a:=1 to 50 do
             begin
                  if Length(DCFY_LR.DCGrid.Cells[1,a])<>0 then
                     begin
                          d:=d+StrToFloat(DCFY_LR.DCGrid.Cells[8,a]);
                     end
                  else
                     begin
                          Break;
                     end;
             end;
             DCFY_LR.Label14.Caption:=FloatToStr(d);
             ShowMessage('调入完毕!');
             Close;
             //-----------------------------------------------------------------
        end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -