📄 pm_pc_entry_h.pas
字号:
unit Pm_Pc_Entry_H;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Entry_Head, Menus, Db, ActnList, AdODB, Grids, DBGridEh, StdCtrls,
ExtCtrls, ComCtrls, ToolWin,Base_Entry_Body, jpeg, ExtPrintReport;
Type
TFrm_Pm_Pc_Entry_H = Class(TFrm_Base_Entry_Head)
AdoQry_HeadPcNo: TStringField;
AdoQry_HeadVendorCode: TStringField;
AdoQry_HeadPCTaxRate_Percent: TIntegerField;
AdoQry_HeadRemArk: TStringField;
AdoQry_HeadVendorName: TStringField;
AdoQry_HeadCurrencyCode: TStringField;
AdoQry_HeadCurrencyName: TStringField;
AdoQry_HeadPCDate: TDateTimeField;
procedure Act_FilterExecute(Sender: TObject);
procedure Act_DeleteExecute(Sender: TObject);
procedure Act_CopyExecute(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);Override;
end;
var
Frm_Pm_Pc_Entry_H: TFrm_Pm_Pc_Entry_H;
implementation
uses Pm_Pc_Entry_B,Pm_Pc_Entry_C, Sys_Global, Pm_Pc_Entry_B1;
{$R *.DFM}
{ TFrm_Pm_Pc_Entry_H }
procedure TFrm_Pm_Pc_Entry_H.InitForm(AdOConnection: TAdOConnection;
ReadOnly: Boolean);
begin
if ReadOnly then
begin
Caption:='采购价格表查询';
Pnl_Title.Caption:='采购价格表查询';
act_Copy.Enabled:=False;
act_Copy.Visible:=False;
// DBGridEh.OnDblClick:=nil;
end
else
begin
Caption:='采购价格表';
Pnl_Title.Caption:='采购价格表';
end;
inherited;
selectfromsql:='Select pc.PcNo'
+',pc.VendorCode'
+',pc.PCDate'
+',Vendor.VendorName'
+',pc.PCTaxRate_Percent'
+',pc.CurrencyCode'
+',Currency.CurrencyName'
+',pc.RemArk'
+' From pc Join Vendor On pc.VendorCode=Vendor.VendorCode'
+' left Join Currency On pc.CurrencyCode=Currency.CurrencyCode';
OrderByFields:='VendorCode ';
if not ReadOnly then
begin
Frm_Sys_Condition:=TFrm_Pm_Pc_Entry_C.Create(Self);
Act_Filter.Execute;
if Frm_Sys_Condition.ModalResult=mrCancel then
begin
selectfromsql:='Select top 0 pc.PcNo'
+',pc.VendorCode'
+',pc.PCDate'
+',Vendor.VendorName'
+',pc.PCTaxRate_Percent'
+',pc.CurrencyCode'
+',Currency.CurrencyName'
+',pc.RemArk'
+' From pc Join Vendor On pc.VendorCode=Vendor.VendorCode'
+' left Join Currency On pc.CurrencyCode=Currency.CurrencyCode';
end;
end;
//conditionuserDefine:=condition;
GetData;
Frm_Sys_Condition:=nil;
Frm_Entry_Body:=TFrm_Pm_Pc_Entry_B.Create(Self);
end;
procedure TFrm_Pm_Pc_Entry_H.Act_FilterExecute(Sender: TObject);
begin
SelectFromSQL:='';
SelectFromSQL:='Select pc.PcNo'
+',pc.VendorCode'
+',pc.PCDate'
+',Vendor.VendorName'
+',pc.PCTaxRate_Percent'
+',pc.CurrencyCode'
+',Currency.CurrencyName'
+',pc.RemArk'
+' From pc Join Vendor On pc.VendorCode=Vendor.VendorCode'
+' Join Currency On pc.CurrencyCode=Currency.CurrencyCode';
inherited;
end;
procedure TFrm_Pm_Pc_Entry_H.Act_DeleteExecute(Sender: TObject);
var
SqlText:String;
IsPriceRequestPass : Integer;
begin
inherited;
If (AdoQry_Head.Eof) And (AdoQry_Head.Bof) Then
Exit;
If (DispInfo('确认真的要删除选定采购价格单吗',2)<>'y') Then exit;
{SqlText:=' Select * from Po where PcNo= '''+AdoQry_Head.fieldbyname('PcNo').asstring+'''';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text := SqlText;
AdoQry_Tmp.Open ;
If not AdoQry_Tmp.Eof then
begin
DispInfo('不能删除采购价格单号为:'+AdoQry_Head.fieldbyname('PcNo').AsString+' 已下采购单的合同!',3);
abort;
end;}
ExecuteSql(AdoQry_Tmp,'Select * from PmParam '
+' where PmParamCode=''ISPriceRequestPass''',0);
IsPriceRequestPass := AdoQry_Tmp.fieldbyname('PmParamValueN').AsInteger;
SqlText:=' Select * from PcLine '
+' Where PclineStatus=1 '
+' and Pcno='''+AdoQry_Head.fieldbyname('PcNo').asstring+''' ';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text := SqlText;
AdoQry_Tmp.Open ;
If (AdoQry_Tmp.RecordCount>0) and (IsPriceRequestPass=1) then
begin
DispInfo('不能删除采购价格单号为:'+AdoQry_Head.fieldbyname('PcNo').AsString+' 已下达的采购价格单!',3);
abort;
end;
try
DbConnect.beginTrans ;
//将要删除的记录写入到历史档
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Insert PcHistory'
+'(PcNo,VendorCode,PCTaxRate_Percent,RemArk,CurrencyCode,PCDate'
+',ChgEmployeeCode,ChgTime,ChgType)'
+' Select PcNo,VendorCode,PCTaxRate_Percent,RemArk,CurrencyCode,PCDate'
+','''+UserCode+''''
+',getdate()'
+','''+'删除'+''' '
+' From Pc where PcNo='''+AdoQry_Head.fieldbyname('PcNo').AsString+'''';
AdoQry_Tmp.ExecSQL;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Insert PcLineHistory'
+'(PcNo,ItemCode,PcTaxPrice,PcNoTaxPrice,PcStArtDate,PcendDate'
+',PcStArtQty,PcendQty,PcPriceType,PCReferencedPrice,PcLineStatus'
+',ChgEmployeeCode,ChgTime,ChgType)'
+' Select PcNo,ItemCode,PcTaxPrice,PcNoTaxPrice,PcStArtDate,PcendDate'
+',PcStArtQty,PcendQty,PcPriceType,PCReferencedPrice,0'
+','''+UserCode+''''
+',getdate() '
+','''+'删除'+''''
+' From PcLine where PcNo='''+AdoQry_Head.fieldbyname('PcNo').AsString+'''';
AdoQry_Tmp.ExecSQL;
//---end
SqlText:=' Delete PcLine '
+' Where (Not Exists(Select * from PcLine PcLine1 '
+' Where PcLine1.PcNO=Pcline.PcNO and PcLine1.PclineStatus=1 ))'
+' and Pcno='''+AdoQry_Head.fieldbyname('PcNo').asstring+''' ';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text := SqlText;
AdoQry_Tmp.ExecSQL;
SqlText:=' Delete Pc '
+' Where (Not Exists(Select * from PcLine '
+' Where Pc.PcNO=PcLine.PcNo And PclineStatus=1 ))'
+' and Pcno='''+AdoQry_Head.fieldbyname('PcNo').asstring+''' ';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text := SqlText;
AdoQry_Tmp.ExecSQL;
DbConnect.CommitTrans;
except
DbConnect.RollBackTrans;
end;
getdata;
end;
procedure TFrm_Pm_Pc_Entry_H.Act_CopyExecute(Sender: TObject);
begin
inherited;
if AdoQry_Head.RecordCount=0 then exit;
Frm_Pm_Pc_Entry_B1:=TFrm_Pm_Pc_Entry_B1.Create(self);
Frm_Pm_Pc_Entry_B1.SetUserParam(Param1,Param2,Param3,Param4,Param5,Param6);
Frm_Pm_Pc_Entry_B1.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
Frm_Pm_Pc_Entry_B1.InitForm(DBConnect,'Edit',AdoQry_Head);
Frm_Pm_Pc_Entry_B1.ShowModal;
Frm_Pm_Pc_Entry_B1.Release;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -