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

📄 car_report.~pas

📁 软件类别: 数据库 软件大小: 2.60M 运行环境: Win9xNT/2000/XP 一套车辆管理系统,此版本为商业版,大家一定用的着。
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
unit Car_Report;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, DBCtrls, StdCtrls, Mask, Buttons, ToolWin,
  ComCtrls, ExtCtrls, XPMenu;

type
  Tfrm_Car_Report = class(TForm)
    Panel5: TPanel;
    Label10: TLabel;
    Label11: TLabel;
    Label18: TLabel;
    Label20: TLabel;
    Label19: TLabel;
    Label21: TLabel;
    Label28: TLabel;
    Label29: TLabel;
    Label24: TLabel;
    Label25: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    Label32: TLabel;
    Label31: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    DBEdit3: TDBEdit;
    DBEdit5: TDBEdit;
    DBEdit6: TDBEdit;
    DBEdit7: TDBEdit;
    DBEdit9: TDBEdit;
    DBEdit10: TDBEdit;
    DBEdit11: TDBEdit;
    DBEdit12: TDBEdit;
    DBEdit13: TDBEdit;
    DBEdit14: TDBEdit;
    DBEdit16: TDBEdit;
    DBEdit17: TDBEdit;
    DBEdit18: TDBEdit;
    DBEdit20: TDBEdit;
    ToolBar1: TToolBar;
    Cmd_Search: TSpeedButton;
    Cmd_Preview: TSpeedButton;
    Cmd_Print: TSpeedButton;
    Cmd_Exit: TSpeedButton;
    Cmd_Cancel: TSpeedButton;
    GroupBox1: TGroupBox;
    ComboBox1: TComboBox;
    ComboBox3: TComboBox;
    ComboBox5: TComboBox;
    ComboBox7: TComboBox;
    Label3: TLabel;
    Label4: TLabel;
    CheckBox1: TCheckBox;
    CheckBox3: TCheckBox;
    CheckBox5: TCheckBox;
    CheckBox7: TCheckBox;
    CheckBox9: TCheckBox;
    CheckBox10: TCheckBox;
    CheckBox11: TCheckBox;
    CheckBox12: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox4: TCheckBox;
    CheckBox6: TCheckBox;
    CheckBox8: TCheckBox;
    ComboBox2: TComboBox;
    ComboBox4: TComboBox;
    ComboBox6: TComboBox;
    ComboBox8: TComboBox;
    ComboBox10: TComboBox;
    DBGrid1: TDBGrid;
    ComboBox9: TComboBox;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    DateTimePicker1: TDateTimePicker;
    DateTimePicker2: TDateTimePicker;
    DateTimePicker3: TDateTimePicker;
    DateTimePicker4: TDateTimePicker;
    XPMenu1: TXPMenu;
    procedure Cmd_SearchClick(Sender: TObject);
    procedure Cmd_PreviewClick(Sender: TObject);
    procedure Cmd_PrintClick(Sender: TObject);
    procedure Cmd_ExitClick(Sender: TObject);
    procedure Cmd_CancelClick(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure CheckBox3Click(Sender: TObject);
    procedure CheckBox4Click(Sender: TObject);
    procedure CheckBox5Click(Sender: TObject);
    procedure CheckBox6Click(Sender: TObject);
    procedure CheckBox7Click(Sender: TObject);
    procedure CheckBox8Click(Sender: TObject);
    procedure CheckBox9Click(Sender: TObject);
    procedure CheckBox10Click(Sender: TObject);
    procedure CheckBox11Click(Sender: TObject);
    procedure CheckBox12Click(Sender: TObject);
    procedure DateTimePicker1Change(Sender: TObject);
    procedure DateTimePicker2Change(Sender: TObject);
    procedure DateTimePicker3Change(Sender: TObject);
    procedure DateTimePicker4Change(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frm_Car_Report: Tfrm_Car_Report;
  tempsql:String;
implementation

uses Data, Preview, ReportInFormation, func;

{$R *.dfm}

procedure Tfrm_Car_Report.Cmd_SearchClick(Sender: TObject);
begin
    inherited;
    tempsql:='Select * from [Car] where ';
    if Trim(ComboBox1.Text)<>'' then
    begin
        tempSql:=tempSql+' C_NO Like '+''''+'%'+ Trim(ComboBox1.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox2.Text)<>'' then
    begin
        tempSql:=tempSql+' C_ID Like '+''''+'%'+ Trim(ComboBox2.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox3.Text)<>'' then
    begin
        tempSql:=tempSql+' Drive_ID Like '+''''+'%'+ Trim(ComboBox3.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox4.Text)<>'' then
    begin
        tempSql:=tempSql+' C_Telphon Like '+''''+'%'+ Trim(ComboBox4.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox5.Text)<>'' then
    begin
        tempSql:=tempSql+' Man Like '+''''+'%'+ Trim(ComboBox5.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox6.Text)<>'' then
    begin
        tempSql:=tempSql+' Type Like '+''''+'%'+ Trim(ComboBox6.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox7.Text)<>'' then
    begin
        tempSql:=tempSql+' Fdjh Like '+''''+'%'+ Trim(ComboBox7.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox8.Text)<>'' then
    begin
        tempSql:=tempSql+' Cjh Like '+''''+'%'+ Trim(ComboBox8.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox9.Text)<>'' then
    begin
        tempSql:=tempSql+' D_Date = '+''''+ Trim(ComboBox9.Text)+''''+' and ';
    end;
    if Trim(ComboBox10.Text)<>'' then
    begin
        tempSql:=tempSql+' F_Date = '+''''+ Trim(ComboBox10.Text)+''''+' and ';
    end;
    if CheckBox11.Checked=True then
    begin
        if Trim(Edit1.Text)<>'' then
        begin
            tempSql:=tempSql+' D_Date between '''+Trim(Edit1.Text)+''' and '''+Trim(Edit2.Text)+''''+' and ';
        end
        else
        begin
            Application.MessageBox('操作错误,已经选择了按时间段查询,开始时间不能为空',''mb_ok);
            Edit1.SetFocus;
            Exit;
        end;
    end;
    if CheckBox12.Checked=True then
    begin
        if Trim(Edit3.Text)<>'' then
        begin
            tempSql:=tempSql+' F_Date between '''+Trim(Edit3.Text)+''' and '''+Trim(Edit4.Text)+''''+' and ';
        end
        else
        begin
            Application.MessageBox('操作错误,已经选择了按时间段查询,开始时间不能为空',''mb_ok);
            Edit3.SetFocus;
            Exit;
        end;
    end;
    tempSql:=Copy(tempSql,0,length(tempSql)-4);
    with frm_data.ADOQuery_Car do
    begin
        Close;
        Sql.Clear;
        Sql.Add(tempSql);
        Prepared;
        Open;
        if frm_data.ADOQuery_Car.RecordCount<>0 then
        begin
            Cmd_Preview.Enabled:=True;
            Cmd_Print.Enabled:=True;
            Showmessage('符合条件的记录有:'+IntToStr(frm_data.ADOQuery_Car.RecordCount)+'条');
        end
        else
        begin
            Cmd_Preview.Enabled:=False;
            Cmd_Print.Enabled:=False;
            Showmessage('符合条件的记录有:'+IntToStr(frm_data.ADOQuery_Car.RecordCount)+'条');
        end;
    end;
end;

procedure Tfrm_Car_Report.Cmd_PreviewClick(Sender: TObject);
begin
    inherited;
    tempsql:='Select * from [Car] where ';
    if Trim(ComboBox1.Text)<>'' then
    begin
        tempSql:=tempSql+' C_NO Like '+''''+'%'+ Trim(ComboBox1.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox2.Text)<>'' then
    begin
        tempSql:=tempSql+' C_ID Like '+''''+'%'+ Trim(ComboBox2.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox3.Text)<>'' then
    begin
        tempSql:=tempSql+' Drive_ID Like '+''''+'%'+ Trim(ComboBox3.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox4.Text)<>'' then
    begin
        tempSql:=tempSql+' C_Telphon Like '+''''+'%'+ Trim(ComboBox4.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox5.Text)<>'' then
    begin
        tempSql:=tempSql+' Man Like '+''''+'%'+ Trim(ComboBox5.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox6.Text)<>'' then
    begin
        tempSql:=tempSql+' Type Like '+''''+'%'+ Trim(ComboBox6.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox7.Text)<>'' then
    begin
        tempSql:=tempSql+' Fdjh Like '+''''+'%'+ Trim(ComboBox7.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox8.Text)<>'' then
    begin
        tempSql:=tempSql+' Cjh Like '+''''+'%'+ Trim(ComboBox8.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox9.Text)<>'' then
    begin
        tempSql:=tempSql+' D_Date = '+''''+ Trim(ComboBox9.Text)+''''+' and ';
    end;
    if Trim(ComboBox10.Text)<>'' then
    begin
        tempSql:=tempSql+' F_Date = '+''''+ Trim(ComboBox10.Text)+''''+' and ';
    end;
    if CheckBox11.Checked=True then
    begin
        if Trim(Edit1.Text)<>'' then
        begin
            tempSql:=tempSql+' D_Date between '''+Trim(Edit1.Text)+''' and '''+Trim(Edit2.Text)+''''+' and ';
        end
        else
        begin
            Application.MessageBox('操作错误,已经选择了按时间段查询,开始时间不能为空',''mb_ok);
            Edit1.SetFocus;
            Exit;
        end;
    end;
    if CheckBox12.Checked=True then
    begin
        if Trim(Edit3.Text)<>'' then
        begin
            tempSql:=tempSql+' F_Date between '''+Trim(Edit3.Text)+''' and '''+Trim(Edit4.Text)+''''+' and ';
        end
        else
        begin
            Application.MessageBox('操作错误,已经选择了按时间段查询,开始时间不能为空',''mb_ok);
            Edit3.SetFocus;
            Exit;
        end;
    end;
    tempSql:=Copy(tempSql,0,length(tempSql)-4);
    with frm_data.ADOQuery_Car do
    begin
        Close;
        Sql.Clear;
        Sql.Add(tempSql);
        Prepared;
        Open;
        frm_Preview:=Tfrm_Preview.Create(self);
        frm_ReportInFormation:=Tfrm_ReportInFormation.Create(self);
        frm_ReportInFormation.L_Car_HeaderTitle.Caption:=func.Use_mond+frm_ReportInFormation.L_Car_HeaderTitle.Caption;
        frm_ReportInFormation.lab_Car_Ren.Caption:=frm_ReportInFormation.lab_Car_Ren.Caption+func.Login_Name;
        frm_ReportInFormation.Lab_Car_Time.Caption:=frm_ReportInFormation.Lab_Car_Time.Caption+formatdatetime('yyyy''-''mm''-''dd',now);
        frm_ReportInFormation.QuickRep_Car.Prepare;
        frm_Preview.ShowModal(frm_ReportInFormation.QuickRep_Car,'设备维修信息报表');
    end;
end;

procedure Tfrm_Car_Report.Cmd_PrintClick(Sender: TObject);
begin
    inherited;
    tempsql:='Select * from [Car] where ';
    if Trim(ComboBox1.Text)<>'' then
    begin
        tempSql:=tempSql+' C_NO Like '+''''+'%'+ Trim(ComboBox1.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox2.Text)<>'' then
    begin
        tempSql:=tempSql+' C_ID Like '+''''+'%'+ Trim(ComboBox2.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox3.Text)<>'' then
    begin
        tempSql:=tempSql+' Drive_ID Like '+''''+'%'+ Trim(ComboBox3.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox4.Text)<>'' then
    begin
        tempSql:=tempSql+' C_Telphon Like '+''''+'%'+ Trim(ComboBox4.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox5.Text)<>'' then
    begin
        tempSql:=tempSql+' Man Like '+''''+'%'+ Trim(ComboBox5.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox6.Text)<>'' then
    begin
        tempSql:=tempSql+' Type Like '+''''+'%'+ Trim(ComboBox6.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox7.Text)<>'' then
    begin
        tempSql:=tempSql+' Fdjh Like '+''''+'%'+ Trim(ComboBox7.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox8.Text)<>'' then
    begin
        tempSql:=tempSql+' Cjh Like '+''''+'%'+ Trim(ComboBox8.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox9.Text)<>'' then
    begin
        tempSql:=tempSql+' D_Date = '+''''+ Trim(ComboBox9.Text)+''''+' and ';
    end;
    if Trim(ComboBox10.Text)<>'' then
    begin
        tempSql:=tempSql+' F_Date = '+''''+ Trim(ComboBox10.Text)+''''+' and ';
    end;
    if CheckBox11.Checked=True then
    begin
        if Trim(Edit1.Text)<>'' then
        begin
            tempSql:=tempSql+' D_Date between '''+Trim(Edit1.Text)+''' and '''+Trim(Edit2.Text)+''''+' and ';
        end
        else
        begin
            Application.MessageBox('操作错误,已经选择了按时间段查询,开始时间不能为空',''mb_ok);
            Edit1.SetFocus;
            Exit;
        end;
    end;
    if CheckBox12.Checked=True then
    begin
        if Trim(Edit3.Text)<>'' then
        begin
            tempSql:=tempSql+' F_Date between '''+Trim(Edit3.Text)+''' and '''+Trim(Edit4.Text)+''''+' and ';
        end
        else
        begin
            Application.MessageBox('操作错误,已经选择了按时间段查询,开始时间不能为空',''mb_ok);
            Edit3.SetFocus;
            Exit;
        end;

⌨️ 快捷键说明

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