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

📄 hycxgl.pas

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

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, DB, ADODB, StdCtrls, Buttons, ExtCtrls, Mask,
  DBCtrls, Excel2000, OleServer, DBTables, ComCtrls;

type
  ThyglForm = class(TForm)
    Panel4: TPanel;
    BitBtn4: TBitBtn;
    Panel1: TPanel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn7: TBitBtn;
    BitBtn8: TBitBtn;
    ExcelApplication1: TExcelApplication;
    ExcelWorksheet1: TExcelWorksheet;
    ExcelWorkbook1: TExcelWorkbook;
    DBGrid1: TDBGrid;
    ADOQuery1: TADOQuery;
    DataSource1: TDataSource;
    ADOQuery2: TADOQuery;
    ADOQuery3: TADOQuery;
    DataSource2: TDataSource;
    DataSource3: TDataSource;
    ADOQuery4: TADOQuery;
    ADOQuery1kh: TWideStringField;
    ADOQuery1zt: TStringField;
    ADOQuery1czyxm: TStringField;
    ADOQuery1yhlb: TStringField;
    ADOQuery1zwxm: TStringField;
    ADOQuery1ywxm: TStringField;
    ADOQuery1sfzhm: TStringField;
    ADOQuery1jrrq: TDateTimeField;
    ADOQuery1yxq: TDateTimeField;
    ADOQuery1hth: TStringField;
    ADOQuery1xfjf: TIntegerField;
    ADOQuery1ye: TIntegerField;
    ADOQuery1zjxfe: TIntegerField;
    ADOQuery1zjcs: TIntegerField;
    ADOQuery1dj: TIntegerField;
    ADOQuery1dh: TStringField;
    ADOQuery1sr: TDateTimeField;
    ADOQuery1ah: TStringField;
    ADOQuery1yb: TStringField;
    ADOQuery1gsmc: TStringField;
    ADOQuery1zw: TStringField;
    ADOQuery1gsdz: TStringField;
    ADOQuery1bz: TStringField;
    ADOQuery1dzyjdz: TStringField;
    CheckBox1: TCheckBox;
    Shape1: TShape;
    procedure FormActivate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BitBtn4Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure BitBtn8Click(Sender: TObject);
    procedure BitBtn7Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    btn:string;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  hyglForm: ThyglForm;
  func:string;
implementation

uses Searchhy, sendmail, xfprnt;
{$R *.dfm}

procedure ThyglForm.FormActivate(Sender: TObject);
begin
     if btn<>'' then exit;
     btn:='xx';
     panel1.Enabled:=true;
     dbgrid1.Enabled:=true;
     adoquery3.Open;
     adoquery2.Open;
     adoquery1.Open;
end;

procedure ThyglForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
     btn:='';
     func:='';
     adoquery2.Close;
     adoquery3.Close;
     adoquery1.Close;
end;

procedure ThyglForm.BitBtn4Click(Sender: TObject);
begin
     close;
end;
procedure ThyglForm.FormCreate(Sender: TObject);
begin
     func:='';
     btn:='';
end;

procedure ThyglForm.FormKeyPress(Sender: TObject; var Key: Char);
begin
    if key=chr(13) then perform($28,0,0);
end;

procedure ThyglForm.BitBtn8Click(Sender: TObject);
var
 i,row,column:integer;
begin
 Try
  ExcelApplication1.Connect;
 Except
  MessageDlg('Excel 没有安装,无法报表!!',
  mtError, [mbOk], 0);
  Abort;
 End;
 ExcelApplication1.Visible[0]:=True;
 ExcelApplication1.Caption:='Excel 报表';
 ExcelApplication1.Workbooks.Add(Null,0);
 ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
 ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _Worksheet);
 column:=1;
 for i:=0 to  dbgrid1.Columns.Count -1 do
   begin
    ExcelWorksheet1.Cells.Item[1,column]:=dbgrid1.Columns[i].Title.Caption;
    column:=column+1;
   end;
 row:=2;
 adoquery1.First;
 While Not(adoquery1.Eof) do
 begin
   column:=1;
   for i:=1 to adoquery1.FieldCount do
   begin
    ExcelWorksheet1.Cells.Item[row,column]:=adoquery1.fields[i-1].AsString;
    column:=column+1;
   end;
   adoquery1.Next;
   row:=row+1;
 end;
 ExcelApplication1.Visible[0]:=true;
 ExcelApplication1.ActiveWorkbook.Save(0);
 ExcelApplication1.Save('会员编码表.xls');
 ExcelApplication1.Workbooks.Close(1);
 ExcelApplication1.Visible[0]:=false;
 ExcelApplication1.Quit;
end;

procedure ThyglForm.BitBtn7Click(Sender: TObject);
var aaa:string;
begin
     searchform:=Tsearchform.Create(self);
     if searchform.ShowModal=mrok then
     begin
        adoquery1.Close;
        adoquery1.SQL.Clear;
        aaa:=' where ';
        adoquery1.SQL.Add('select * from hykwj ');
//
        if (searchform.cb1.Text<>'') and (searchform.edit1.Text<>'') then begin
          adoquery1.SQL.Add( aaa+ '( kh'+searchform.cb1.Text+searchform.edit1.Text+')');;
          aaa:=' and ';
        end;
        if (searchform.lj1.Text<>'') and (searchform.ccb1.Text<>'') and (searchform.edit2.Text<>'') then begin
          adoquery1.SQL.Add(searchform.lj1.Text+ ' (kh'+searchform.ccb1.Text+searchform.edit2.Text+')');
        end;
        if (searchform.cb2.Text<>'') and (searchform.lj2.Text<>'') then begin
          adoquery1.SQL.Add(aaa+'( zt'+searchform.cb2.Text+searchform.lj2.Text+')');
          aaa:=' and ';
        end;
        if (searchform.edit5.Text<>'') then begin
          adoquery1.SQL.Add(aaa+'( czyxm like '+''''+searchform.edit5.Text+'%'+''''+')');
          aaa:=' and ';
        end;
        if (searchform.cb4.Text<>'') and (searchform.edit7.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( yhlb'+searchform.cb4.Text+searchform.edit7.Text+')');
          aaa:=' and ';
        end;
        if (searchform.lj4.Text<>'') and (searchform.ccb4.Text<>'') and (searchform.edit8.Text<>'') then begin
          adoquery1.SQL.Add(searchform.lj4.Text+ ' (yhlb'+searchform.ccb4.Text+searchform.edit8.Text+')');
        end;
        if (searchform.edit9.Text<>'') then begin
         adoquery1.SQL.Add(aaa+ '( zwxm like '+''''+searchform.edit9.Text+'%'+''''+')');
         aaa:=' and ';
        end;
        if (searchform.edit11.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( ywxm like '+''''+searchform.edit11.Text+'%'+''''+')');
          aaa:=' and ';
        end;
        if (searchform.edit13.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( sfzh like '+''''+searchform.edit13.Text+'%'+''''+')');
          aaa:=' and ';
        end;
        if (searchform.cb8.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( jrrq '+searchform.cb8.Text+':cs0)');
          adoquery1.Parameters.ParamByName('cs0').Value:=searchform.datetimepicker1.DateTime;
          aaa:=' and ';
        end;
        if (searchform.lj8.Text<>'') and (searchform.ccb8.Text<>'') then begin
          adoquery1.SQL.Add(searchform.lj8.Text+ ' (jrrq '+searchform.ccb8.Text+':cs1)');
          adoquery1.Parameters.ParamByName('cs1').Value:=searchform.datetimepicker2.DateTime;
        end;
        if (searchform.cb9.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( yxq '+searchform.cb9.Text+':cs2)');
          adoquery1.Parameters.ParamByName('cs2').Value:=searchform.datetimepicker3.DateTime;
          aaa:=' and ';
        end;
        if (searchform.lj9.Text<>'') and (searchform.ccb9.Text<>'') then begin
          adoquery1.SQL.Add(searchform.lj9.Text+ ' (yxq '+searchform.ccb9.Text+':cs3)');
          adoquery1.Parameters.ParamByName('cs3').Value:=searchform.datetimepicker4.DateTime;
        end;
        if (searchform.cb10.Text<>'') and (searchform.edit19.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( hth'+searchform.cb10.Text+searchform.edit19.Text+')');
          aaa:=' and ';
        end;
        if (searchform.lj10.Text<>'') and (searchform.ccb10.Text<>'') and (searchform.edit20.Text<>'') then begin
          adoquery1.SQL.Add(searchform.lj10.Text+ ' (hth'+searchform.ccb10.Text+searchform.edit20.Text+')');
        end;
        if (searchform.cb11.Text<>'') and (searchform.edit21.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( xfjf'+searchform.cb11.Text+searchform.edit21.Text+')');
          aaa:=' and ';
        end;
        if (searchform.lj11.Text<>'') and (searchform.ccb11.Text<>'') and (searchform.edit22.Text<>'') then begin
          adoquery1.SQL.Add(searchform.lj11.Text+ ' (xfjf'+searchform.ccb11.Text+searchform.edit22.Text+')');
        end;
        if (searchform.cb12.Text<>'') and (searchform.edit23.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( ye'+searchform.cb12.Text+searchform.edit23.Text+')');
          aaa:=' and ';
        end;
        if (searchform.lj12.Text<>'') and (searchform.ccb12.Text<>'') and (searchform.edit24.Text<>'') then begin
          adoquery1.SQL.Add(searchform.lj12.Text+ ' (ye'+searchform.ccb12.Text+searchform.edit24.Text+')');
        end;
        if (searchform.cb13.Text<>'') and (searchform.edit25.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( zjxf'+searchform.cb13.Text+searchform.edit25.Text+')');
          aaa:=' and ';
        end;
        if (searchform.lj13.Text<>'') and (searchform.ccb13.Text<>'') and (searchform.edit26.Text<>'') then begin
          adoquery1.SQL.Add(searchform.lj13.Text+ ' (zjxf'+searchform.ccb13.Text+searchform.edit26.Text+')');
        end;
        if (searchform.cb14.Text<>'') and (searchform.edit27.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( zjcs'+searchform.cb14.Text+searchform.edit27.Text+')');
          aaa:=' and ';
        end;
        if (searchform.lj14.Text<>'') and (searchform.ccb14.Text<>'') and (searchform.edit28.Text<>'') then begin
          adoquery1.SQL.Add(searchform.lj14.Text+ ' (zjcs'+searchform.ccb14.Text+searchform.edit28.Text+')');
        end;
        if (searchform.cb15.Text<>'') and (searchform.edit29.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( dj'+searchform.cb15.Text+searchform.edit29.Text+')');
          aaa:=' and ';
        end;
        if (searchform.lj15.Text<>'') and (searchform.ccb15.Text<>'') and (searchform.edit30.Text<>'') then begin
          adoquery1.SQL.Add(searchform.lj15.Text+ ' (dj'+searchform.ccb15.Text+searchform.edit30.Text+')');
        end;
        if (searchform.edit31.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( dh like '+''''+searchform.edit31.Text+'%'+''''+')');
          aaa:=' and ';
        end;
        if (searchform.cb17.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( sr '+searchform.cb17.Text+':cs4)');
          adoquery1.Parameters.ParamByName('cs4').Value:=searchform.datetimepicker5.DateTime;
          aaa:=' and ';
        end;
        if (searchform.lj17.Text<>'') and (searchform.ccb17.Text<>'') then begin
          adoquery1.SQL.Add(searchform.lj17.Text+ ' sr '+searchform.ccb17.Text+':cs5)');
          adoquery1.Parameters.ParamByName('cs5').Value:=searchform.datetimepicker6.DateTime;
        end;
        if (searchform.edit35.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( grah like '+''''+searchform.edit35.Text+'%'+''''+')');
          aaa:=' and ';
        end;
        if (searchform.edit37.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( yzbm like '+''''+searchform.edit37.Text+'%'+''''+')');
          aaa:=' and ';
        end;
        if (searchform.edit39.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( gsmc like '+''''+searchform.edit39.Text+'%'+''''+')');
          aaa:=' and ';
        end;
        if (searchform.edit41.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( zw like '+''''+searchform.edit41.Text+'%'+''''+')');
          aaa:=' and ';
        end;
        if (searchform.edit43.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( gsdz like '+''''+searchform.edit43.Text+'%'+''''+')');
        end;
        if (searchform.edit45.Text<>'') then begin
          adoquery1.SQL.Add(aaa+ '( dzyjdz like '+''''+searchform.edit45.Text+'%'+''''+')');
        end;
        adoquery1.Open;
     end;
     searchform.Free;
end;

procedure ThyglForm.BitBtn2Click(Sender: TObject);
begin
     mailform:=Tmailform.Create(self);
     mailform.Edtreceiver.Text:=adoquery1dzyjdz.AsString;
     mailform.ShowModal;
     mailform.Free;
end;

procedure ThyglForm.BitBtn1Click(Sender: TObject);
begin
     xfform:=Txfform.Create(self);
     xfform.yb.Text:=adoquery1yb.AsString;
     xfform.gsdz.Text:=adoquery1gsdz.AsString;
     xfform.gsmc.text:=adoquery1gsmc.AsString;
     xfform.zw.Text:=adoquery1zw.AsString;
     xfform.zwxm.Text:=adoquery1zwxm.AsString;
     xfform.ShowModal;
     xfform.Free;
end;

end.

⌨️ 快捷键说明

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