📄 stockfindinfo.pas
字号:
unit StockFindInfo;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, ComCtrls, Grids, StdCtrls, PicButton, ExtCtrls,Comobj,Excel97,Excel2000;
type
TStockFind = class(TForm)
Image1: TImage;
Image2: TImage;
Bevel1: TBevel;
Bevel2: TBevel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
PicButton1: TPicButton;
PicButton3: TPicButton;
PicButton4: TPicButton;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Edit1: TEdit;
SaleDate: TDateTimePicker;
ComboBox3: TComboBox;
DBgrid: TStringGrid;
ListView1: TListView;
query1: TADOQuery;
Bevel3: TBevel;
Label6: TLabel;
Edit2: TEdit;
Label7: TLabel;
Edit3: TEdit;
Label8: TLabel;
Edit4: TEdit;
PicButton5: TPicButton;
ADOTable1: TADOTable;
PicButton2: TPicButton;
procedure Image2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ComboBox1Click(Sender: TObject);
procedure PicButton1Click(Sender: TObject);
procedure PicButton3Click(Sender: TObject);
procedure ComboBox3Change(Sender: TObject);
procedure PicButton4Click(Sender: TObject);
procedure PicButton7Click(Sender: TObject);
procedure DBgridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure PicButton5Click(Sender: TObject);
procedure PicButton2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
StockFind: TStockFind;
strList,strList1:TStringList;
strWhere,strSql,strSql1:string;
stringl,stringl1,strWhere1,strWhere2:string;
strType:string;
strOper:string;
strOper1:string;
FieldList:TStringList;
implementation
{$R *.dfm}
uses common,PrinterRpt;
procedure TStockFind.Image2Click(Sender: TObject);
begin
close;
end;
procedure TStockFind.FormCreate(Sender: TObject);
begin
ShowployForm(image1.picture.bitmap,handle);
///添加查询字段////
combobox1.Items.add('进货单号');
combobox1.Items.add('进货日期');
combobox1.Items.add('产品名称');
combobox1.Items.add('经手人');
combobox1.Items.add('所属市');
combobox1.Items.add('所有');
combobox1.Items.add('票据类型');
///添加操作符/////
combobox2.Items.Add('=');
combobox2.Items.Add('>');
combobox2.Items.Add('<');
combobox2.Items.Add('<>');
combobox2.Items.Add('>=');
combobox2.Items.Add('<=');
combobox2.Items.Add('like');
///添加运算符/////
combobox3.Items.Add('并且');
combobox3.Items.Add('或者');
///设置控件stringGrid的标题//////
DBgrid.Cells[0,0]:='进货单号';
dbgrid.ColWidths[0]:=100;
DBgrid.Cells[1,0]:='产品编码';
DBgrid.Cells[2,0]:='产品名称';
DBgrid.Cells[3,0]:='规格';
DBgrid.Cells[4,0]:='容量';
DBgrid.Cells[5,0]:='单位';
DBgrid.Cells[6,0]:='单价';
DBgrid.Cells[7,0]:='数量';
DBgrid.Cells[8,0]:='金额';
DBgrid.Cells[9,0]:='进货日期';
strOper1:='and';
strList:=TStringList.Create;
strList1:=TStringList.Create;
end;
procedure TStockFind.ComboBox1Click(Sender: TObject);
begin
case combobox1.ItemIndex of
1:
begin
saleDate.Left:=377;
saleDate.Top:=57;
saleDate.Visible:=true;
edit1.Visible:=false;
strType:='billDate';
end;
0:
begin
edit1.Left:=377;
edit1.Top:=57;
saleDate.Visible:=false;
edit1.Visible:=true;
strType:='billCode';
end;
2:
begin
edit1.Left:=377;
edit1.Top:=57;
saleDate.Visible:=false;
edit1.Visible:=true;
strType:='ProductName';
end;
3:
begin
edit1.Left:=377;
edit1.Top:=57;
saleDate.Visible:=false;
edit1.Visible:=true;
strType:='Checker';
end;
4:
begin
edit1.Left:=377;
edit1.Top:=57;
saleDate.Visible:=false;
edit1.Visible:=true;
strType:='city';
end;
6:
begin
edit1.Left:=377;
edit1.Top:=57;
saleDate.Visible:=false;
edit1.Visible:=true;
strType:='BeerType';
end;
end;
end;
procedure TStockFind.PicButton1Click(Sender: TObject);
var
listitem:Tlistitem;
i,index:integer;
begin
if combobox1.text='进货日期' then
begin
listitem:=listview1.items.add;
listitem.Caption:=combobox1.Text;
listitem.SubItems.Add(combobox2.text);
listitem.SubItems.Add(DateToStr(saleDate.Date));
listitem.SubItems.Add(combobox3.text);
strWhere:=trim(strType)+trim(combobox2.text)+'"'+trim(DateToStr(saleDate.Date))+'" '+trim(strOper1)+' ';
strList1.Add(strWhere);
end
else
begin
listitem:=listview1.items.add;
listitem.Caption:=combobox1.Text;
listitem.SubItems.Add(combobox2.text);
listitem.SubItems.Add(edit1.text);
listitem.SubItems.Add(combobox3.text);
strWhere:=trim(strType)+trim(combobox2.text)+'"'+trim(edit1.text)+'" '+trim(strOper1)+' ';
strList.Add(strWhere);
end;
strSql:='';
for i:=0 to strList.count-1 do
begin
strSql:=strSql+strList[i];
end;
//Showmessage(strsql);
strSql1:='';
for i:=0 to strList1.count-1 do
begin
strSql1:=strSql1+strList1[i];
end;
//Showmessage(strsql1);
end;
procedure TStockFind.PicButton3Click(Sender: TObject);
begin
strList.Clear;
strList1.Clear;
strSql:='';
strSql1:='';
listview1.Clear;
strList.Clear;
end;
procedure TStockFind.ComboBox3Change(Sender: TObject);
begin
case combobox3.ItemIndex of
0: strOper1:=' and ';
1: strOper1:=' or ';
end;
end;
procedure TStockFind.PicButton4Click(Sender: TObject);
var
strSearch,strSearch1:string;
query2,Query3:TAdoQuery;
price_Arg:double; ///平均价
Amount_Sum:double; ///总数量
Money_Sum:double; ///总金额
i:integer;
tmpTotal:Array[0..1] of double;
strDelete,strInsert:string;
begin
stringl:=DeleteLastSubstring(' and ',strsql1);
//Showmessage(stringl);
FieldList:=TStringList.Create;
if (strList1.count>0) then
begin
strSearch:='SELECT * FROM billTable WHERE '+stringl;
//showmessage(strSearch);
query2:=RunSqlOfAdo(query1,strSearch);
if isRunSql(query1,strSearch) then
begin
while not query2.Eof do
begin
FieldList.Add(query2.FieldValues['billCode']);
query2.next;
end;
FieldList.Sort;
strWhere1:=' billCode BETWEEN "'+FieldList[0]+'" and "'+FieldList[FieldList.count-1]+'"';
end
else
begin
Showmessage('没有找到记录');
for i:=1 to dbgrid.rowcount-2 do
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -