📄 fmtsbegstocku.pas
字号:
unit FMTsBegstockU;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, FMBizMulU, DB, Menus, ADODB, Grids, DBGrids, dxDBTLCl, dxGrClms,
dxDBGrid, dxTL, dxDBCtrl, dxCntner, DBCtrls, ComCtrls, StdCtrls, Mask,
Buttons, ExtCtrls;
type
TFMTsBegstock = class(TFMBizMul)
cdsDetailfBuyPrice: TFloatField;
procedure btnQueryClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btnAddClick(Sender: TObject);
procedure btnPrintClick(Sender: TObject);
procedure btnCheckClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FMTsBegstock: TFMTsBegstock;
implementation
{$R *.dfm}
uses RepTsLostU ;
procedure TFMTsBegstock.btnQueryClick(Sender: TObject);
begin
PTableName :='ts_begstock_head';
inherited;
end;
procedure TFMTsBegstock.FormCreate(Sender: TObject);
begin
inherited;
aPriceType := 1 ;
aNumType :=1 ;
aMainTable :='ts_begstock_head';
aDetailTable :='ts_begstock_detail';
aKeyField :='fBillId';
aBillNo :='fBillNo';
Style :='BS';
end;
procedure TFMTsBegstock.btnAddClick(Sender: TObject);
begin
Qry.Active :=false ;
Qry.SQL.Text :='select count(*) from ts_begstock_head where fState<>2 ';
Qry.Open ;
if Qry.Fields[0].AsInteger >0 then
begin
MessageBox(handle,'期初库存单只能有一张.','提示',MB_OK+MB_ICONWARNING);
exit ;
end ;
inherited;
end;
procedure TFMTsBegstock.btnPrintClick(Sender: TObject);
begin
inherited;
if Application.FindComponent('RepTsLost')=nil then
RepTsLost:=TRepTsLost.create(self);
RepTsLost.Caption :=Self.Caption ;
RepTsLost.idtCompany.Caption :=aCompany ;
RepTsLost.idtTitle.Caption :=Self.Caption;
RepTsLost.cdsRep.Active :=false ;
RepTsLost.cdsRep.CommandText :='SELECT a.*, b.fProductId, b.fqty, c.fProductNo, c.fProductName, c.fSpec, c.fSaleUnit, b.fBuyPrice,u.fusername '
+' FROM ts_begstock_head AS a, ts_begstock_detail AS b, ts_item AS c, ts_User AS u '
+' WHERE a.fBillId=b.fBillId And b.fProductId=c.fProductId '
+' and a.fcreuser=u.fuserno and a.fBillId in '+GetPrintList
+' order by a.fbillid,b.fProductId ' ;
RepTsLost.cdsRep.Active :=true ;
RepTsLost.Show ;
RepTsLost.Visible :=false ;
RepTsLost.QRep.Preview ;
end;
procedure TFMTsBegstock.btnCheckClick(Sender: TObject);
var
strBillId,strBegDate,strEndDate :string ;
begin
inherited;
//往月结表写 期初库存
strBillId :=GetNextId('tb_month','fId');
strBegDate :=FormatDateTime('YYYY'+DateSeparator+'MM'+DateSeparator+'DD',Date());
strEndDate :=FormatDateTime('YYYY'+DateSeparator+'MM'+DateSeparator+'DD',Date()+1);
QrySQL.Active :=false ;
QrySQL.SQL.Text :='insert into tb_month_detail(fid,fProductid,fQty,fAmt)'
+' select '+strBillId+',fProductid,fQty,fQty*fBuyPrice from ts_begstock_detail '
+' where fBillId='+cdsMain.FieldByName(aKeyField).AsString;
QrySQL.ExecSQL ;
QrySQL.Active :=false ;
QrySQL.SQL.Text :='insert into tb_month_detail(fid,fProductid,fQty,fAmt)'
+' select '+strBillId+',fProductid,0,0 from ts_item '
+' where fProductid not in (select fProductid from tb_month_detail where fId='+strBillId+')' ;
QrySQL.ExecSQL ;
QrySQL.Active :=false ;
QrySQL.SQL.Text :='insert into tb_month(fid,fBegDate,fEndDate,fCreUser,fState,fMemo,fFFU)'
+' values('+strBillId+','+#39+strBegDate+#39+','+#39+strEndDate+#39+','+#39+aUserId+#39+',1,0,0)';
QrySQL.ExecSQL ;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -