📄 mc_jhxxtj.pas
字号:
unit MC_JHXXTJ;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids, StdCtrls, Db, DBTables, ComCtrls, Buttons, ExtCtrls,
ADODB;
type
TJHXXTJ = class(TForm)
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
DBGrid1: TDBGrid;
Query1: TQuery;
DataSource1: TDataSource;
GroupBox3: TGroupBox;
CheckBox1: TCheckBox;
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Query2: TQuery;
BitBtn3: TBitBtn;
CheckBox2: TCheckBox;
ComboBox1: TComboBox;
Label10: TLabel;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
ComboBox4: TComboBox;
Edit1: TEdit;
Label11: TLabel;
Panel1: TPanel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure BitBtn2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure ComboBox4Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
JHXXTJ: TJHXXTJ;
implementation
{$R *.DFM}
//系统初始设置
procedure TJHXXTJ.FormShow(Sender: TObject);
begin
ANimateWindow(Handle,300,AW_SLIDE+AW_VER_NEGATIVE);
GroupBox1.Refresh;
GroupBox2.Refresh;
GroupBox3.Refresh;
Panel1.Refresh;
DBGrid1.Refresh;
ComboBox1.ItemIndex:=0;
ComboBox2.ItemIndex:=0;
ComboBox3.ItemIndex:=0;
ComboBox4.ItemIndex:=0;
end;
//删除数据
procedure TJHXXTJ.BitBtn1Click(Sender: TObject);
begin
If Query1.RecordCount <> 0 Then
Query1.Delete;
end;
//筛选数据
procedure TJHXXTJ.BitBtn3Click(Sender: TObject);
var cc,abc:String;
begin
If Length(Edit1.Text) = 0 Then
begin
ShowMessage('请输入查询值');
Edit1.SetFocus;
End
Else
begin
if ComboBox2.Items[ComboBox2.ItemIndex]='升序' then cc:='ASC' else CC:='DESC';
if Query1.Prepared=False then Query1.Prepare;
if Length(Edit1.Text)<>0 then Abc:=edit1.Text+'*';
//设置时间
If Checkbox1.Checked = True Then
begin
if ComboBox4.text='Like' then
begin
if Edit1.text='*' then
begin
Query1.Close;
Query1.SQL.Clear;
if cc='ASC' then Query1.SQL.Add('select * From 进货信息历史表 Where 进货日期>:Date1 and 进货日期<:Date2 ORDER BY '+ComboBox1.Items[ComboBox1.ItemIndex]+' ASC')
else Query1.SQL.Add('select * From 进货信息历史表 Where 进货日期>:Date1 and 进货日期<:Date2 ORDER BY '+ComboBox1.Items[ComboBox1.ItemIndex]+' DESC');
Query1.ParamByName('Date1').AsDateTime:=DateTimePicker1.DateTime;
Query1.ParamByName('Date2').AsDateTime:=DateTimePicker2.DateTime;
Query1.Open;
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('select Count(DisTinCt 商品编号),Sum(数量),Sum(合计金额) from 进货信息历史表');
Query2.SQL.Add('Where 进货日期>:Date1 and 进货日期<:Date2');
Query2.ParamByName('Date1').AsDateTime:=DateTimePicker1.DateTime;
Query2.ParamByName('Date2').AsDateTime:=DateTimePicker2.DateTime;
Query2.Open;
Label3.Caption:=Query2.Fields[0].AsString+'种';
Label5.Caption:=IntToStr(Query1.RecordCount);
Label7.Caption:=Query2.FieldS[1].AsString;
Label9.Caption:=Query2.Fields[2].AsString;
Query2.Close;
End
Else
begin
if (ComboBox3.Items[ComboBox3.ItemIndex]='单据编号') or (ComboBox3.Items[ComboBox3.ItemIndex]='商品编号') or (ComboBox3.Items[ComboBox3.ItemIndex]='数量')
or (ComboBox3.Items[ComboBox3.ItemIndex]='仓库编号') then
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select * From 进货信息历史表 where 进货日期>:Date1 and 进货日期<:Date2 and '+ComboBox3.Items[ComboBox3.ItemIndex]+' Like :A');
if cc='ASC' then
begin
Query1.SQL.Add('ORDER BY '+ComboBox3.Items[ComboBox3.ItemIndex]+' ASC');
End
Else
begin
Query1.SQL.Add('ORDER BY '+ComboBox3.Items[ComboBox3.ItemIndex]+' DESC');
end;
Query1.ParamByName('A').AsString:=Edit1.Text+'%';
Query1.ParamByName('Date1').AsDateTime:=DateTimePicker1.DateTime;
Query1.ParamByName('Date2').AsDateTime:=DateTimePicker2.DateTime;
Query1.Open;
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('select Count(DisTinCt 商品编号),Sum(数量),Sum(合计金额) from 进货信息历史表');
Query2.SQL.Add('Where 进货日期>:Date1 and 进货日期<:Date2 and '+ComboBox3.Items[ComboBox3.ItemIndex]+' Like :A');
Query2.ParamByName('A').AsString:=Edit1.Text+'%';
Query2.ParamByName('Date1').AsDateTime:=DateTimePicker1.DateTime;
Query2.ParamByName('Date2').AsDateTime:=DateTimePicker2.DateTime;
Query2.Open;
Label3.Caption:=Query2.Fields[0].AsString+'种';
Label5.Caption:=IntToStr(Query1.RecordCount);
Label7.Caption:=Query2.FieldS[1].AsString;
Label9.Caption:=Query2.Fields[2].AsString;
Query2.Close;
end;//结束判断字段为整形
if (ComboBox3.Items[ComboBox3.ItemIndex]='商品名称') or (ComboBox3.Items[ComboBox3.ItemIndex]='经手人') or (ComboBox3.Items[ComboBox3.ItemIndex]='仓库名称') then
begin
if ComboBox3.Items[ComboBox3.ItemIndex]='经手人' then
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select * From 进货信息历史表 where 进货日期>:Date1 and 进货日期<:Date2 and 经受人 Like :A');
if cc='ASC' then
begin
Query1.SQL.Add('ORDER BY '+ComboBox1.Items[ComboBox1.ItemIndex]+' ASC');
End
Else
begin
Query1.SQL.Add('ORDER BY '+ComboBox1.Items[ComboBox1.ItemIndex]+' DESC');
end;
Query1.ParamByName('A').AsString:=Edit1.Text+'%';
Query1.ParamByName('Date1').AsDateTime:=DateTimePicker1.DateTime;
Query1.ParamByName('Date2').AsDateTime:=DateTimePicker2.DateTime;
Query1.Open;
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('select Count(DisTinCt 商品编号),Sum(数量),Sum(合计金额) from 进货信息历史表');
Query2.SQL.Add('Where 进货日期>:Date1 and 进货日期<:Date2 and 经受人 Like :A');
Query2.ParamByName('A').AsString:=Edit1.Text+'%';
Query2.ParamByName('Date1').AsDateTime:=DateTimePicker1.DateTime;
Query2.ParamByName('Date2').AsDateTime:=DateTimePicker2.DateTime;
Query2.Open;
Label3.Caption:=Query2.Fields[0].AsString+'种';
Label5.Caption:=IntToStr(Query1.RecordCount);
Label7.Caption:=Query2.FieldS[1].AsString;
Label9.Caption:=Query2.Fields[2].AsString;
Query2.Close;
end//结束判断字段为字符型[经受人]
Else
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select * From 进货信息历史表 where 进货日期>:Date1 and 进货日期<:Date2 and '+ComboBox3.Items[ComboBox3.ItemIndex]+' Like :A');
if cc='ASC' then
begin
Query1.SQL.Add('ORDER BY '+ComboBox1.Items[ComboBox1.ItemIndex]+' ASC');
End
Else
begin
Query1.SQL.Add('ORDER BY '+ComboBox1.Items[ComboBox1.ItemIndex]+' DESC');
end;
Query1.ParamByName('A').AsString:=Edit1.Text+'%';
Query1.ParamByName('Date1').AsDateTime:=DateTimePicker1.DateTime;
Query1.ParamByName('Date2').AsDateTime:=DateTimePicker2.DateTime;
Query1.Open;
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('select Count(DisTinCt 商品编号),Sum(数量),Sum(合计金额) from 进货信息历史表');
Query2.SQL.Add('Where 进货日期>:Date1 and 进货日期<:Date2 and '+ComboBox3.Items[ComboBox3.ItemIndex]+' Like :A');
Query2.ParamByName('A').AsString:=Edit1.Text+'%';
Query2.ParamByName('Date1').AsDateTime:=DateTimePicker1.DateTime;
Query2.ParamByName('Date2').AsDateTime:=DateTimePicker2.DateTime;
Query2.Open;
Label3.Caption:=Query2.Fields[0].AsString+'种';
Label5.Caption:=IntToStr(Query1.RecordCount);
Label7.Caption:=Query2.FieldS[1].AsString;
Label9.Caption:=Query2.Fields[2].AsString;
Query2.Close;
end;
end;//结束判断字段为字符型
end;//结束Edit1.Text不为*
end//结束Like------------------------------
Else
begin//开始不等符号判断
if ComboBox4.Items[ComboBox4.ItemIndex]='=' then
begin
Query1.Close;
Query1.SQL.Clear;
if ComboBox3.Items[ComboBox3.ItemIndex]='经手人' then
Query1.SQL.Add('Select * From 进货信息历史表 where 经受人 = :B and 进货日期>:Date1 and 进货日期<:Date2')
Else
Query1.SQL.Add('Select * From 进货信息历史表 where 进货日期>:Date1 and 进货日期<:Date2 and '+ComboBox3.Items[ComboBox3.ItemIndex]+' = :B');
//------------------------------------------------
if cc='ASC' then
begin
Query1.SQL.Add('ORDER BY '+ComboBox1.Items[ComboBox1.ItemIndex]+' ASC');
End
Else
begin
Query1.SQL.Add('ORDER BY '+ComboBox1.Items[ComboBox1.ItemIndex]+' DESC');
end;
if (ComboBox3.Items[ComboBox3.ItemIndex]='商品名称') or (ComboBox3.Items[ComboBox3.ItemIndex]='经手人') or (ComboBox3.Items[ComboBox3.ItemIndex]='仓库名称') then
begin
Query1.ParamByName('B').AsString:=Edit1.Text;
End
Else
begin
Query1.ParamByName('B').AsInteger:=StrToInt(Edit1.Text);
end;
Query1.ParamByName('Date1').AsDateTime:=DateTimePicker1.DateTime;
Query1.ParamByName('Date2').AsDateTime:=DateTimePicker2.DateTime;
//Query1.Params[0].AsString:=Edit1.Text;
Query1.Open;
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('select Count(DisTinCt 商品编号),Sum(数量),Sum(合计金额) from 进货信息历史表');
if ComboBox3.Items[ComboBox3.ItemIndex]='经手人' then
Query2.SQL.Add('Where 经受人 = :B and 进货日期>:Date1 and 进货日期<:Date2')
Else
Query2.SQL.Add('Where '+ComboBox3.Items[ComboBox3.ItemIndex]+' = :B and 进货日期>:Date1 and 进货日期<:Date2');
//------------------------------------------------
if (ComboBox3.Items[ComboBox3.ItemIndex]='商品名称') or (ComboBox3.Items[ComboBox3.ItemIndex]='经手人') or (ComboBox3.Items[ComboBox3.ItemIndex]='仓库名称') then
begin
Query2.ParamByName('B').AsString:=Edit1.Text;
End
Else
begin
Query2.ParamByName('B').AsInteger:=StrToInt(Edit1.Text);
end;
Query2.ParamByName('Date1').AsDateTime:=DateTimePicker1.DateTime;
Query2.ParamByName('Date2').AsDateTime:=DateTimePicker2.DateTime;
//Query2.Params[0].AsString:=Edit1.Text;
Query2.Open;
Label3.Caption:=Query2.Fields[0].AsString+'种';
Label5.Caption:=IntToStr(Query1.RecordCount);
Label7.Caption:=Query2.FieldS[1].AsString;
Label9.Caption:=Query2.Fields[2].AsString;
Query2.Close;
end;//结束等号判断
if ComboBox4.Items[ComboBox4.ItemIndex]='>' then
begin
Query1.Close;
Query1.SQL.Clear;
if ComboBox3.Items[ComboBox3.ItemIndex]='经手人' then
Query1.SQL.Add('Select * From 进货信息历史表 where 经受人 > :B and 进货日期>:Date1 and 进货日期<:Date2')
Else
Query1.SQL.Add('Select * From 进货信息历史表 where '+ComboBox3.Items[ComboBox3.ItemIndex]+' > :B and 进货日期>:Date1 and 进货日期<:Date2');
//-----------------------------------------------------------------
if cc='ASC' then
begin
Query1.SQL.Add('ORDER BY '+ComboBox1.Items[ComboBox1.ItemIndex]+' ASC');
End
Else
begin
Query1.SQL.Add('ORDER BY '+ComboBox1.Items[ComboBox1.ItemIndex]+' DESC');
end;
if (ComboBox3.Items[ComboBox3.ItemIndex]='商品名称') or (ComboBox3.Items[ComboBox3.ItemIndex]='经手人') or (ComboBox3.Items[ComboBox3.ItemIndex]='仓库名称') then
begin
Query1.ParamByName('B').AsString:=Edit1.Text;
End
Else
begin
Query1.ParamByName('B').AsInteger:=StrToInt(Edit1.Text);
end;
Query1.ParamByName('Date1').AsDateTime:=DateTimePicker1.DateTime;
Query1.ParamByName('Date2').AsDateTime:=DateTimePicker2.DateTime;
//Query1.Params[0].AsString:=Edit1.Text;
Query1.Open;
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('select Count(DisTinCt 商品编号),Sum(数量),Sum(合计金额) from 进货信息历史表');
if ComboBox3.Items[ComboBox3.ItemIndex]='经手人' then
Query2.SQL.Add('Where 经受人 > :B and 进货日期>:Date1 and 进货日期<:Date2')
Else
Query2.SQL.Add('Where '+ComboBox3.Items[ComboBox3.ItemIndex]+' > :B and 进货日期>:Date1 and 进货日期<:Date2');
//-------------------------------------------------
if (ComboBox3.Items[ComboBox3.ItemIndex]='商品名称') or (ComboBox3.Items[ComboBox3.ItemIndex]='经手人') or (ComboBox3.Items[ComboBox3.ItemIndex]='仓库名称') then
begin
Query2.ParamByName('B').AsString:=Edit1.Text;
End
Else
begin
Query2.ParamByName('B').AsInteger:=StrToInt(Edit1.Text);
end;
Query2.ParamByName('Date1').AsDateTime:=DateTimePicker1.DateTime;
Query2.ParamByName('Date2').AsDateTime:=DateTimePicker2.DateTime;
Query2.Open;
Label3.Caption:=Query2.Fields[0].AsString+'种';
Label5.Caption:=IntToStr(Query1.RecordCount);
Label7.Caption:=Query2.FieldS[1].AsString;
Label9.Caption:=Query2.Fields[2].AsString;
Query2.Close;
end;//结束大于号
if ComboBox4.Items[ComboBox4.ItemIndex]='<' then
begin
Query1.Close;
Query1.SQL.Clear;
if ComboBox3.Items[ComboBox3.ItemIndex]='经手人' then
Query1.SQL.Add('Select * From 进货信息历史表 where 经受人 < :B and 进货日期>:Date1 and 进货日期<:Date2')
Else
Query1.SQL.Add('Select * From 进货信息历史表 where '+ComboBox3.Items[ComboBox3.ItemIndex]+' < :B and 进货日期>:Date1 and 进货日期<:Date2');
//------------------------------------------------
if cc='ASC' then
begin
Query1.SQL.Add('ORDER BY '+ComboBox1.Items[ComboBox1.ItemIndex]+' ASC');
End
Else
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -