📄 qryconditionfrm.pas
字号:
unit qryConditionfrm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, RXCtrls, StdCtrls, Buttons, ComCtrls;
type
TqryConditionForm = class(TForm)
Panel1: TPanel;
RxLabel1: TRxLabel;
RxLabel3: TRxLabel;
RxLabel4: TRxLabel;
RxLabel5: TRxLabel;
RxLabel7: TRxLabel;
dpBIRTH1: TDateTimePicker;
RxLabel8: TRxLabel;
dpBIRTH2: TDateTimePicker;
RxLabel10: TRxLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
ComboBox4: TComboBox;
procedure RxLabel1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
APPMode:Byte;
procedure ClearEdit;
procedure ShowNotebook;
procedure ShowEditor;
procedure ShowCD;
procedure ShowSeal;
function BuildSQLStr:String;
{ Private declarations }
public
{ Public declarations }
end;
var
qryConditionForm: TqryConditionForm;
procedure ShowqryCondition(AppNo:byte);
implementation
uses DataModule1,ApplyRptfrm,ApplyEditRptfrm;
{$R *.DFM}
procedure ShowqryCondition(AppNo:Byte);
begin
qryConditionForm:=TqryConditionForm.Create(Application);
try
qryConditionForm.AppMode:=AppNo;
qryConditionForm.ShowModal;
if qryConditionForm.ModalResult =mrOK then
case AppNo of
0:begin
qryConditionForm.ShowNotebook;
ShowApplyRpt(0);
end;
1:begin //制作要求
qryConditionForm.ShowEditor;
ShowApplyEditRpt;
end;
2:begin
qryConditionForm.ShowCD;
ShowApplyRpt(2);
end;
3:begin
qryConditionForm.ShowSeal;
ShowApplyRpt(3);
end;
4:;
end;
finally
qryConditionForm.Free;
end;
end;
procedure TqryConditionForm.ClearEdit;
var
i: word;
begin
for i := 0 to ComponentCount - 1 do
begin
if Components[i] is TComboBox then
TComboBox(Components[i]).Text := '';
if Components[i] is TLabel then
TRxLabel(Components[i]).Font.Color := clBlue;
end;
dpBIRTH1.Date:=Date;
dpBIRTH2.Date:=Date;
end;
procedure TqryConditionForm.RxLabel1Click(Sender: TObject);
begin
with (Sender as TRxLabel) do
if Font.Color = clBLue then
Font.Color := clRed
else
Font.Color := clBlue;
end;
function TqryConditionForm.BuildSQLStr:String;
var
Sep:String;
BT,BT1:String;
begin
sep:='';
Result:='';
BT:=formatdatetime('yyyy-mm-dd',dpBIRTH1.Date);
BT1:=formatdatetime('yyyy-mm-dd',dpBIRTH2.Date);
if ComboBox1.Text<>'' then
begin
Result := Format('(A_ApplyMan=''%s'')', [ComboBox1.Text]);
Sep := 'AND';
end;
if ComboBox2.Text<>'' then
begin
Result := Format('%s %s (A_Client=''%s'')',[Result, Sep,ComboBox2.Text]);
Sep := 'AND';
end;
if ComboBox3.Text<>'' then
begin
Result := Format('%s %s (A_Depart=''%s'')',[Result, Sep,ComboBox3.Text]);
Sep := 'AND';
end;
if ComboBox4.Text<>'' then
begin
Result := Format('%s %s (A_ManageMan =''%s'')',[Result, Sep,ComboBox4.Text]);
Sep := 'AND';
end;
if dpBIRTH1.Date<Date then
begin
Result:=Format('%s %s (A_Date>''%s'')', [Result,sep,BT]);
Sep := 'AND';
Result:=Format('%s %s (A_Date<=''%s'')',[Result,sep,BT1]);
Sep:='AND';
end;
end;
procedure TqryConditionForm.FormShow(Sender: TObject);
begin
clearEdit;
case CurrentLev of
0:begin
ComboBox1.Enabled :=False;
ComboBox2.Enabled :=False;
ComboBox3.Enabled :=False;
Combobox4.Enabled :=False;
ComboBox1.Text :=CurrentWorker;
end;
1:begin
ComboBox1.Enabled :=True;
ComboBox2.Enabled :=True;
ComboBox3.Enabled :=False;
Combobox4.Enabled :=True; //有漏洞 可以查到别部门
GetDepartComboBoxItem(ComboBox1);
ComboBox3.Text :=CurrentDepart;
end;
2:begin
ComboBox1.Enabled :=True;
ComboBox2.Enabled :=True;
ComboBox3.Enabled :=True;
Combobox4.Enabled :=True;
GetComboBoxItem(ComboBox1);
GetComboBoxItem(ComboBox4);
end;
end;
if AppMode=2 then
begin
ComboBox2.Enabled :=False;
end;
end;
procedure TqryConditionForm.ShowCD;
var
SQLString:String;
begin
SQlString:=BuildSQLStr;
if SQLString<>'' then
SQLString:=Format('Select * from ApplyCD where (%s)',[SQLString])
else SQLString:='Select * from ApplyCD';
with DM.qryApply do
begin
Close;
SQL.Clear;
SQL.Add(SQLString);
Open;
end;
end;
procedure TqryConditionForm.ShowEditor;
var
SQLString:String;
begin
SQlString:=BuildSQLStr;
if SQLString<>'' then
SQLString:=Format('Select * from ApplyEditor where (%s)',[SQLString])
else SQLString:='Select * from ApplyEditor';
with DM.qryApply do
begin
Close;
SQL.Clear;
SQL.Add(SQLString);
Open;
end;
end;
procedure TqryConditionForm.ShowNotebook;
var
SQLString:String;
begin
SQlString:=BuildSQLStr;
if SQLString<>'' then
SQLString:=Format('Select * from ApplyNoteBook where (%s)',[SQLString])
else SQLString:='Select * from ApplyNoteBook';
with DM.qryApply do
begin
Close;
SQL.Clear;
SQL.Add(SQLString);
Open;
end;
end;
procedure TqryConditionForm.ShowSeal;
var
SQLString:String;
begin
ComboBox2.Enabled :=False;
SQlString:=BuildSQLStr;
if SQLString<>'' then
SQLString:=Format('Select * from ApplySeal where (%s)',[SQLString])
else SQLString:='Select * from ApplySeal';
with DM.qryApply do
begin
Close;
SQL.Clear;
SQL.Add(SQLString);
Open;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -