📄 sal_enter_salecontracth.pas
字号:
unit Sal_Enter_SaleContractH;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Entry_Head, Menus, Db, ActnList, AdODB, Grids, DBGridEh, StdCtrls,
ExtCtrls, ComCtrls, ToolWin, jpeg, ExtPrintReport;
Type
TFrm_Sal_Enter_SaleContractH = Class(TFrm_Base_Entry_Head)
AdoQry_HeadSlcNo: TStringField;
AdoQry_HeadCustomerCode: TStringField;
AdoQry_HeadCurrencyCode: TStringField;
AdoQry_HeadTaxRate_Percent: TFloatField;
AdoQry_HeadSlcDate: TDateTimeField;
AdoQry_HeadRemArk: TStringField;
AdoQry_HeadCreateDate: TDateTimeField;
AdoQry_HeadCreateEmployeeCode: TStringField;
AdoQry_HeadEditDate: TDateTimeField;
AdoQry_HeadEdItEmployeeCode: TStringField;
AdoQry_HeadCustomerName: TStringField;
AdoQry_HeadCurrencyName: TStringField;
AdoQry_HeadCurrencyFalg: TStringField;
procedure Act_DeleteExecute(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);Override;
end;
var
Frm_Sal_Enter_SaleContractH: TFrm_Sal_Enter_SaleContractH;
implementation
uses Sal_Enter_SaleContract,Sys_Global;
{$R *.DFM}
{ TFrm_Pm_Pc_Entry_H }
procedure TFrm_Sal_Enter_SaleContractH.InitForm(AdOConnection: TAdOConnection;
ReadOnly: Boolean);
begin
if ReadOnly then
begin
Caption:='销售价格表';
Pnl_Title.Caption:='销售价格表查询';
end
else
begin
Caption:='销售价格表';
Pnl_Title.Caption:='销售价格表';
end;
Application.ProcessMessages;
inherited;
SelectFromSQL:=' Select Sa_SaleContract.* ,Customer.CustomerName,'
+' Currency.CurrencyName, '
+' Sa_SaleContract.CurrencyCode+'' ''+Currency.CurrencyName As CurrencyFalg '
+' From Sa_SaleContract '
+' Left Join Customer '
+' On Sa_SaleContract.CustomerCode= Customer.CustomerCode '
+' Left Join Currency '
+' On Sa_SaleContract.CurrencyCode=Currency.CurrencyCode ';
Condition := ' Sa_SaleContract.SlcNo in (Select Distinct SlcNo From Sa_SaleContractLine Where Linestatus=0 )';
OrderByFields:=' CustomerCode,SlcNo ';
GetData;
Frm_Entry_Body:=TFrm_Sal_Enter_SaleContract.Create(Self);
end;
procedure TFrm_Sal_Enter_SaleContractH.Act_DeleteExecute(Sender: TObject);
var
SqlText:String;
AdoQuery:TAdoQuery;
IsPriceRequestPass : Integer; //销售价格是否需要批准 0:不需要 1:需要
begin
inherited;
if AdoQry_Head.RecordCount=0 then exit;
If (DispInfo('确认真的要删除这张销售价格单吗?',2)='y') Then
begin
ExecuteSql(AdoQry_Tmp,'Select * from Sa_SalParam'
+' where SalParamCode=''IsPriceRequestPass''',0);
IsPriceRequestPass := AdoQry_Tmp.fieldbyname('SalParamValueN').AsInteger;
SqlText:=' Select * From Sa_SaleContract where '
+' SlcNo in ( Select Distinct SlcNo from Sa_SaleContractLine where (LineStatus<>1))'
+' And SlcNo='''+AdoQry_Head.fieldbyname('SlcNo').AsString+'''';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text :=SqlText;
AdoQry_Tmp.Open;
if ( AdoQry_Tmp.Eof )and (IsPriceRequestPass=1) then
begin
DispInfo('有销售价格表行记录处于非准备状态,不能删除',3);
Abort;
end
else
begin
AdoQuery:=TAdoQuery.Create(nil);
AdoQuery.Connection := DbConnect;
DbConnect.beginTrans;
try
Sqltext:='Select * From Sa_SaleContractLine where SlcNo='''+AdoQry_Head.fieldbyname('SlcNo').AsString+'''';
AdoQuery.Close;
AdoQuery.SQL.clear;
AdoQuery.SQL.Text:=SqlText;
AdoQuery.Open ;
AdoQuery.First;
While not AdoQuery.Eof do
begin
saveSalContractLineHistory(Dbconnect,AdoQuery.fieldbyname('SlcNo').AsString,AdoQuery.fieldbyname('SlcLineNo').AsInteger,userCode,2);
AdoQuery.Next;
end;
Sqltext:='Delete Sa_SaleContractLine where SlcNo='''+AdoQry_Head.fieldbyname('SlcNo').AsString+'''';
ExecuteSql(AdoQry_Tmp,SqlText,1);
saveSalContractHistory(dbconnect,AdoQry_Head.fieldbyname('SlcNo').AsString,userCode,2);
Sqltext:='Delete Sa_SaleContract where SlcNo='''+AdoQry_Head.fieldbyname('SlcNo').AsString+'''';
ExecuteSql(AdoQry_Tmp,SqlText,1);
AdoQuery.Free;
DbConnect.CommitTrans;
AdoQry_Head.Delete;
except
if dbconnect.InTransaction then
DbConnect.RollBackTrans;
end;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -