📄 information.pas
字号:
unit information;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, EhlibAdo, ImgList, Menus, ComCtrls, ToolWin, DBGridEh,
ExtCtrls, Buttons, StdCtrls, DB, ADODB, Mask, DBCtrlsEh, comobj, StrUtils;
type
TinfoForm = class(TForm)
infoGEh: TDBGridEh;
Tbinfo: TToolBar;
Tbedit: TToolButton;
Tbprint: TToolButton;
PMprint: TPopupMenu;
Mpreview: TMenuItem;
Tbadd: TToolButton;
Tbdel: TToolButton;
ToolButton4: TToolButton;
TBsec: TToolButton;
Tbsave: TToolButton;
ToolButton7: TToolButton;
Tbexit: TToolButton;
ILinfo: TImageList;
TbRights: TToolButton;
PanelCondition1: TPanel;
Label3: TLabel;
edtTypeCode: TDBEditEh;
Label1: TLabel;
edtCode: TDBEditEh;
tbCopy: TToolButton;
SaveDialog1: TSaveDialog;
procedure TbexitClick(Sender: TObject);
procedure TBsecClick(Sender: TObject);
procedure TbaddClick(Sender: TObject);
procedure TbeditClick(Sender: TObject);
procedure MpreviewClick(Sender: TObject);
procedure TbdelClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure infoGEhDblClick(Sender: TObject);
procedure TbRightsClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure DBEditEh1EditButtons0Click(Sender: TObject;
var Handled: Boolean);
procedure edtCodeKeyPress(Sender: TObject; var Key: Char);
procedure tbCopyClick(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure TbsaveClick(Sender: TObject);
private
{ Private declarations }
tblTmp:TAdoTable;
queryTmp:TAdoQuery;
queryId:integer;
public
{ Public declarations }
procedure dataadd(tablename: TADOtable; formname: Tform);overload;//增加
procedure dataedit(tablename: TADOtable; formname: Tform);overload;//编辑
procedure datadel(tablename: TADOtable);overload;//删除
procedure dataadd(tablename: TADOQuery; formname: Tform);overload;//增加
procedure dataedit(tablename: TADOQuery; formname: Tform);overload;//编辑
procedure datadel(tablename: TADOQuery);overload;//删除
procedure dataprint(sqlstr,reportname:string);//打印
function CheckCode(sqlstr: string; aValue: Integer):boolean;
end;
var
infoForm: TinfoForm;
implementation
uses department, datamodule1, employee, client, vendor_D, store, subarea,
warehouse, search, report2, ClientType, unittype, VendorTYPE, GoodType,
iotype, PayType, bank, IEType, Rights, Operator, selBill1, selBill, edit,
TreeGoodsType;
{$R *.dfm}
procedure TinfoForm.dataadd(tablename: TADOtable; formname: Tform);
var
s:string;
begin
tablename.Append;
s:=FormName.Name;
formname.ShowModal;
end;
procedure TinfoForm.dataadd(tablename: TADOQuery; formname: Tform);
var
s:string;
begin
tablename.Append;
s:=FormName.Name;
formname.ShowModal;
end;
procedure TinfoForm.dataedit(tablename: TADOtable; formname: Tform);
begin
tablename.Edit;
formname.ShowModal;
end;
procedure TinfoForm.dataedit(tablename: TADOQuery; formname: Tform);
begin
tablename.Edit;
formname.ShowModal;
end;
procedure TinfoForm.datadel(tablename: TADOtable);
begin
if MessageDlg('真的要删除当前记录吗?', mtconfirmation, [mbyes, mbno], 0)=idyes then
tablename.Delete
else exit;
end;
procedure TinfoForm.datadel(tablename: TADOQuery);
begin
if MessageDlg('真的要删除当前记录吗?', mtconfirmation, [mbyes, mbno], 0)=idyes then
tablename.Delete
else exit;
end;
procedure TinfoForm.dataprint(sqlstr,reportname:string);
begin
FormRpt1.PrintInfo(Sqlstr,reportname,false);
end;
procedure TinfoForm.TbexitClick(Sender: TObject);
begin
close;
end;
procedure TinfoForm.TBsecClick(Sender: TObject);
var
sSql:string;
begin
//在queryModule中的querycode value
case QueryId of
1: sSql:='008';
2: sSql:='013';
3: sSql:='009';
end;
schConditionForm.xQueryCode:=sSql;
if schConditionForm.showmodal=mrOk then
begin
sSql:=schConditionForm.xSql;
with DataE2 do
case QueryId of
1 : begin
tblgoods.close;
tblGoods.SQL.clear;
tblGoods.SQL.add('select * from goods g '+sSql);
tblGoods.open;
end;
2 : begin
tblvendor.close;
tblvendor.SQL.clear;
tblvendor.SQL.add('select * from Vendor '+sSql);
tblVendor.open;
end;
3 : begin
tblClient.close;
tblClient.SQL.clear;
tblclient.SQL.add('select * from Client '+sSql);
tblClient.open;
end;
end;
end;
end;
procedure TinfoForm.TbaddClick(Sender: TObject);
begin
with DataE2 do
begin
if self.caption='供应商资料' then
dataadd(tblvendor,vend_Dform);
if self.caption='客户资料' then
dataadd(tblClient,clientform);
if self.caption='部门资料' then
dataadd(tblDept,deptForm);
if self.caption='员工资料' then
dataadd(tblemploy,empForm);
if self.caption='区域资料' then
dataadd(tblSubArea,areaForm);
if self.caption='客户类别' then
dataadd(tblclienttype,clienttypeForm);
if self.caption='供应商类别' then
dataadd(tblvdtype,vdTypeForm);
if self.caption='货品资料' then
dataadd(tblGoods,goodsForm);
if self.caption='仓库资料' then
dataadd(tblstore,wareForm);
if self.caption='货品类别' then
dataadd(tblType,GoodTypeForm);
if self.caption='单位资料' then
dataadd(tblUnit,unitForm);
if self.caption='其它出入库类型' then
dataadd(tbliotype,iotypeForm);
if self.caption='收付款方式' then
dataadd(tblpaytype,paytypeForm);
if self.caption='现金银行' then
dataadd(tblbank,bankForm);
if self.caption='收入支出类别' then
dataadd(tblIetype,IetypeForm);
if self.caption='操作员及权限设置' then
dataadd(tblOpr,OperatorForm);
end;
end;
procedure TinfoForm.TbeditClick(Sender: TObject);
begin
with DataE2 do
begin
if self.caption='供应商资料' then
dataedit(tblvendor,vend_Dform);
if self.caption='客户资料' then
dataedit(tblClient,clientform);
if self.caption='部门资料' then
dataedit(tblDept,deptForm);
if self.caption='员工资料' then
dataedit(tblemploy,empForm);
if self.caption='区域资料' then
dataedit(tblSubArea,areaForm);
if self.caption='客户类别' then
dataedit(tblclienttype,clienttypeForm);
if self.caption='供应商类别' then
dataedit(tblvdtype,vdTypeForm);
if self.caption='货品资料' then
dataedit(tblGoods,goodsForm);
if self.caption='仓库资料' then
dataedit(tblstore,wareForm);
if self.caption='货品类别' then
dataedit(tblType,GoodTypeForm);
if self.caption='单位资料' then
dataedit(tblUnit,unitForm);
if self.caption='其它出入库类型' then
dataedit(tbliotype,iotypeForm);
if self.caption='收付款方式' then
dataedit(tblpaytype,paytypeForm);
if self.caption='现金银行' then
dataedit(tblbank,bankForm);
if self.caption='收入支出类别' then
dataedit(tblIetype,IetypeForm);
if self.caption='操作员及权限设置' then
dataedit(tblOpr,OperatorForm);
end;
end;
procedure TinfoForm.MpreviewClick(Sender: TObject);
var
sSql:string;
n:integer;
begin
if self.caption='供应商资料' then
dataprint(dataE2.tblVendor.sql.text,'供应商报表');// 'select * from vendor','供应商报表');
if self.caption='客户资料' then
dataprint(dataE2.tblClient.sql.text,'客户报表');
if self.caption='区域资料' then
dataprint('select * from AREA','区域报表');
if self.caption='客户类别' then
dataprint('select * from ClientType','客户类别报表');
if self.caption='供应商类别' then
dataprint('select * from VendorTYPE','供应商类别报表');
if self.caption='货品资料' then
begin
sSql:=dataE2.tblGoods.sql.text;
n:=pos('where',sSql);
if n > 0 then
sSql:=copy(sSql,n,length(sSql)-n+1)
else sSql:='';
ssql:='select g.*,b.Name as TypeName from Goods g left join GoodsType b on g.TypeCode=b.Type '+sSql;
dataprint(ssql,'货品报表');
end;
if self.caption='仓库资料' then
dataprint('select * from store','仓库报表');
if self.caption='货品类别' then
dataprint('select * from GoodsType','货品类别报表');
if self.caption='单位资料' then
dataprint('select * from unitType','计量单位报表');
if self.caption='部门资料' then
dataprint('select * from Department','部门资料报表');
if self.caption='员工资料' then
dataprint('select * from Employ','员工报表');
if self.caption='其它出入库类型' then
dataprint('select * from IOType','其它出入库类型报表');
if self.caption='收付款方式' then
dataprint('select * from PayType','收付款方式报表');
if self.caption='现金银行' then
dataprint('select * from bank','现金银行报表');
if self.caption='收入支出类别' then
dataprint('select * from IEtype','收入支出类别报表');
end;
procedure TinfoForm.TbdelClick(Sender: TObject);
begin
with DataE2 do
begin
if self.caption='供应商资料' then
if not CheckCode('I_InStore where VendorId=:VendorId',tblvendor.FieldByName('VENDORID').AsInteger) then
datadel(tblvendor);
if self.caption='客户资料' then
if not CheckCode('O_Outstore where ClientId=:ClientId',tblClient.FieldByName('ClientId').AsInteger) then
if tblClient.FieldByName('CLIENTID').AsInteger<>9 then
datadel(tblClient)
else Application.MessageBox('此客户不能删除!','提示',64);
if self.caption='部门资料' then
datadel(tblDept);
if self.caption='员工资料' then
if tblEmploy.FieldByName('EmployID').AsInteger<>1 then
datadel(tblEmploy)
else Application.MessageBox('此员工资料不能删除!','提示',64);
if self.caption='区域资料' then
datadel(tblSubArea);
if self.caption='客户类别' then
datadel(tblclienttype);
if self.caption='供应商类别' then
datadel(tblvdtype);
if self.caption='货品资料' then
begin
if not tblGoods.Eof then
with QueryTmp do
begin
Close;
SQL.Clear;
SQL.Add('select * from ONHAND where GoodsId =:GoodsId');
Parameters[0].Value:=tblGoods.FieldByName('GoodsId').AsInteger;
Open;
if Not Eof then
if (FieldByName('qty').AsFloat>0) or (FieldByName('qty1').AsFloat>0) then
begin
Application.MessageBox('这种商品已有库存,所以不能删除!','提示',64);
exit;
end;
end;
datadel(tblGoods);
end;
if self.caption='仓库资料' then
if tblstore.FieldByName('STOREID').AsInteger<>1 then
datadel(tblstore)
else Application.MessageBox('此仓库资料不能删除!','提示',64);
if self.caption='货品类别' then
datadel(tblType);
if self.caption='单位资料' then
datadel(tblUnit);
if self.caption='其它出入库类型' then
datadel(tbliotype);
if self.caption='收付款方式' then
datadel(tblpaytype);
if self.caption='现金银行' then
datadel(tblbank);
if self.caption='收入支出类别' then
datadel(tblIetype);
if self.caption='操作员及权限设置' then
datadel(tblOpr);
end;
end;
procedure TinfoForm.FormShow(Sender: TObject);
var
i,nCount:integer;
sSql:string;
begin
Tbdel.Visible:=Not dataE2.bBakAccSet;
Tbadd.Visible:=Not dataE2.bBakAccSet;
QueryId:=0;
with DataE2 do
begin
if self.caption='供应商资料' then
//tblTmp:=tblVendor;
queryId:=2;
if self.caption='客户资料' then
queryId:=3;
//tblTmp:=tblClient;
if self.caption='部门资料' then
tblTmp:=tblDept;
if self.caption='员工资料' then
tblTmp:=tblemploy;
if self.caption='区域资料' then
tblTmp:=tblSubArea;
if self.caption='客户类别' then
tblTmp:=tblclienttype;
if self.caption='供应商类别' then
tblTmp:=tblvdtype;
if self.caption='货品资料' then
begin
if not tblUnit.Active then tblUnit.open;
QueryId:=1;
end;
if self.caption='仓库资料' then
tblTmp:=tblstore;
if self.caption='货品类别' then
tblTmp:=tblType;
if self.caption='单位资料' then
tblTmp:=tblUnit;
if self.caption='其它出入库类型' then
tblTmp:=tblIOTYPE;
if self.caption='收付款方式' then
tblTmp:=tblpaytype;
if self.caption='现金银行' then
tblTmp:=tblbank;
if self.caption='收入支出类别' then
tblTmp:=tblIetype;
if self.caption='操作员及权限设置' then
tblTmp:=tblOpr;
if QueryId > 0 then
case QueryId of
1 : tblGoods.open;
2 : tblVendor.open;
3 : tblClient.open;
end
else begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -