📄 bas_vendor.pas
字号:
unit Bas_Vendor;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Outer, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin, Menus, DBCtrls, jpeg;
Type
TFrm_Bas_Vendor = Class(TFrm_Base_Outer)
AdoQry_MaInvendorCode: TStringField;
AdoQry_MaInvendorName: TStringField;
AdoQry_MaInvendorSHORTName: TStringField;
AdoQry_MaInvendorAdDRESS: TStringField;
AdoQry_MaInvendorEMAIL: TStringField;
AdoQry_MaInvendorTEL: TStringField;
AdoQry_MaInvendorFAX: TStringField;
AdoQry_MaInvendorBANK: TStringField;
AdoQry_MaInvendorBANKACCNO: TStringField;
AdoQry_MaInvendorTAXRATE_PERCENT: TIntegerField;
AdoQry_MaInvendorTAXNO: TStringField;
AdoQry_MaInvendorCONTACT: TStringField;
AdoQry_MaInvendorOWNER: TStringField;
AdoQry_MaInvendorCEO: TStringField;
AdoQry_MaInvendorCREATETIME: TDateTimeField;
AdoQry_MaInvendorMODIFYTIME: TDateTimeField;
AdoQry_MaInvendorREMArK: TStringField;
AdoQry_MaInvendorClass1: TStringField;
AdoQry_MaInvendorClass2: TStringField;
AdoQry_MaInvendorClass3: TStringField;
AdoQry_MaInvendorClass4: TStringField;
AdoQry_MaInvendorClass5: TStringField;
Label1: TLabel;
DBText1: TDBText;
AdoQry_MaincurrencyCode: TStringField;
AdoQry_MaincurrencyName: TStringField;
AdoQry_MaincurrencyCodeName: TStringField;
AdoQry_MaInvendorQFund: TFloatField;
AdoQry_MaInvendorCredit: TFloatField;
AdoQry_MaInvendorWebPage: TStringField;
AdoQry_MaInvendorUsable: TIntegerField;
AdoQry_MaInvendordisabletime: TDateTimeField;
AdoQry_MainNoInvoiceApKmCode: TStringField;
AdoQry_MainKmName: TStringField;
AdoQry_MainNoInvoiceApKmCodeName: TStringField;
AdoQry_MainInvoiceApKmCode: TStringField;
AdoQry_MainKmName1: TStringField;
AdoQry_MainInvoiceApKmCodeName: TStringField;
AdoQry_MainAreaCode: TStringField;
AdoQry_MainAreaName: TStringField;
AdoQry_MainInvoiceCancelMode: TIntegerField;
procedure Act_NewExecute(Sender: TObject);
procedure Act_ModifyExecute(Sender: TObject);
procedure DBGridEhGetCellParams(Sender: TObject; Column: TColumnEh;
AFont: TFont; var Background: TColor; State: TGridDrawState);
procedure Action3Execute(Sender: TObject);
private
{ Private declarations }
procedure initdbgrdehcolumn;
public
function SetDeleteSql:String;Override;
procedure initform(AdOConnection:TAdOConnection;ReadOnly:boolean);Override;
{ Public declarations }
end;
var
Frm_Bas_Vendor: TFrm_Bas_Vendor;
implementation
uses Bas_Vendor_D,Sys_Global;
{$R *.DFM}
procedure TFrm_Bas_Vendor.initform(AdOConnection:TAdOConnection;ReadOnly:boolean);
begin//SQL初始化
inherited;
SelectFromSQL:='Select Vendor.VendorCode,'+
'Vendor.VendorName,'+
'Vendor.VendorshortName,'+
'Vendor.VendorAddress,'+
'Vendor.Vendoremail,'+
'Vendor.VendorUsable,'+
'Vendor.Vendortel,'+
'Vendor.Vendorfax,'+
'Vendor.Vendorbank,'+
'Vendor.Vendorbankaccno,'+
'Vendor.Vendortaxrate_Percent,'+
'Vendor.Vendortaxno,'+
'Vendor.Vendorcontact,'+
'Vendor.Vendorowner,'+
'Vendor.Vendorceo,'+
'Vendor.Vendorcreatetime,'+
'Vendor.Vendormodifytime,'+
'Vendor.Vendordisabletime,'+
'Vendor.currencyCode,'+
'currency.currencyName,'+
'Vendor.currencyCode+'+''' '''+'+currency.currencyName as currencyCodeName, '+
'Vendor.VendorremArk,'+
'Vendor.VendorQFund,'+
'Vendor.VendorCredit,'+
'Vendor.VendorWebPage,'+
'Vendor.NoInvoiceApKmCode,'+
'Gl_AccountSubject.KmName,'+
'Vendor.NoInvoiceApKmCode+'' ''+Gl_AccountSubject.KmName as NoInvoiceApKmCodeName,'+
'Vendor.InvoiceApKmCode,'+
'g.KmName as KmName1,'+
'Vendor.InvoiceApKmCode+'' ''+g.KmName as InvoiceApKmCodeName,'+
'Vendor.AreaCode,'+
'Area.AreaName,'+
'Vendor.VendorClass1,'+
'Vendor.VendorClass2,'+
'Vendor.VendorClass3,'+
'Vendor.VendorClass4,'+
'Vendor.VendorClass5,'+
'Vendor.InvoiceCancelMode '+
'from Vendor '+
' left join currency on Vendor.currencyCode=currency.currencyCode '+
' left join Gl_AccountSubject on Vendor.NoInvoiceApKmCode=Gl_AccountSubject.KmCode '+
' left join Gl_AccountSubject g on Vendor.InvoiceApKmCode=g.KmCode'+
' left join Area on Vendor.AreaCode=Area.AreaCode';
//当前排序字段
OrderByFields:='VendorCode';
lbl_Order.Caption:='供应商代码';
GetData;
initdbgrdehcolumn;
//设置弹出窗体
Frm_Sys_Detail:=TFrm_Bas_Vendor_D.Create(Application);
end;
function TFrm_Bas_Vendor.SetDeleteSql: String;
begin
Result:='Delete Vendor Where VendorCode='''+AdoQry_Main.fieldbyname('VendorCode').AsString+'''';
end;
procedure TFrm_Bas_Vendor.initdbgrdehcolumn;
var
recCount,fieldCounts,i,j:Integer;
VendorClass:string;
begin
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select SysParamValueC from SysParam where left(SysParamCode,11)=''VendorClass'' ');
open;
recCount:=0;
while not eof do
begin
if fieldbyname('SysParamValueC').asstring<>'' then
inc(recCount)
else
//防止中间有一个为空的,如果有,则后面的都不理会
break;
next;
end;
First;
//记录dbgrid有多少个Column
fieldCounts:=dbgrideh.Columns.Count;
for i:=1 to recCount do
begin
VendorClass:='VendorClass'+inttostr(i);
//遍历所有字段,而不是指定字段的序号
for j:=0 to fieldCounts-1 do
begin
if lowercase(dbgrideh.columns[j].fieldName)=VendorClass then
begin
dbgrideh.columns[j].Title.Caption:=fieldbyname('SysParamValueC').asstring;
next;
break;
end;
end;
end;
//删除不用的字段
for i:=i to 5 do
begin
VendorClass:='VendorClass'+inttostr(i);
for j:=0 to fieldCounts-1 do
begin
if lowercase(dbgrideh.columns[j].fieldName)=VendorClass then
begin
dbgrideh.columns.delete(j);
break;
end;
end;
end;
end;
end;
procedure TFrm_Bas_Vendor.Act_NewExecute(Sender: TObject);
begin
inherited;
GetData;
end;
procedure TFrm_Bas_Vendor.Act_ModifyExecute(Sender: TObject);
var
VendorCode:string;
begin
VendorCode:=AdoQry_Main.fieldbyname('VendorCode').asstring;
inherited;
GetData;
AdoQry_Main.First;
AdoQry_Main.locate('VendorCode',VendorCode,[]);
end;
procedure TFrm_Bas_Vendor.DBGridEhGetCellParams(Sender: TObject;
Column: TColumnEh; AFont: TFont; var Background: TColor;
State: TGridDrawState);
begin
inherited;
if AdoQry_Main.fieldbyname('VendorUsable').AsString='0' Then
AFont.Color:=ClRed;
if (gdselected in state) then
begin
Background:=clnavy;
afont.color:=clwindow;
end;
end;
procedure TFrm_Bas_Vendor.Action3Execute(Sender: TObject);
begin
inherited;
if AdoQry_Main.fieldbyname('VendorUsable').asstring='1' then
begin
if DispInfo('确认该供应商无效吗?',2)='y' then
begin
try
AdoQry_Main.edit;
AdoQry_Main.fieldbyname('VendorUsable').asstring:='0';
AdoQry_Main.post;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('update Vendor '+
' set '+
' VendorUsable=0,'+
' Vendordisabletime='''+formatdatetime('yyyy.mm.dd hh:mm:ss',now)+''''+
' where VendorCode='''+AdoQry_Main.fieldbyname('VendorCode').asstring+'''');
execsql;
end
except
begin
DispInfo('更改失败,请重试!',1);
abort;
end;
end;
end;
end
else
begin
if DispInfo('确认该供应商有效吗?',2)='y' then
begin
try
AdoQry_Main.edit;
AdoQry_Main.fieldbyname('VendorUsable').asstring:='1';
AdoQry_Main.post;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('update Vendor set VendorUsable=1,Vendordisabletime=null where VendorCode='''+AdoQry_Main.fieldbyname('VendorCode').asstring+'''');
execsql;
end
except
begin
DispInfo('更改失败,请重试!',1);
abort;
end;
end;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -