📄 oldgatheringfrm.pas
字号:
with Node do begin
ImageIndex :=4;
SelectedIndex :=4;
StateIndex :=-1;
end;
end else begin
lbTransfer.Caption :='(未过帐)';
lbTransfer.Font.Color :=clBlue;
with Node do begin
ImageIndex :=23;
SelectedIndex :=23;
StateIndex :=-1;
end;
end;
{str :=PString(Node.Data)^;
str :='DepartId=' + str;}
with cdsOldGathering do begin
if not Active then Open;
Filtered :=false;
Filter := str;
Filtered := true;
if IsEmpty then lbTransfer.Caption :='';
end;
end;
procedure TFmOldGathering.dbgOldGatheringEditButtonClick(Sender: TObject);
var sFieldName, sRet1, sRet2 : string;
begin
if dbgOldGathering.SelectedField = nil then exit;
sFieldName := LowerCase(dbgOldGathering.SelectedField.FieldName);
if sFieldName = 'custno' then begin
sRet1 := cdsOldGatheringCustNo.Value;
if not SelectCust(sRet1,sRet2) then exit;
with cdsOldGathering do begin
if (state <> dsInsert) and (state <> dsEdit) then Edit;
FieldByName('custno').AsString := sRet1;
FieldByName('custname').AsString := sRet2;
end;
end else if sFieldName = 'goodsid' then begin
if not SelectGoodsID(sRet1,false) then exit;
with cdsOldGathering do begin
if (state <> dsInsert) and (state <> dsEdit) then Edit;
FieldByName('goodsid').AsString := sRet1;
end;
end else if sFieldName = 'empno' then begin
if not SelectEmp(sRet1) then exit;
with cdsOldGathering do begin
if (state <> dsInsert) and (state <> dsEdit) then Edit;
FieldByName('empno').AsString := sRet1;
end;
end;
end;
procedure TFmOldGathering.ActNewExecute(Sender: TObject);
begin
with cdsOldGathering do
if Active and (not (state in dsEditModes)) then Insert;
end;
procedure TFmOldGathering.ActModifyExecute(Sender: TObject);
begin
with cdsOldGathering do
if Active and not ((state in dsEditModes)or(IsEmpty)) then Edit;
end;
procedure TFmOldGathering.ActDeleteExecute(Sender: TObject);
begin
with cdsOldGathering do
if Active and not ((state in dsEditModes)or(IsEmpty)) then Delete;
end;
procedure TFmOldGathering.ActRefreshExecute(Sender: TObject);
begin
with cdsOldGathering do begin
if (not Active) or IsEmpty then exit;
if state in dsEditModes then Post;
if ApplyUpdates(0)>0 then
raise Exception.Create('提交数据出错!');
Refresh;
end;
end;
procedure TFmOldGathering.edtCustNoButtonClick(Sender: TObject);
var sCustNo, sCustName : string;
begin
with cdsOldGathering do begin
if not SelectCust(sCustNo,sCustName) then exit;
edtCustNo.Text := sCustNo;
lbCustName.Caption := sCustName;
if (not Active) or IsEmpty then exit;
Filtered :=false;
Filter :='DepartID='+ IntToStr(Integer(tvDeparts.Selected.Data)) +
' AND CustNo=' + QuotedStr(edtCustNo.Text);
Filtered :=true;
end;
end;
procedure TFmOldGathering.BtnUnFilteredClick(Sender: TObject);
begin
tvDepartsChange(tvDeparts, tvDeparts.Selected);
end;
procedure TFmOldGathering.btnExitClick(Sender: TObject);
begin
close;
end;
procedure TFmOldGathering.BtnPopMenuClick(Sender: TObject);
var pt: TPoint;
begin
pt.X :=BtnPopMenu.Left;
pt.Y :=BtnPopMenu.Top + BtnPopMenu.Height;
pt := BtnPopMenu.Parent.ClientToScreen(pt);
TopPopMenu.Popup(pt.X,pt.Y);
end;
procedure TFmOldGathering.cdsOldGatheringAfterInsert(DataSet: TDataSet);
var
s1,s2 : string;
begin
with DataSet do begin
FieldByName('DepartID').AsInteger :=Integer(tvDeparts.Selected.Data);
GetDepartNoAndName(tvDeparts.Selected.Text,s1,s2);
FieldByName('DepartNo').AsString :=s1;
FieldByName('DepartName').AsString :=s2;
FieldByName('FDate').AsString := DateToStr(Now);
if (not chkCustID.Checked)or(edtCustNo.Text = '') then exit;
FieldByName('CustNo').AsString := edtCustNo.Text;
FieldByName('CustName').AsString := lbCustName.Caption;
end;
end;
procedure TFmOldGathering.cdsOldGatheringAfterPost(DataSet: TDataSet);
begin
if cdsOldGathering.ApplyUpdates(0)>0 then
MessageBox(Handle,'更新数据出错!',nil,MB_ICONHAND);
end;
procedure TFmOldGathering.GetDepartNoAndName(sText: string; var sNo,
sName: string);
begin
sNo := Copy(sText,1,Pos('[',sText)-1);
sName := Copy(sText,Pos('[',sText)+1,100);
Delete(sName,Pos(']',sName),100);
end;
procedure TFmOldGathering.tvDepartsCollapsing(Sender: TObject;
Node: TTreeNode; var AllowCollapse: Boolean);
begin
AllowCollapse := Node.Level>0;
end;
procedure TFmOldGathering.cdsOldGatheringBeforePost(DataSet: TDataSet);
begin
case DataSet.State of
dsInsert :
if not ActNew.Enabled then begin
MessageBox(Handle,'你没有足够的权限新增数据。','警告',MB_ICONEXCLAMATION);
abort;
end;
dsEdit :
if not ActModify.Enabled then begin
MessageBox(Handle,'你没有足够的权限修改数据。','警告',MB_ICONEXCLAMATION);
abort;
end;
end;
end;
procedure TFmOldGathering.ActFilterExecute(Sender: TObject);
begin
with cdsOldGathering do begin
if (not Active) or IsEmpty then exit;
Filtered := false;
Filter := 'DepartID='+ IntToStr(Integer(tvDeparts.Selected.Data)) +
' AND CustNo=' + QuotedStr(edtCustNo.Text);
Filtered := true;
end;
end;
procedure TFmOldGathering.tvDepartsChanging(Sender: TObject;
Node: TTreeNode; var AllowChange: Boolean);
begin
if cdsOldGathering.State in dsEditModes then begin
AllowChange := false;
MessageBox(Handle,'当前公司有编辑的数据未提交!','警告',MB_ICONEXCLAMATION);
end;
end;
procedure TFmOldGathering.btnPostClick(Sender: TObject);
begin
with cdsOldGathering do begin
if (not Active) or IsEmpty then exit;
if state in dsEditModes then post;
if ApplyUpdates(0)>0 then
MessageBox(Handle,'提交数据出错!',nil,MB_ICONHAND);
end;
end;
procedure TFmOldGathering.btnCancelClick(Sender: TObject);
begin
with cdsOldGathering do begin
if (not Active) or IsEmpty then exit;
if state in dsEditModes then Cancel;
CancelUpdates;
end;
end;
procedure TFmOldGathering.cdsOldGatheringPaidUpChange(Sender: TField);
begin
with cdsOldGathering do begin
FieldByName('UnPaid').AsFloat :=FieldByName('Amount').AsFloat - FieldByName('PaidUp').AsFloat;
if FieldByName('UnPaid').AsFloat + FieldByName('PaidUp').AsFloat <> FieldByName('Amount').AsFloat then
MessageBox(Handle,'应付金额与已付金额、欠款余额不匹配!',nil,MB_ICONHAND);
end;
end;
procedure TFmOldGathering.ActPrintExecute(Sender: TObject);
begin
SelRepPrint(Self.Name,[cdsOldGathering],'历史应收款',ActDesignReport.Enabled);
end;
procedure TFmOldGathering.ActFieldLayoutExecute(Sender: TObject);
begin
SetFieldsLayOut(LocSetting^.FieldLayoutCfgFile, Name, [dbgOldGathering], '历史应收款');
end;
procedure TFmOldGathering.ActDataExportExecute(Sender: TObject);
begin
ExportData([cdsOldGathering], '历史应收款', '');
end;
procedure TFmOldGathering.ActRevertExecute(Sender: TObject);
var iDepartID: integer;
begin
with cdsOldGathering do if (not Active)or IsEmpty then exit;
with tvDeparts do
if Selected =nil then exit else if Selected.Data =nil then exit;
iDepartID := Integer(tvDeparts.Selected.Data);
with SvrGathering do begin
if not AppServer.IsAudited(iClientID, iDepartID,1) then
raise Exception.Create('当前公司的历史应收款未审核过帐!');
if AppServer.Revert(iClientID, iDepartID,1) then
MessageBox(Handle,'历史应收款还原成功!','提示',MB_ICONINFORMATION)
else
MessageBox(Handle,'历史应收款还原失败!',nil,MB_ICONHAND);
end;
end;
procedure TFmOldGathering.ActAuditExecute(Sender: TObject);
var iDepartID ,iBranchID,iMachineID: integer;
sBranchMachine: String;
begin
with cdsOldGathering do if (not Active)or IsEmpty then exit;
with tvDeparts do
if Selected =nil then exit else if Selected.Data =nil then exit;
iDepartID := Integer(tvDeparts.Selected.Data);
with SvrGathering do begin
if AppServer.IsAudited(iClientID, iDepartID,1) then
raise Exception.Create('当前公司的历史应收款已审核过帐!');
iBranchID := IFmMain.IFmMainEx.GetLocSetting^.BranchNo;
iMachineId := IFmMain.IFmMainEx.GetLocSetting^.MachineNo;
sBranchMachine := FormatFloat('000',iBranchID)+FormatFloat('00',iMachineID);
if AppServer.Audit(iClientID, iDepartID,1,sBranchMachine) then
MessageBox(Handle,'历史应收款审核成功!','提示',MB_ICONINFORMATION)
else
MessageBox(Handle,'历史应收款审核失败!',nil,MB_ICONHAND);
end;
end;
procedure TFmOldGathering.cdsOldGatheringBeforeInsert(DataSet: TDataSet);
var iDepartID: integer;
begin
with tvDeparts do
if Selected =nil then abort else if Selected.Data =nil then abort;
iDepartID := Integer(tvDeparts.Selected.Data);
with SvrGathering do
if AppServer.IsAudited(iClientID, iDepartID,1) then begin
MessageBox(Handle,'当前公司的历史应收款已审核过帐!不能修改.','警告',MB_ICONEXCLAMATION);
abort;
end;
end;
initialization
RegisterClass(TFmOldGathering);
finalization
UnRegisterClass(TFmOldGathering);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -