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

📄 skycwbb.pas

📁 日昌餐饮管理系统是用Delphi7+SQL写的管理系统
💻 PAS
字号:
unit skycwbb;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ComCtrls, DBTables, DB, QRCtrls, QuickRpt,
  ExtCtrls, Grids, DBGrids;

type
  TskyForm = class(TForm)
    Label1: TLabel;
    ComboBox1: TComboBox;
    Label2: TLabel;
    DateTimePicker1: TDateTimePicker;
    DateTimePicker2: TDateTimePicker;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    DBGrid1: TDBGrid;
    DBGrid2: TDBGrid;
    Panel1: TPanel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    LabeledEdit1: TLabeledEdit;
    LabeledEdit2: TLabeledEdit;
    LabeledEdit3: TLabeledEdit;
    LabeledEdit4: TLabeledEdit;
    LabeledEdit5: TLabeledEdit;
    LabeledEdit6: TLabeledEdit;
    LabeledEdit7: TLabeledEdit;
    LabeledEdit8: TLabeledEdit;
    LabeledEdit9: TLabeledEdit;
    Panel3: TPanel;
    QuickRep1: TQuickRep;
    PageHeaderBand2: TQRBand;
    QRSysData3: TQRSysData;
    QRLabel10: TQRLabel;
    QRLabel11: TQRLabel;
    QRLabel1: TQRLabel;
    QRLabel2: TQRLabel;
    QRLabel3: TQRLabel;
    QRLabel4: TQRLabel;
    QRLabel5: TQRLabel;
    QRLabel6: TQRLabel;
    QRLabel7: TQRLabel;
    QRLabel8: TQRLabel;
    QRLabel9: TQRLabel;
    QRLabel12: TQRLabel;
    QRLabel13: TQRLabel;
    QRLabel14: TQRLabel;
    QRLabel15: TQRLabel;
    QRLabel16: TQRLabel;
    QRLabel19: TQRLabel;
    QRLabel20: TQRLabel;
    QRLabel21: TQRLabel;
    QRLabel22: TQRLabel;
    QRLabel23: TQRLabel;
    QRLabel24: TQRLabel;
    QRLabel25: TQRLabel;
    QRLabel26: TQRLabel;
    QRLabel27: TQRLabel;
    QRLabel28: TQRLabel;
    QRLabel29: TQRLabel;
    QRLabel30: TQRLabel;
    SummaryBand2: TQRBand;
    QRLabel17: TQRLabel;
    QRLabel34: TQRLabel;
    ColumnHeaderBand1: TQRBand;
    QRLabel31: TQRLabel;
    QRLabel32: TQRLabel;
    QRLabel33: TQRLabel;
    DetailBand1: TQRBand;
    QRDBText1: TQRDBText;
    QRDBText2: TQRDBText;
    QRDBText3: TQRDBText;
    DataSource1: TDataSource;
    Query1: TQuery;
    Query2: TQuery;
    UpdateSQL1: TUpdateSQL;
    DataSource2: TDataSource;
    Query3: TQuery;
    Label7: TLabel;
    Label8: TLabel;
    Query4: TQuery;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    xx:string; 
    { Private declarations }
  public
    { Public declarations }
  end;

var
  skyForm: TskyForm;

implementation
uses rjsmain;
{$R *.dfm}

procedure TskyForm.BitBtn1Click(Sender: TObject);
begin
     if combobox1.Text='' then
     begin
        showmessage('请选择收款员!');
        combobox1.SetFocus;
        exit;
     end;
     if combobox1.Text='全部' then
     begin
      query3.Close;
      query3.SQL.Clear;
      query3.SQL.Add('SELECT count(distinct djh) as djsl, sum(sl) as sle, sum(je) as jee, sum(zke) as zkee, sum(fwfe) fwfee, sum(se) as see FROM dcd dcd where rq>=:cs1 and rq<=:cs2 and fkbz=1 and zfbz=0 ');
      query3.ParamByName('cs1').AsDateTime:=datetimepicker1.DateTime;
      query3.ParamByName('cs2').AsDateTime:=datetimepicker2.DateTime;
      query3.Open;
      edit3.Text:=query3.FieldByName('jee').AsString;
      labelededit2.Text:=query3.FieldByName('fwfee').AsString;
      labelededit1.Text:=query3.FieldByName('see').AsString;
      labelededit3.Text:=query3.FieldByName('zkee').AsString;
      query3.Close;
      query3.SQL.Clear;
      query3.SQL.Add('SELECT count(distinct djh) as djsl, sum(sl) as sle, sum(je) as jee, sum(zke) as zkee, sum(fwfe) fwfee, sum(se) as see FROM dcd dcd where rq>=:cs1 and rq<=:cs2 ');
      query3.ParamByName('cs1').AsDateTime:=datetimepicker1.DateTime;
      query3.ParamByName('cs2').AsDateTime:=datetimepicker2.DateTime;
      query3.Open;
      edit2.Text:=query3.FieldByName('jee').AsString;
      edit1.Text:=query3.FieldByName('djsl').AsString;
      query3.Close;
      query3.SQL.Clear;
      query3.SQL.Add('SELECT count(distinct djh) as djsl, sum(sl) as sle, sum(je) as jee, sum(zke) as zkee, sum(fwfe) fwfee, sum(se) as see FROM dcd dcd where rq>=:cs1 and rq<=:cs2 and zfbz=1 and fkbz=0');
      query3.ParamByName('cs1').AsDateTime:=datetimepicker1.DateTime;
      query3.ParamByName('cs2').AsDateTime:=datetimepicker2.DateTime;
      query3.Open;
      labelededit4.Text:=query3.FieldByName('djsl').AsString;
      labelededit5.Text:=query3.FieldByName('jee').AsString;
      query3.Close;
      query3.SQL.Clear;
      query3.SQL.Add('SELECT count(distinct djh) as djsl, sum(sl) as sle, sum(je) as jee, sum(zke) as zkee, sum(fwfe) fwfee, sum(se) as see FROM dcd dcd where rq>=:cs1 and rq<=:cs2 and zfbz=1 and fkbz=1');
      query3.ParamByName('cs1').AsDateTime:=datetimepicker1.DateTime;
      query3.ParamByName('cs2').AsDateTime:=datetimepicker2.DateTime;
      query3.Open;
      labelededit7.Text:=query3.FieldByName('djsl').AsString;
      labelededit8.Text:=query3.FieldByName('jee').AsString;
      query3.Close;
      if (edit1.Text<>'') and (edit1.Text<>'0') then labelededit6.Text:=floattostr(round(strtoint(labelededit4.Text)/strtoint(edit1.Text) *100));
      if (edit1.Text<>'') and (edit1.Text<>'0') then labelededit9.Text:=floattostr(round(strtoint(labelededit7.Text)/strtoint(edit1.Text) *100));
      query1.Close;
      query2.Close;
      query1.SQL.Clear;
      query1.SQL.Add(' SELECT count(distinct djh) as djsl, lb, mc, bh, sum(sl) as sle, sum(je) as jee, sum(zke) as zkee, sum(fwfe) fwfee, sum(se) as see FROM dcd dcd');
      query1.SQL.Add(' where rq>=:cs1 and rq<=:cs2 and fkbz=1 and zfbz=0 group by lb,bh,mc order by lb,bh');
      query1.ParamByName('cs1').AsDateTime:=datetimepicker1.DateTime;
      query1.ParamByName('cs2').AsDateTime:=datetimepicker2.DateTime;
      query1.Open;
      query2.SQL.Clear;
      query2.SQL.Add(' SELECT count(distinct djh) as bs, fkfsmc, sum(fkje) as jee FROM fkwj fkwj ');
      query2.SQL.Add(' where rq>=:cs1 and rq<=:cs2 group by fkfsmc ');
      query2.ParamByName('cs1').AsDateTime:=datetimepicker1.DateTime;
      query2.ParamByName('cs2').AsDateTime:=datetimepicker2.DateTime;
      query2.Open;
     end
    else
     begin
      query4.Locate('yhmc',combobox1.Text,[]);
      query3.Close;
      query3.SQL.Clear;
      query3.SQL.Add('SELECT count(distinct djh) as djsl, sum(sl) as sle, sum(je) as jee, sum(zke) as zkee, sum(fwfe) fwfee, sum(se) as see FROM dcd dcd where rq>=:cs1 and rq<=:cs2 and fkbz=1 and zfbz=0 and yhh=:cs3 ');
      query3.ParamByName('cs1').AsDateTime:=datetimepicker1.DateTime;
      query3.ParamByName('cs2').AsDateTime:=datetimepicker2.DateTime;
      query3.ParamByName('cs3').AsString:=query4.FieldByName('yhm').AsString;
      query3.Open;
      edit1.Text:=query3.FieldByName('djsl').AsString;
      edit3.Text:=query3.FieldByName('jee').AsString;
      labelededit2.Text:=query3.FieldByName('fwfee').AsString;
      labelededit1.Text:=query3.FieldByName('see').AsString;
      labelededit3.Text:=query3.FieldByName('zkee').AsString;
      query3.Close;
      query3.SQL.Clear;
      query3.SQL.Add('SELECT count(distinct djh) as djsl, sum(sl) as sle, sum(je) as jee, sum(zke) as zkee, sum(fwfe) fwfee, sum(se) as see FROM dcd dcd where rq>=:cs1 and rq<=:cs2 and yhh=:cs3');
      query3.ParamByName('cs1').AsDateTime:=datetimepicker1.DateTime;
      query3.ParamByName('cs2').AsDateTime:=datetimepicker2.DateTime;
      query3.ParamByName('cs3').AsString:=query4.FieldByName('yhm').AsString;
      query3.Open;
      edit2.Text:=query3.FieldByName('jee').AsString;
      query3.Close;
      query3.SQL.Clear;
      query3.SQL.Add('SELECT count(distinct djh) as djsl, sum(sl) as sle, sum(je) as jee, sum(zke) as zkee, sum(fwfe) fwfee, sum(se) as see FROM dcd dcd where rq>=:cs1 and rq<=:cs2 and zfbz=1 and fkbz=0 and yhh=:cs3');
      query3.ParamByName('cs1').AsDateTime:=datetimepicker1.DateTime;
      query3.ParamByName('cs2').AsDateTime:=datetimepicker2.DateTime;
      query3.ParamByName('cs3').AsString:=query4.FieldByName('yhm').AsString;
      query3.Open;
      labelededit4.Text:=query3.FieldByName('djsl').AsString;
      labelededit5.Text:=query3.FieldByName('jee').AsString;
      query3.Close;
      query3.SQL.Clear;
      query3.SQL.Add('SELECT count(distinct djh) as djsl, sum(sl) as sle, sum(je) as jee, sum(zke) as zkee, sum(fwfe) fwfee, sum(se) as see FROM dcd dcd where rq>=:cs1 and rq<=:cs2 and zfbz=1 and fkbz=1 and yhh=:cs3');
      query3.ParamByName('cs1').AsDateTime:=datetimepicker1.DateTime;
      query3.ParamByName('cs2').AsDateTime:=datetimepicker2.DateTime;
      query3.ParamByName('cs3').AsString:=query4.FieldByName('yhm').AsString;
      query3.Open;
      labelededit7.Text:=query3.FieldByName('djsl').AsString;
      labelededit8.Text:=query3.FieldByName('jee').AsString;
      query3.Close;
      if (labelededit4.Text<>'') and (labelededit4.Text<>'0') then labelededit6.Text:=floattostr(round(strtoint(labelededit4.Text)/(strtoint(edit1.Text)+strtoint(labelededit4.Text)) *100));
      if (labelededit7.Text<>'') and (labelededit7.Text<>'0') then labelededit9.Text:=floattostr(round(strtoint(labelededit7.Text)/(strtoint(edit1.Text)+strtoint(labelededit7.Text)) *100));
      query1.Close;
      query2.Close;
      query1.SQL.Clear;
      query1.SQL.Add(' SELECT count(distinct djh) as djsl, lb, mc, bh, sum(sl) as sle, sum(je) as jee, sum(zke) as zkee, sum(fwfe) fwfee, sum(se) as see FROM dcd dcd');
      query1.SQL.Add(' where rq>=:cs1 and rq<=:cs2 and fkbz=1 and zfbz=0 and yhh=:cs3 group by lb,bh,mc order by lb,bh');
      query1.ParamByName('cs1').AsDateTime:=datetimepicker1.DateTime;
      query1.ParamByName('cs2').AsDateTime:=datetimepicker2.DateTime;
      query1.ParamByName('cs3').AsString:=query4.FieldByName('yhm').AsString;
      query1.Open;
      query2.SQL.Clear;
      query2.SQL.Add(' SELECT count(distinct djh) as bs, fkfsmc, sum(fkje) as jee FROM fkwj ');
      query2.SQL.Add(' where rq>=:cs1 and rq<=:cs2 and yhh=:cs3 group by fkfsmc ');
      query2.ParamByName('cs1').AsDateTime:=datetimepicker1.DateTime;
      query2.ParamByName('cs2').AsDateTime:=datetimepicker2.DateTime;
      query2.ParamByName('cs3').AsString:=query4.FieldByName('yhm').AsString;
      query2.Open;
     end;
     bitbtn2.Enabled:=true;
end;

procedure TskyForm.BitBtn2Click(Sender: TObject);
begin
     qrlabel10.Caption:=rjsmain.dwmc;
     qrlabel1.Caption:=edit1.Text;
     if combobox1.Text<>'全部' then
       qrlabel4.Caption:=combobox1.Text
     else qrlabel4.Caption:='';
     qrlabel6.Caption:=edit2.Text;
     qrlabel8.Caption:=edit3.Text;
     qrlabel12.Caption:=labelededit2.Text;
     qrlabel14.Caption:=labelededit1.Text;
     qrlabel16.Caption:=labelededit3.Text;
     qrlabel20.Caption:=labelededit4.Text;
     qrlabel22.Caption:=labelededit5.Text;
     qrlabel24.Caption:=labelededit6.Text;
     qrlabel26.Caption:=labelededit7.Text;
     qrlabel30.Caption:=labelededit8.Text;
     qrlabel28.Caption:=labelededit9.Text;
     qrlabel34.Caption:=combobox1.Text;
     if query2.Active=false then BitBtn1Click(sender);
     quickrep1.Preview;
end;

procedure TskyForm.BitBtn3Click(Sender: TObject);
begin
     close;
end;

procedure TskyForm.FormActivate(Sender: TObject);
begin
     if xx='xx' then exit;
     xx:='xx';
     bitbtn2.Enabled:=false;
     query4.Open;
     combobox1.Clear;
     combobox1.Items.Add('全部');
     while not query4.Eof do
     begin
       combobox1.Items.Add(query4.FieldByName('yhmc').AsString);
       query4.Next;
     end;
     combobox1.Text:='';
     datetimepicker1.Date:=date;
     datetimepicker1.Time:=strtotime('00:00:00');
     datetimepicker2.Date:=date;
     datetimepicker2.Time:=strtotime('23:59:59');
     query3.Close;
     edit1.Text:='';
     edit3.Text:='';
     labelededit2.Text:='';
     labelededit1.Text:='';
     labelededit3.Text:='';
     edit2.Text:='';
     labelededit4.Text:='';
     labelededit5.Text:='';
     labelededit7.Text:='';
     labelededit8.Text:='';
     labelededit6.Text:='';
     labelededit9.Text:='';
end;

procedure TskyForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
     xx:='';
     query4.Close;
     query1.Close;
     query2.Close;
end;

end.

⌨️ 快捷键说明

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