📄 traderfindinfo.~pas
字号:
unit TraderFindInfo;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Grids, ComCtrls, PicButton, DB, ADODB,Comobj,excel97,excel2000;
type
TTraderFind = class(TForm)
Image1: TImage;
Image2: TImage;
Bevel1: TBevel;
Bevel2: TBevel;
Label1: TLabel;
ComboBox1: TComboBox;
Label2: TLabel;
ComboBox2: TComboBox;
Label3: TLabel;
Edit1: TEdit;
SaleDate: TDateTimePicker;
Label4: TLabel;
ComboBox3: TComboBox;
DBgrid: TStringGrid;
Label5: TLabel;
ListView1: TListView;
PicButton1: TPicButton;
PicButton3: TPicButton;
PicButton4: TPicButton;
query1: TADOQuery;
Bevel3: TBevel;
Label6: TLabel;
Edit2: TEdit;
Label7: TLabel;
Edit3: TEdit;
Label8: TLabel;
Edit4: TEdit;
Label9: TLabel;
Edit5: TEdit;
Label10: TLabel;
Edit6: TEdit;
PicButton5: TPicButton;
ADOTable1: TADOTable;
PicButton2: TPicButton;
procedure FormCreate(Sender: TObject);
procedure Image2Click(Sender: TObject);
procedure PicButton7Click(Sender: TObject);
procedure ComboBox1Click(Sender: TObject);
procedure PicButton1Click(Sender: TObject);
procedure PicButton3Click(Sender: TObject);
procedure ComboBox3Click(Sender: TObject);
procedure PicButton4Click(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
TraderFind: TTraderFind;
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 TTraderFind.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('经手人');
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]:='数量';
DBgrid.Cells[10,0]:='金额';
DBgrid.Cells[11,0]:='搭赠政策';
DBgrid.Cells[12,0]:='搭赠数量';
DBgrid.Cells[13,0]:='搭赠金额';
Dbgrid.Cells[14,0]:='销售日期';
//DBgrid.Cells[14,0]:='库存';
strOper1:='and';
strList:=TStringList.Create;
strList1:=TstringList.Create;
end;
procedure TTraderFind.Image2Click(Sender: TObject);
begin
DefWindowProc(handle,WM_SYSCOMMAND,SC_CLOSE,0);
end;
procedure TTraderFind.PicButton7Click(Sender: TObject);
begin
close;
end;
procedure TTraderFind.ComboBox1Click(Sender: TObject);
begin
case combobox1.ItemIndex of
1:
begin
saleDate.Left:=377;
saleDate.Top:=57;
saleDate.Visible:=true;
edit1.Visible:=false;
strType:='saleDate';
end;
0:
begin
edit1.Left:=377;
edit1.Top:=57;
saleDate.Visible:=false;
edit1.Visible:=true;
strType:='saleCode';
end;
2:
begin
edit1.Left:=377;
edit1.Top:=57;
saleDate.Visible:=false;
edit1.Visible:=true;
strType:='areaName';
end;
3:
begin
edit1.Left:=377;
edit1.Top:=57;
saleDate.Visible:=false;
edit1.Visible:=true;
strType:='ProductName';
end;
4:
begin
edit1.Left:=377;
edit1.Top:=57;
saleDate.Visible:=false;
edit1.Visible:=true;
strType:='traderName';
end;
5:
begin
edit1.Left:=377;
edit1.Top:=57;
saleDate.Visible:=false;
edit1.Visible:=true;
strType:='checker';
end;
6:
begin
edit1.Left:=377;
edit1.Top:=57;
saleDate.Visible:=false;
edit1.Visible:=true;
strType:='city';
end;
end;
end;
procedure TTraderFind.PicButton1Click(Sender: TObject);
var
listitem:Tlistitem;
i,index:integer;
begin
//stringl:=Tstringlist.Create;
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;
//strList.Add(strWhere);
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 TTraderFind.PicButton3Click(Sender: TObject);
begin
strList.Clear;
strList1.Clear;
strSql:='';
strSql1:='';
listview1.Clear;
strList.Clear;
//strList.Free;
//strList1.Free;
end;
procedure TTraderFind.ComboBox3Click(Sender: TObject);
begin
case combobox3.ItemIndex of
0: strOper1:=' and ';
1: strOper1:=' or ';
end;
end;
procedure TTraderFind.PicButton4Click(Sender: TObject);
var
strSearch,strSearch1:string;
query2,Query3:TAdoQuery;
price_Arg:double; ///平均价
Amount_Sum:double; ///总数量
Money_Sum:double; ///总金额
Present_Sum:double;///搭赠数量
Present_Money:double;//搭赠金额
i:integer;
tmpTotal:Array[0..3] of double;
strdelete,strInsert:string;
begin
stringl:=DeleteLastSubstring(' and ',strsql1);
//Showmessage(stringl);
FieldList:=TStringList.Create;
if (strList1.Count>0) then
begin
strSearch:='SELECT * FROM saleTable WHERE '+stringl;
//showmessage(strSearch);
query2:=RunSqlOfAdo(query1,strSearch);
if isRunSql(query1,strSearch) then
begin
//Showmessage('bbb'+'aaaa');
while not query2.Eof do
begin
FieldList.Add(query2.FieldValues['saleCode']);
query2.next;
end;
FieldList.Sort;
strWhere1:=' saleCode BETWEEN "'+FieldList[0]+'" and "'+FieldList[FieldList.count-1]+'"';
end
else
begin
Showmessage('记录不存在...');
/////////////
for i:=1 to dbgrid.rowcount-2 do
begin
dbgrid.Cells[0,i]:='';
dbgrid.Cells[1,i]:='';
dbgrid.Cells[2,i]:='';
dbgrid.Cells[3,i]:='';
dbgrid.Cells[4,i]:='';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -