📄 inv_undoclosebook.pas
字号:
unit Inv_UndoCloseBook;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Dialog, Db, AdODB, StdCtrls;
Type
TFrm_Inv_UndoCloseBook = Class(TFrm_Base_Dialog)
Label1: TLabel;
Lbl_Month: TLabel;
Lbl_State: TLabel;
procedure btn_okClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btn_CancelClick(Sender: TObject);
private
{ Private declarations }
PriorMonth,NextMonth:String;
public
{ Public declarations }
procedure SetDBConnect(AdOConnection:TAdOConnection); Override;
end;
var
Frm_Inv_UndoCloseBook: TFrm_Inv_UndoCloseBook;
implementation
uses Sys_Global;
{$R *.DFM}
procedure TFrm_Inv_UndoCloseBook.btn_okClick(Sender: TObject);
var
MonthStr:String;
begin
inherited;
if Lbl_State.Caption<>'' then
begin
Close;
Exit;
end
else if DispInfo('确认取消该月的结帐吗?',2)='y' then
begin
btn_ok.Enabled:=False;
btn_Cancel.Enabled:=False;
{2、目前InvInBill、InvOutBill中最大日期的月份与当前已结帐月份进行比较
如果比已结帐月份大两个月,则不允许取消结帐,错误提示“!”
例如:现在已经有2001.09的出入库单据了,只能取消2001.08的结帐,而不能取消2001.07的结帐}
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select Max(InvBillMonth) As MaxMonth From InvInBill';
AdoQry_Tmp.Open;
MonthStr:=AdoQry_Tmp.fieldbyname('MaxMonth').AsString;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select Max(InvBillMonth) As MaxMonth From InvOutBill';
AdoQry_Tmp.Open;
if MonthStr<AdoQry_Tmp.fieldbyname('MaxMonth').AsString then
MonthStr:=AdoQry_Tmp.fieldbyname('MaxMonth').AsString;
if Lbl_Month.Caption<FormatDateTime('yyyy.mm',IncMonth(StrToDateTime(MonthStr+'.01'),-1)) then
begin
DispInfo('跨月过多,不允许取消结帐!',3);
Close;
//Exit;
end;
{AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select Count(*) As CountTotal From InvInBill'
+' Where InvBillWHChck=1'
+' And InvBillMonth='''+NextMonth+'''';
AdoQry_Tmp.Open;
if AdoQry_Tmp.fieldbyname('CountTotal').AsInteger<>0 then
begin
DispInfo('下月已经有业务发生,该月不允许取消结帐!',3);
Close;
Exit;
end;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select Count(*) As CountTatol From InvOutBill'
+' Where InvBillWHChck=1'
+' And InvBillMonth='''+NextMonth+'''';
AdoQry_Tmp.Open;
if AdoQry_Tmp.fieldbyname('CountTatol').AsInteger<>0 then
begin
DispInfo('下月已经有业务发生,该月不允许取消结帐!',3);
Close;
Exit;
end;}
DBConnect.beginTrans;
try
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Update InvStatus Set InvStatus='''+PriorMonth+''''
+' Where InvStatusName=''clsperiod''';
AdoQry_Tmp.ExecSQL;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Update InvStatus Set InvStatus=1'
+' Where InvStatusName='''+FormatDateTime('yymm',StrToDateTime(Lbl_Month.Caption+'.01'))+'''';
AdoQry_Tmp.ExecSQL;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Delete CurrentPeriodInv';
AdoQry_Tmp.ExecSQL;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Insert CurrentPeriodInv (WHCode,WhPositionCode'
+',ItemCode,OnhandInv)'
+' Select WHPMonthSum.WHCode,WHPMonthSum.WhPositionCode'
+',WHPMonthSum.ItemCode,WHPMonthSum.InvBlncQty'
+' From WHPMonthSum'
+' Join WhPosition On WHPMonthSum.WHCode=WhPosition.WHCode'
+' And WHPMonthSum.WhPositionCode=WhPosition.WhPositionCode'
+' Where WhPosition.WhPositionType=0'
+' And WHPMonthSum.InvMonth='''+Lbl_Month.Caption+'''';
AdoQry_Tmp.ExecSQL;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Insert CurrentPeriodInv (WHCode,WhPositionCode'
+',ItemCode,FreezeInv)'
+' Select WHPMonthSum.WHCode,WHPMonthSum.WhPositionCode'
+',WHPMonthSum.ItemCode,WHPMonthSum.InvBlncQty'
+' From WHPMonthSum'
+' Join WhPosition On WHPMonthSum.WHCode=WhPosition.WHCode'
+' And WHPMonthSum.WhPositionCode=WhPosition.WhPositionCode'
+' Where WhPosition.WhPositionType=2'
+' And WHPMonthSum.InvMonth='''+Lbl_Month.Caption+'''';
AdoQry_Tmp.ExecSQL;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Insert CurrentPeriodInv (WHCode,WhPositionCode'
+',ItemCode,WasterInv)'
+' Select WHPMonthSum.WHCode,WHPMonthSum.WhPositionCode'
+',WHPMonthSum.ItemCode,WHPMonthSum.InvBlncQty'
+' From WHPMonthSum'
+' Join WhPosition On WHPMonthSum.WHCode=WhPosition.WHCode'
+' And WHPMonthSum.WhPositionCode=WhPosition.WhPositionCode'
+' Where WhPosition.WhPositionType=3'
+' And WHPMonthSum.InvMonth='''+Lbl_Month.Caption+'''';
AdoQry_Tmp.ExecSQL;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Insert CurrentPeriodInv (WHCode,WhPositionCode'
+',ItemCode,OnShipInv)'
+' Select WHPMonthSum.WHCode,WHPMonthSum.WhPositionCode'
+',WHPMonthSum.ItemCode,WHPMonthSum.InvBlncQty'
+' From WHPMonthSum'
+' Join WhPosition On WHPMonthSum.WHCode=WhPosition.WHCode'
+' And WHPMonthSum.WhPositionCode=WhPosition.WhPositionCode'
+' Where WhPosition.WhPositionType=4'
+' And WHPMonthSum.InvMonth='''+Lbl_Month.Caption+'''';
AdoQry_Tmp.ExecSQL;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Insert InvParam (InvParamCode,InvParamName'
+',InvValueC)'
+' Values('
+' ''UndoClsPeriodRecord'''
+',''取消结帐记录'''
+',''取消结帐月份:'+Lbl_Month.Caption
+'.取消结帐日期:''+Convert(varChAr(10),GetDate())+'+'''.操作人:'+UserCode+''''
+')';
AdoQry_Tmp.ExecSQL;
DBConnect.CommitTrans;
Lbl_State.Caption:='该月结帐已经取消!';
except
DBConnect.RollBackTrans;
Lbl_State.Caption:='取消结帐失败!';
btn_ok.Enabled:=True;
end;
btn_Cancel.Enabled:=True;
end;
end;
procedure TFrm_Inv_UndoCloseBook.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
Action:=caFree;
end;
procedure TFrm_Inv_UndoCloseBook.btn_CancelClick(Sender: TObject);
begin
inherited;
Close
end;
procedure TFrm_Inv_UndoCloseBook.SetDBConnect(
AdOConnection: TAdOConnection);
begin
inherited;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select InvStatus From InvStatus'
+' Where InvStatusName=''clsperiod''';
AdoQry_Tmp.Open;
Lbl_Month.Caption:=FormatFloat('0000.00',AdoQry_Tmp.fieldbyname('InvStatus').AsFloat);
PriorMonth:=FormatDateTime('yyyy.mm',IncMonth(StrToDateTime(
Lbl_Month.Caption+'.01'),-1));
NextMonth:=FormatDateTime('yyyy.mm',IncMonth(StrToDateTime(
Lbl_Month.Caption+'.01'),1));
Lbl_State.Caption:='';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -