📄 u3_1.pas
字号:
unit U3_1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, ExtCtrls, CheckLst, Grids, DBGrids, DB,
DBTables, Buttons ;
type
TF3_1 = class(TForm)
bmzPanel1: TPanel;
bmLabel1: TLabel;
bmComboBox1: TComboBox;
bmPanel1: TPanel;
Splitter1: TSplitter;
dwPanel1: TPanel;
dwLabel1: TLabel;
dwEdit1: TEdit;
dwListBox1: TListBox;
Panel1: TPanel;
xfdPanel1: TPanel;
xfdPageControl1: TPageControl;
xmTabSheet1: TTabSheet;
xmLabel1: TLabel;
xeLabel1: TLabel;
xmDBGrid1: TDBGrid;
xhTabSheet2: TTabSheet;
xhLabel1: TLabel;
xhDBGrid2: TDBGrid;
syTabSheet3: TTabSheet;
syDBGrid1: TDBGrid;
fkPanel1: TPanel;
fkfLabel1: TLabel;
jsLabel1: TLabel;
ysLabel1: TLabel;
sjLabel1: TLabel;
mcLabel1: TLabel;
khLabel1: TLabel;
zhLabel1: TLabel;
SBTzhangdan: TSpeedButton;
SBTjiezhang: TSpeedButton;
SBTback: TSpeedButton;
CBoxfukuan: TComboBox;
Edit1: TEdit;
EDys: TEdit;
EDsj: TEdit;
CBoxbizhong: TComboBox;
EDyinghang: TEdit;
EDzhanghao: TEdit;
Panel2: TPanel;
DBGrid2: TDBGrid;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure CBoxfukuanChange(Sender: TObject);
procedure SBTbackClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure readinfo(info:string);
procedure DBGrid2CellClick(Column: TColumn);
procedure add;
procedure SBTjiezhangClick(Sender: TObject);
procedure SBTzhangdanClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
F3_1: TF3_1;
implementation
uses UDmo, Ureport;
{$R *.dfm}
procedure TF3_1.add;
var
zh:string;
begin
zh:=DBGrid2.Fields[0].AsString;
dwListBox1.Items.Clear;
with dmo.ADOQuery4 do
begin
Close;
sql.Clear;
sql.Add('select zhanghaoID from zhanghao');
sql.Add('where dengjiID=:zh');
parameters.ParamByName('zh').Value:=zh;
open;
while EOF=false do
begin
dwListbox1.Items.Add(fields.Fields[0].AsString);
next;
end;
end;
end;
procedure TF3_1.readinfo(info:string);
begin
with dmo.ADOQuery3 do
begin
Close;
xmDBgrid1.Columns.Clear;
sql.Clear;
sql.add('select xfID as ''ID'',mingxi.zhanghaoID as ''顾客账号'','
+'shangpinName as ''编号'',mingcheng as ''名称'','
+'danwei as ''单位'',danjia as ''单价'','
+'mingxi.xiaofei as ''消费额'',time as ''消费时间''');
sql.Add('from mingxi,zhanghao');
sql.Add('where zhanghao.dengjiID=:dengjiID');
sql.add('and mingxi.zhanghaoID=zhanghao.zhanghaoID');
parameters.ParamByName('dengjiID').Value:=strToint(info);
open;
end;
end;
procedure TF3_1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TF3_1.CBoxfukuanChange(Sender: TObject);
begin
if CBoxFukuan.Text='现金' then
begin
EDyinghang.Enabled:=false;
EDyinghang.Color:=clScrollBar;
EDzhanghao.Enabled:=false;
EDzhanghao.Color:=clScrollBar;
Cboxbizhong.Enabled:=true;
CBoxbizhong.Color:=clWindow;
CBoxbizhong.Items.Clear;
CBoxbizhong.Items.Add('人民币');
CBoxbizhong.Items.Add('美元');
CBoxbizhong.ItemIndex:=0;
end else if CBoxFukuan.Text='信用卡' then
begin
EDzhanghao.Enabled:=true;
EDzhanghao.Color:=clWindow;
EDyinghang.Enabled:=false;
EDyinghang.Color:=clScrollBar;
CBoxbizhong.Enabled:=true;
CBoxbizhong.Color:=clWindow;
CBoxbizhong.Items.Clear;
CBoxbizhong.Items.Add('牡丹卡');
CBoxbizhong.Items.Add('灵通卡');
CBoxbizhong.Items.Add('龙卡');
CBoxbizhong.ItemIndex:=0;
end else if CBoxFukuan.Text='支票' then
begin
EDyinghang.Enabled:=true;
EDyinghang.Color:=clWindow;
EDzhanghao.Enabled:=true;
EDzhanghao.Color:=clWindow;
CBoxbizhong.Enabled:=true;
CBoxbizhong.Color:=clWindow;
CBoxbizhong.Items.Clear;
CBoxbizhong.Text:='';
end else if CBoxFukuan.Text='签单帐户' then
begin
CBoxbizhong.Enabled:=false;
CBoxbizhong.Color:=clScrollBar;
EDyinghang.Enabled:=false;
EDyinghang.Color:=clScrollBar;
EDzhanghao.Enabled:=false;
EDzhanghao.Color:=clScrollBar;
end else begin
CBoxbizhong.Enabled:=false;
CBoxbizhong.Color:=clScrollBar;
EDyinghang.Enabled:=false;
EDyinghang.Color:=clScrollBar;
EDzhanghao.Enabled:=false;
EDzhanghao.Color:=clScrollBar;
end;
end;
procedure TF3_1.SBTbackClick(Sender: TObject);
begin
Close;
end;
procedure TF3_1.FormShow(Sender: TObject);
begin
with Dmo.ADOQuery2 do
begin
Close;
SQL.Clear;
Sql.Add('select Distinct dengjiID, na from Vinfo');
sql.Add('where zhuangtai=1');
open;
end;
Dbgrid2.Columns.Items[0].Width:=40;
DBGrid2.Columns.Items[1].Width:=50;
readinfo('0')
end;
procedure TF3_1.DBGrid2CellClick(Column: TColumn);
var
zong:real;
yajin:real;
day:integer;
begin
{with dmo.ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select binkeINFo.ruzhutime,binkeInfo.likaitime,B.xfID from binkeINfo,');
sql.Add('(select distinct A.shangpinname,Vinfo.sfz,A.xfID from VInfo,');
sql.Add('(select zhanghao.dengjiID,mingxi.shangpinname,mingxi.xfID'
+'from mingxi,zhanghao where mingxi.zhanghaoID=zhanghao.zhanghaoID'
+' and zhanghao.dengjiID=:dengjiID) as A');
sql.Add('where A.dengjiID=Vinfo.dengjiID) as B');
sql.Add('where B.sfz=binkeINfo.sfz and B.shangpinname like('''+'kf'+'%'')');
parameters.ParamByName('dengjiID').Value:=DBgrid2.Fields[0].AsInteger;
open;
while Eof=false do
begin
//day:=fields.Fields[1].Value-fields.Fields[0].Value;
end;
end; }
readInfo(DBgrid2.Fields[0].AsString);
Panel2.Caption:=DBGrid2.Fields[0].AsString+' '
+DBGrid2.Fields[1].AsString;
add;
with Dmo.ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select SUM(danjia) from mingxi');
sql.Add('where zhanghaoID like('''+DBgrid2.Fields[0].AsString+'%'')');
open;
zong:=fields.Fields[0].AsFloat;
Edit1.Text:=floatTostr(zong);
close;
sql.Clear;
sql.Add('select yajin from dengji');
sql.Add('where dengjiID=:dengjiID');
parameters.ParamByName('dengjiID').Value:=DBGrid2.Fields[0].AsInteger;
open;
yajin:=fields.Fields[0].AsFloat;
EDys.Text:=floatTostr(yajin);
EDsj.text:=floatTostr(zong-yajin);
end;
end;
procedure TF3_1.SBTjiezhangClick(Sender: TObject);
var
kf:string;
count:integer;
ID:integer;
begin
if MessageBox(Handle, '确定要结账吗?', '结账询问',
MB_ICONQUESTION or MB_OKCANCEL) <> IDOK then
exit;
DMo.ADOQuery3.First;
with dmo.ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('update zhanghao set zhuangtai=''0''');
sql.Add('where dengjiID=:dengjiID');
ID:=DBgrid2.Fields[0].AsInteger;
parameters.ParamByName('dengjiID').Value:=id;
execsql;
close;
sql.Clear;
sql.Add('update zhanghao set yifu=weifu');
sql.Add('where dengjiID=:dengjiID');
parameters.ParamByName('dengjiID').Value:=id;
execsql;
end;
while DMO.ADOQuery3.eof=false do
begin
with dmo.ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('update mingxi set fk=''y''');
sql.Add('where xfID=:id');
parameters.ParamByName('id').Value:=id;
execsql;
end;
DMo.ADOQuery3.next;
end;
for count:=0 to dwlistbox1.count-1 do
begin
kf:=copy(dwlistBox1.Items.Strings[count],length(trimright(dwlistBox1.Items.Strings[0]))-5,6);
with Dmo.ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('update zhuangtai set zhuangtai=''清理中''');
sql.Add('where fangjian=:fangjian');
parameters.ParamByName('fangjian').Value:=kf;
execsql;
end;
end;
with Dmo.ADOQuery2 do
begin
Close;
SQL.Clear;
Sql.Add('select Distinct dengjiID, na from Vinfo');
sql.Add('where zhuangtai=1');
open;
end;
Dbgrid2.Columns.Items[0].Width:=40;
DBGrid2.Columns.Items[1].Width:=50;
readinfo('0')
end;
procedure TF3_1.SBTzhangdanClick(Sender: TObject);
var
ID:integer;
begin
Application.CreateForm(TQRListForm,QRListForm);
ID:=DBgrid2.Fields[0].AsInteger;
with QRListForm.ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select * from report where dengjiID=:id');
parameters.ParamByName('ID').Value:=ID;
Open;
end;
QRListForm.QuickRep1.Preview;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -