📄 inv_backpricedefine.pas
字号:
unit Inv_BackPriceDefine;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Outer, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin, DBCtrls;
Type
TFrm_Inv_BackPriceDefine = Class(TFrm_Base_Outer)
Label4: TLabel;
Label3: TLabel;
DBText1: TDBText;
AdoQry_tmp1: TAdoQuery;
AdoQry_MainInvMonth: TStringField;
AdoQry_MainWHCode: TStringField;
AdoQry_MainItemCode: TStringField;
AdoQry_MainPrice: TFloatField;
AdoQry_MainRemArk: TStringField;
AdoQry_MainUomName: TStringField;
AdoQry_MainInvoutqty: TFloatField;
procedure Act_FilterExecute(Sender: TObject);
procedure Act_SaveExecute(Sender: TObject);
procedure Act_LookExecute(Sender: TObject);
private
{ Private declarations }
public
procedure initform(AdOConnection:TAdOConnection;ReadOnly:boolean);Override;
{ Public declarations }
end;
var
Frm_Inv_BackPriceDefine: TFrm_Inv_BackPriceDefine;
implementation
uses Inv_BackPriceDefine_D,Inv_BackPriceDefine_C,Sys_Global,Inv_JournalQry;
{$R *.DFM}
procedure TFrm_Inv_BackPriceDefine.initform(AdOConnection:TAdOConnection;ReadOnly:boolean);
begin
inherited;
tlbtn_Delete.Action :=act_Save;
PriceFields:='Price,';
OrderByFields:='whCode,ItemCode,';
lbl_Order.Caption:='仓库、物料';
Frm_Inv_BackPriceDefine_C:=TFrm_Inv_BackPriceDefine_C.Create(Application);
Frm_Inv_BackPriceDefine_C.InitForm(AdoQry_Main.Connection,'','');
Frm_Sys_Detail:=TFrm_Inv_BackPriceDefine_D.Create(Application);
act_filter.Execute ;
if ReadOnly then
begin
act_Save.Enabled :=False;
act_Modify.Enabled :=False;
end
else
begin
act_Save.Enabled :=True;
act_Modify.Enabled :=True;
end;// getdata;
end;
procedure TFrm_Inv_BackPriceDefine.Act_FilterExecute(Sender: TObject);
begin
if Frm_Inv_BackPriceDefine_C.ShowModal=mrOk then
begin
lbl_Condition.Caption :=Frm_Inv_BackPriceDefine_C.medt_Month.Text ;
if Frm_Inv_BackPriceDefine_C.onlyQuery then
begin
act_Modify.Enabled :=False;
act_Save.Enabled :=False;
end
else
begin
act_Modify.Enabled :=True;
act_Save.Enabled :=True;
end;
if Frm_Inv_BackPriceDefine_C.medt_Month.Text<Frm_Inv_BackPriceDefine_C.bigMonth then
begin
SelectFromSQL:=
'select i.InvMonth,i.WHCode+'''+' '+'''+w.whName whCode,'+
'i.ItemCode+'''+' '+'''+it.ItemName ItemCode,'+
' Price,b.RemArk,UomName,i.Invoutqty'+
' from InvMonthSum i'+
' left join (select Item.ItemCode,Uom.UomName from Item,Uom where Item.UomCode=Uom.UomCode) Uom'+
' on i.ItemCode=Uom.ItemCode'+
' left join Warehouse w on i.whCode=w.whCode'+
' left join Item it on it.ItemCode=i.ItemCode'+
' left join BackPrice b '+
' on i.InvMonth=b.InvMonth and i.whCode=b.whCode and i.ItemCode=b.ItemCode ';
condition:='i.InvMonth='''+Frm_Inv_BackPriceDefine_C.medt_Month.Text+'''';
end
else
if Frm_Inv_BackPriceDefine_C.medt_Month.Text=Frm_Inv_BackPriceDefine_C.bigMonth then
begin
SelectFromSQL:=
'select i.InvMonth,i.WHCode+'''+' '+'''+w.whName whCode,'+
'i.ItemCode+'''+' '+'''+it.ItemName ItemCode,'+
' Price,b.RemArk,UomName,i.Invoutqty'+
' from InvMonthSum i'+
' left join '+
'(select InvOutBill.whCode,InvOutBillline.ItemCode,sum(InvBillqty) as qty '+
' from InvOutBill,InvOutBillline '+
' where InvOutBill.InvBillid=InvOutBillline.InvBillid and InvOutBill.InvBillMonth='''+Frm_Inv_BackPriceDefine_C.medt_Month.Text+''''+
' and ((InvOutBill.BillTypeCode in(''0201'',''0203'',''0204'') and InvOutBill.InvBillWhChck=1) or InvOutBill.BillTypeCode=''0299'')'+
' group by whCode,ItemCode) a '+
' on i.whCode=a.whCode and i.ItemCode=a.ItemCode '+
' left join (select Item.ItemCode,Uom.UomName from Item,Uom where Item.UomCode=Uom.UomCode) Uom'+
' on i.ItemCode=Uom.ItemCode'+
' left join Warehouse w on i.whCode=w.whCode'+
' left join Item it on it.ItemCode=i.ItemCode'+
' left join BackPrice b '+
' on i.InvMonth=b.InvMonth and i.whCode=b.whCode and i.ItemCode=b.ItemCode ';
condition:='i.InvMonth='''+Frm_Inv_BackPriceDefine_C.medt_Month.Text+''''+
' and i.InvLMQty+InvInqty=0 and i.Invoutqty<>0 and a.qty<>0 ';
end;
getdata;
end;
end;
procedure TFrm_Inv_BackPriceDefine.Act_SaveExecute(Sender: TObject);
var
Bookm:tBookmArk;
sqltext:string;
tmp_Cursor:tcursor;
begin
inherited;
tmp_Cursor:=Screen.Cursor;
Screen.cursor:=crHourGlass;
with AdoQry_tmp do
begin
Close;
sql.text:='Delete from BackPrice ';
execsql;
end;
Bookm:=AdoQry_Main.GetBookmArk ;
AdoQry_Main.DisableControls ;
try
with AdoQry_Main do
begin
First;
while not eof do
begin
if fieldbyname('Price').asfloat<>0 then
begin
AdoQry_tmp.Close ;
sqlText:='insert into BackPrice (InvMonth,WHCode,ItemCode,Price,RemArk) Values ('+
''''+lbl_Condition.Caption+''','+
''''+getCode(fieldbyname('whCode').asstring)+''','+
''''+getCode(fieldbyname('ItemCode').asstring)+''','+
''''+fieldbyname('Price').asstring+''','+
''''+fieldbyname('remArk').asstring+' '')' ;
AdoQry_tmp.sql.Add(sqltext);
AdoQry_tmp.ExecSQL ;
end;
next;
end;
end;
except
DispInfo('数据保存失败,请稍后再试。',3);
end;
AdoQry_Main.GotoBookmArk(Bookm);
AdoQry_Main.EnableControls ;
Screen.Cursor :=tmp_Cursor;
act_Save.Enabled:=False;
Act_Modify.Enabled:=False;
DBGridEh.Enabled:=False;
end;
procedure TFrm_Inv_BackPriceDefine.Act_LookExecute(Sender: TObject);
begin
if (not AdoQry_Main.IsEmpty)and(Frm_Inv_JournalQry=nil) then
begin
Frm_Inv_JournalQry:=TFrm_Inv_JournalQry.Create(Self);
Frm_Inv_JournalQry.SetUserParam('User','','','','','');
Frm_Inv_JournalQry.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
Frm_Inv_JournalQry.InitForm(DBConnect,True);
Frm_Inv_JournalQry.SetFormParam('','','',Lbl_Condition.Caption
,getCode(AdoQry_Main.fieldbyname('ItemCode').AsString)
,getCode(AdoQry_Main.fieldbyname('WHCode').AsString));
end
else
if (not AdoQry_Main.IsEmpty)and(Frm_Inv_JournalQry<>nil) then
begin
Frm_Inv_JournalQry.Show ;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -