done_report.pas

来自「软件类别: 数据库 软件大小: 2.60M 运行环境: Win9xNT/」· PAS 代码 · 共 572 行 · 第 1/2 页

PAS
572
字号
begin
    Edit1.Clear;
    Edit2.Clear;
    if CheckBox7.Checked=True then
    begin
        Edit1.Visible:=True;
        Edit2.Visible:=True;
        DateTimePicker1.Visible:=True;
        DateTimePicker2.Visible:=True;
        Label1.Visible:=True;
    end
    else
    begin
        Edit1.Visible:=False;
        Edit2.Visible:=False;
        DateTimePicker1.Visible:=False;
        DateTimePicker2.Visible:=False;
        Label1.Visible:=False;
    end;
end;

procedure Tfrm_Done_Report.CheckBox8Click(Sender: TObject);
begin
    Edit3.Clear;
    Edit4.Clear;
    if CheckBox8.Checked=True then
    begin
        Edit3.Visible:=True;
        Edit4.Visible:=True;
        DateTimePicker3.Visible:=True;
        DateTimePicker4.Visible:=True;
        Label2.Visible:=True;
    end
    else
    begin
        Edit3.Visible:=False;
        Edit4.Visible:=False;
        DateTimePicker3.Visible:=False;
        DateTimePicker4.Visible:=False;
        Label2.Visible:=False;
    end;
end;

procedure Tfrm_Done_Report.DateTimePicker1Change(Sender: TObject);
begin
    Edit1.Text:=ForMatDateTime('yyyy''-''mm''-''dd',DateTimePicker1.DateTime);
end;

procedure Tfrm_Done_Report.DateTimePicker2Change(Sender: TObject);
begin
    Edit2.Text:=ForMatDateTime('yyyy''-''mm''-''dd',DateTimePicker2.DateTime);
end;

procedure Tfrm_Done_Report.DateTimePicker3Change(Sender: TObject);
begin
    Edit3.Text:=ForMatDateTime('yyyy''-''mm''-''dd',DateTimePicker3.DateTime);
end;

procedure Tfrm_Done_Report.DateTimePicker4Change(Sender: TObject);
begin
    Edit4.Text:=ForMatDateTime('yyyy''-''mm''-''dd',DateTimePicker4.DateTime);
end;

procedure Tfrm_Done_Report.Cmd_SearchClick(Sender: TObject);
begin
    inherited;
    tempsql:='Select * from [Back_Role_View] where ';
    if Trim(ComboBox1.Text)<>'' then
    begin
        tempSql:=tempSql+' C_ID Like '+''''+'%'+ Trim(ComboBox1.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox2.Text)<>'' then
    begin
        tempSql:=tempSql+' Man Like '+''''+'%'+ Trim(ComboBox2.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox3.Text)<>'' then
    begin
        tempSql:=tempSql+' Drive_Man Like '+''''+'%'+ Trim(ComboBox3.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox4.Text)<>'' then
    begin
        tempSql:=tempSql+' Drive_ID Like '+''''+'%'+ Trim(ComboBox4.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox5.Text)<>'' then
    begin
        tempSql:=tempSql+' Back_Date = '+''''+ Trim(ComboBox5.Text)+''''+' and ';
    end;
    if Trim(ComboBox6.Text)<>'' then
    begin
        tempSql:=tempSql+' Done_Date = '+''''+ Trim(ComboBox6.Text)+''''+' and ';
    end;
    if CheckBox7.Checked=True then
    begin
        if Trim(Edit1.Text)<>'' then
        begin
            tempSql:=tempSql+' Back_Date between '''+Trim(Edit1.Text)+''' and '''+Trim(Edit2.Text)+''''+' and ';
        end
        else
        begin
            Application.MessageBox('操作错误,已经选择了按时间段查询,开始时间不能为空',''mb_ok);
            Edit1.SetFocus;
            Exit;
        end;
    end;
    if CheckBox8.Checked=True then
    begin
        if Trim(Edit3.Text)<>'' then
        begin
            tempSql:=tempSql+' Done_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.Query_Back_Role_View do
    begin
        Close;
        Sql.Clear;
        Sql.Add(tempSql);
        Prepared;
        Open;
        if frm_data.Query_Back_Role_View.RecordCount<>0 then
        begin
            Cmd_Preview.Enabled:=True;
            Cmd_Print.Enabled:=True;
            Showmessage('符合条件的记录有:'+IntToStr(frm_data.Query_Back_Role_View.RecordCount)+'条');
        end
        else
        begin
            Cmd_Preview.Enabled:=False;
            Cmd_Print.Enabled:=False;
            Showmessage('符合条件的记录有:'+IntToStr(frm_data.Query_Back_Role_View.RecordCount)+'条');
        end;
    end;
end;

procedure Tfrm_Done_Report.Cmd_PreviewClick(Sender: TObject);
begin
    inherited;
    tempsql:='Select * from [Back_Role_View] where ';
    if Trim(ComboBox1.Text)<>'' then
    begin
        tempSql:=tempSql+' C_ID Like '+''''+'%'+ Trim(ComboBox1.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox2.Text)<>'' then
    begin
        tempSql:=tempSql+' Man Like '+''''+'%'+ Trim(ComboBox2.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox3.Text)<>'' then
    begin
        tempSql:=tempSql+' Drive_Man Like '+''''+'%'+ Trim(ComboBox3.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox4.Text)<>'' then
    begin
        tempSql:=tempSql+' Drive_ID Like '+''''+'%'+ Trim(ComboBox4.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox5.Text)<>'' then
    begin
        tempSql:=tempSql+' Back_Date = '+''''+ Trim(ComboBox5.Text)+''''+' and ';
    end;
    if Trim(ComboBox6.Text)<>'' then
    begin
        tempSql:=tempSql+' Done_Date = '+''''+ Trim(ComboBox6.Text)+''''+' and ';
    end;
    if CheckBox7.Checked=True then
    begin
        if Trim(Edit1.Text)<>'' then
        begin
            tempSql:=tempSql+' Back_Date between '''+Trim(Edit1.Text)+''' and '''+Trim(Edit2.Text)+''''+' and ';
        end
        else
        begin
            Application.MessageBox('操作错误,已经选择了按时间段查询,开始时间不能为空',''mb_ok);
            Edit1.SetFocus;
            Exit;
        end;
    end;
    if CheckBox8.Checked=True then
    begin
        if Trim(Edit3.Text)<>'' then
        begin
            tempSql:=tempSql+' Done_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.Query_Back_Role_View 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_BackRole_HeaderTitle.Caption:=func.Use_mond+frm_ReportInFormation.L_BackRole_HeaderTitle.Caption;
        frm_ReportInFormation.lab_BackRole_Ren.Caption:=frm_ReportInFormation.lab_BackRole_Ren.Caption+func.Login_Name;
        frm_ReportInFormation.Lab_BackRole_Time.Caption:=frm_ReportInFormation.Lab_BackRole_Time.Caption+formatdatetime('yyyy''-''mm''-''dd',now);
        frm_ReportInFormation.QuickRep_Back_Role.Prepare;
        frm_Preview.ShowModal(frm_ReportInFormation.QuickRep_Back_Role,'违章信息报表');
    end;
end;

procedure Tfrm_Done_Report.Cmd_PrintClick(Sender: TObject);
begin
    inherited;
    tempsql:='Select * from [Back_Role_View] where ';
    if Trim(ComboBox1.Text)<>'' then
    begin
        tempSql:=tempSql+' C_ID Like '+''''+'%'+ Trim(ComboBox1.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox2.Text)<>'' then
    begin
        tempSql:=tempSql+' Man Like '+''''+'%'+ Trim(ComboBox2.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox3.Text)<>'' then
    begin
        tempSql:=tempSql+' Drive_Man Like '+''''+'%'+ Trim(ComboBox3.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox4.Text)<>'' then
    begin
        tempSql:=tempSql+' Drive_ID Like '+''''+'%'+ Trim(ComboBox4.Text)+'%'+''''+' and ';
    end;
    if Trim(ComboBox5.Text)<>'' then
    begin
        tempSql:=tempSql+' Back_Date = '+''''+ Trim(ComboBox5.Text)+''''+' and ';
    end;
    if Trim(ComboBox6.Text)<>'' then
    begin
        tempSql:=tempSql+' Done_Date = '+''''+ Trim(ComboBox6.Text)+''''+' and ';
    end;
    if CheckBox7.Checked=True then
    begin
        if Trim(Edit1.Text)<>'' then
        begin
            tempSql:=tempSql+' Back_Date between '''+Trim(Edit1.Text)+''' and '''+Trim(Edit2.Text)+''''+' and ';
        end
        else
        begin
            Application.MessageBox('操作错误,已经选择了按时间段查询,开始时间不能为空',''mb_ok);
            Edit1.SetFocus;
            Exit;
        end;
    end;
    if CheckBox8.Checked=True then
    begin
        if Trim(Edit3.Text)<>'' then
        begin
            tempSql:=tempSql+' Done_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.Query_Back_Role_View 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_BackRole_HeaderTitle.Caption:=func.Use_mond+frm_ReportInFormation.L_BackRole_HeaderTitle.Caption;
        frm_ReportInFormation.lab_BackRole_Ren.Caption:=frm_ReportInFormation.lab_BackRole_Ren.Caption+func.Login_Name;
        frm_ReportInFormation.Lab_BackRole_Time.Caption:=frm_ReportInFormation.Lab_BackRole_Time.Caption+formatdatetime('yyyy''-''mm''-''dd',now);
        frm_ReportInFormation.QuickRep_Back_Role.Prepare;
        frm_ReportInFormation.QuickRep_Back_Role.Print;
    end;
end;

end.

⌨️ 快捷键说明

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