📄 mainform.~pas
字号:
Close;
end;
TempList.Free;
end;
procedure TFormMain.MenuH_ListWindowClick(Sender: TObject);
begin
if FormInfoList=nil then
FormInfoList:=TFormInfoList.Create(Self);
FormInfoList.Top:=IniFile.ReadInteger('设置','InfoTop',16);
FormInfoList.Left:=IniFile.ReadInteger('设置','InfoLeft',Width-FormInfoList.Width-16);
FormInfoList.Show;
FormMain.MenuH_ListWindow.Checked:=True;
end;
procedure TFormMain.MenuP_ViewClick(Sender: TObject);
begin
if HaveThesePower(OpID,'sf_xt_zhanghu','发票预览')<>1 then begin
ShowMessage('当前帐号没有预览发票的权利!');
Exit;
end;
if ChkIdx=0 then begin
if (not FenCiShouFei) and (CEditShiShou.Value<StrToFloat(LabelHJ.Caption)) then begin
CEditShiShou.Value:=StrToFloat(LabelHJ.Caption);
ShowORHideZHAOLING(False);
ShowMessage('不允许分次收费!');
Abort;
end;
if CEditShiShou.Value>=StrToFloat(LabelHJ.Caption) then begin
ShowORHideZHAOLING(True);
end;
end;
MenuP_View.Checked:=not MenuP_View.Checked;
SpeedButtonPre.Down:=MenuP_View.Checked;
ToolBarRT.Enabled:=not MenuP_View.Checked;
ToolBarLB.Enabled:=not MenuP_View.Checked;
ToolBarRB.Enabled:=not MenuP_View.Checked;
if MenuP_View.Checked then begin
SpeedButtonPre.Caption:='&V取消预览';
PageControl.ActivePageIndex:=1;
FillReport(False);
RepRunShouFei.InsidePreview:=True;
RepRunShouFei.PrintPreview(True);
Invalidate;
end
else begin
SpeedButtonPre.Caption:='&V预览发票';
PageControl.ActivePageIndex:=0;
end;
end;
function GetItemCount(var TmpList:TStringList;ItemName:String):Integer;
var
i,Cnt : Integer;
begin
Cnt:=0;
for i:=0 to TmpList.Count-1 do
if TmpList[i]=ItemName then
Inc(Cnt);
Result:=Cnt;
end;
procedure TFormMain.FillReport(IsPrint:Boolean);
var
RepFileName:String;
ShiShouFee :double; //---------实收金额
ZhiNaJin :double; //-----------实收滞纳金
YSZhNj :double; //-----------应收滞纳金
BenYueYE :double; //-----------本月余额
ShangYueYE :double; //-----------上月余额
YuJiaoFuFei:double; //-----------本次用预交支付的电费是多少
ShouFeiXH :Integer;//-----------收费序号
FormatStr :String;
MXList,TempList :TStringList;
LiuShuiH :String;
IsSettleUp :Boolean;
begin
if QUZHENGWS=0 then
FormatStr:='0'
else
FormatStr:='0.0';
if ChkIdx=0 then begin
//注意:收费时,在打印全部发票和选择打印不同
// 预存足够支付本次电费的情况放在数据导入中考虑
LiuShuiH:=QueryMain.FieldByName('流水号').AsString;
if RefreshUIFee or (not IsPrint) then begin
//选择打印或预览直接从界面取值
if (FENCiShouFei) and (CEditShiShou.Value<StrtoFloat(LabelHJ.Caption)) then
ShiShouFee:=CEditShiShou.Value //分次
else
ShiShouFee:=StrtoFloat(LabelHJ.Caption);
YSZhNj:=StrtoFloat(LabelYSZNJ.Caption);
if ZHIDINGZHNJ then
ZhiNaJin:=CurrencyEditZHNJ.Value
else
ZhiNaJin:=StrtoFloat(LabelYSZNJ.Caption);
ShangYueYE:=StrtoFloat(LabelSYYE.Caption);
BenYueYE:=0;//未缴清本月余额为0
IsSettleUp:=False;
YuJiaoFuFei:=StrtoFloat(LabelYC.Caption);
if FormatFloat('0.00',ShiShouFee)=FormatFloat('0.00',StrtoFloat(LabelHJ.Caption)) then begin
//表示预存的金额不够付这次电费
//结清则计算本月余额
if YuEisNegative then////多收的本月余额用负数表示供电局欠用户
//本月余额=上月余额+应收+滞纳金-已缴-本次缴费-预存金额
BenYueYE:=StrtoFloat(LabelSYYE.Caption)+StrtoFloat(LabelYSJE.Caption)+ZhiNaJin
-StrtoFloat(LabelYJ.Caption)-ShiShouFee-YuJiaoFuFei
else////多收的本月余额用正数表示供电局欠用户
//本月余额=(已缴+本次缴费+预存金额+上月余额)-(应收+滞纳金)
BenYueYE:=StrtoFloat(LabelYJ.Caption)+ShiShouFee+YuJiaoFuFei+StrtoFloat(LabelSYYE.Caption)
-(StrtoFloat(LabelYSJE.Caption)+ZhiNaJin);
IsSettleUp:=True;
end;
end
else begin
//直接从QueryMain中取值
IsSettleUp:=True;
DataMD.ADOSPCalcfee.Parameters.ParamByName('@lsh').Value:=LiuShuiH;
if JINEQUZHENG then
DataMD.ADOSPCalcfee.Parameters.ParamByName('@quzheng').Value:='T'
else
DataMD.ADOSPCalcfee.Parameters.ParamByName('@quzheng').Value:='F';
DataMD.ADOSPCalcfee.Parameters.ParamByName('@quzhengws').Value:=QUZHENGWS;
DataMD.ADOSPCalcfee.ExecProc;
YuJiaoFuFei:=DataMD.ADOSPCalcfee.Parameters.ParamByName('@yucunfee').Value;//预存金额
ShiShouFee:=DataMD.ADOSPCalcfee.Parameters.ParamByName('@yingjiaofee').Value;
ZhiNaJin:=DataMD.ADOSPCalcfee.Parameters.ParamByName('@znj').Value;
with DataMD.OpenQuery('select 余额 from sf_shoufei_ye where ID='+QueryMain.FieldByName('ID').AsString) do begin
if RecordCount>0 then
ShangYueYE:=FieldByName('余额').AsFloat
else
ShangYueYE:=0;
Close;
end;
if YuEisNegative then
//本月余额=上月余额+应收+滞纳金-已缴-本次缴费-预存金额
BenYueYE:=ShangYueYE+QueryMain.FieldByName('应收金额').AsFloat+ZhiNaJin
-DataMD.ADOSPCalcfee.Parameters.ParamByName('@yonghuyjfee').Value
-ShiShouFee-YuJiaoFuFei
else
//本月余额=(已缴+本次缴费+预存金额+上月余额)-(应收+滞纳金)
BenYueYE:=(DataMD.ADOSPCalcfee.Parameters.ParamByName('@yonghuyjfee').Value+ShiShouFee+YuJiaoFuFei+ShangYueYE)
-(QueryMain.FieldByName('应收金额').AsFloat+ZhiNaJin);
end;
end;
if ChkIdx=1 then begin
LiuShuiH:=QueryYiShou.FieldByName('流水号').AsString;
ShiShouFee:=QueryYiShou.FieldByName('实收金额').AsFloat;
ZhiNaJin:=QueryYiShou.FieldByName('实收滞纳金').AsFloat;
BenYueYE:=QueryYiShou.FieldByName('本月余额').AsFloat;
ShangYueYE:=QueryYiShou.FieldByName('上月余额').AsFloat;
end;
if ChkIdx=2 then begin
LiuShuiH:=QueryWDFP.FieldByName('流水号').AsString;
ShiShouFee:=QueryWDFP.FieldByName('实收金额').AsFloat;
ZhiNaJin:=QueryWDFP.FieldByName('实收滞纳金').AsFloat;
BenYueYE:=QueryWDFP.FieldByName('本月余额').AsFloat;
ShangYueYE:=QueryWDFP.FieldByName('上月余额').AsFloat;
ShouFeiXH:=QueryWDFP.FieldByName('收费序号').AsInteger;
end;
RepRunShouFei.ResetSelf;
RepFileName:='';
RepFileName:=IniFile.ReadString('发票格式',ComboBoxCurFP.Items[ComboBoxCurFP.ItemIndex],'');
if RepFileName='' then begin
ShowMessage('没有发票格式!');
Abort;
end;
if IsPrint then
RepFileName:=GetPrintRepName(RepFileName);
RepRunShouFei.loadfile(RepFileName);
RepRunShouFei.SetVarValue('OpID',OpID);
RepRunShouFei.SetVarValue('OpName',OpName);
RepRunShouFei.SetVarValue('OpDate',FormatDateTime('YYYY',OpDate)+'年'+FormatDateTime('MM',OpDate)+'月'+FormatDateTime('DD',OpDate)+'日');
RepRunShouFei.SetVarValue('ShiShouFee',ShiShouFee);
RepRunShouFei.SetVarValue('ZhiNaJin',ZhiNaJin);
RepRunShouFei.SetVarValue('BenYueYE',BenYueYE);
RepRunShouFei.SetVarValue('ShangYueYE',ShangYueYE);
//填入明细项目
TempList := TStringList.Create;
MXList := TStringList.Create;
with DataMD.OpenQuery('select 明细内容 from sf_shoufeimx where 流水号='''+LiuShuiH+'''') do begin
if RecordCount>0 then begin
CutStr(Fields[0].AsString,MXList,';');
while MXList.Count>0 do begin
if TempList.IndexOf(GetFieldorValue(MXList.Strings[0],'F'))>-1 then
RepRunShouFei.SetVarValue(GetFieldorValue(MXList.Strings[0],'F')+InttoStr(GetItemCount(TempList,GetFieldorValue(MXList.Strings[0],'F'))),
GetFieldorValue(MXList.Strings[0],'V'))
else
RepRunShouFei.SetVarValue(GetFieldorValue(MXList.Strings[0],'F'),GetFieldorValue(MXList.Strings[0],'V'));
TempList.Add(GetFieldorValue(MXList.Strings[0],'F'));
MXList.Delete(0);
end;
end;
Close;
end;
MXList.Free;
TempList.Free;
RepRunShouFei.EnableEdit:=False;
if IsPrint then begin
JieDuanHeJi:=JieDuanHeJi+ShiShouFee;
PanelHeJi.Caption:='阶段合计金额:¥'+FormatFloat('0.00',JieDuanHeJi);
case ChkIdx of
0:with DataMD.ADOSPprintFP do begin
Parameters.ParamByName('@lsh').Value:=LiuShuiH;
Parameters.ParamByName('@ShiShouFee').Value:=ShiShouFee;
Parameters.ParamByName('@YingShouZNJ').Value:=YSZhNj;
Parameters.ParamByName('@ShiShouZNJ').Value:=ZhiNaJin;
Parameters.ParamByName('@BenYueYE').Value:=BenYueYE;
Parameters.ParamByName('@FPHao').Value:=SpinEditPiaoHao.Text;
Parameters.ParamByName('@OpName').Value:=OpName;
if IsSettleUp then
Parameters.ParamByName('@IsSettleUp').Value:='T'
else
Parameters.ParamByName('@IsSettleUp').Value:='F';
ExecProc;
end;
2:with DataMD.ADOSPReprintFP do begin
Parameters.ParamByName('@lsh').Value:=LiuShuiH;
Parameters.ParamByName('@ShouFeiXH').Value:=ShouFeiXH;
Parameters.ParamByName('@FPHao').Value:=SpinEditPiaoHao.Text;
Parameters.ParamByName('@OpName').Value:=OpName;
ExecProc;
end;
end;
end;
end;
procedure TFormMain.MenuH_AboutClick(Sender: TObject);
var
FormAbout: TFormAbout;
begin
FormAbout:=TFormAbout.Create(Self);
FormAbout.ShowModal;
FormAbout.Free;
end;
procedure TFormMain.MenuP_PrintClick(Sender: TObject);
var
ExtAppHandle:THandle;
PExtProc:FarProc;
begin
if HaveThesePower(OpID,'sf_xt_zhanghu','发票打印')<>1 then begin
ShowMessage('当前帐号没有打印发票的权利!');
Exit;
end;
if ChkIdx=0 then
if (not ToolButtonSelPrn.Down) and (QueryMain.RecordCount>1) then
if Application.MessageBox('您确定打印全部发票吗?','',MB_OKCANCEL+MB_ICONQUESTION)<>ID_OK then
Exit;
if ChkIdx=2 then
if (not ToolButtonSelPrn.Down) and (QueryWDFP.RecordCount>1) then
if Application.MessageBox('您确定打印全部发票吗?','',MB_OKCANCEL+MB_ICONQUESTION)<>ID_OK then
Exit;
if ChkIdx=0 then begin
if (not FenCiShouFei) and (CEditShiShou.Value<StrToFloat(LabelHJ.Caption)) then begin
CEditShiShou.Value:=StrToFloat(LabelHJ.Caption);
ShowORHideZHAOLING(False);
ShowMessage('不允许分次收费!');
Abort;
end;
if CEditShiShou.Value>=StrToFloat(LabelHJ.Caption) then begin
ShowORHideZHAOLING(True);
end;
end;
try
FormPrintInfo:=TFormPrintInfo.Create(Self);
if ChkIdx=0 then begin
if (ToolButtonSelPrn.Down) or (QueryMain.RecordCount=1) then begin
FillReport(True);
RepRunShouFei.Print;
SpinEditPiaoHao.Value:=SpinEditPiaoHao.Value+1;
if CheckBox1.Visible and CheckBox1.Checked then begin
ExtAppHandle:=LoadLibrary(PChar(ExtAppPath+'YuJiao.dll'));
PreCallDll(ExtAppHandle);
if ExtAppHandle>=32 then begin
try
PExtProc:=GetProcAddress(ExtAppHandle,PChar('DLL_Prepay'));
Screen.Cursor:=crDefault;
if PExtProc<>nil then
TDllPrepay(PExtProc)(StrtoFloat(LabelZHL.Caption));
PExtProc:=GetProcAddress(ExtAppHandle,'DLL_Destory');
if PExtProc<>nil then
TVoidProc(PExtProc);
except
end;
FreeLibrary(ExtAppHandle);
end;
end;
end
else begin
RefreshUIFee:=False;
FormPrintInfo.ProgressBar.Max:=QueryMain.RecordCount;
if QueryMain.RecordCount>2 then
FormPrintInfo.Show;
QueryMain.First;
while not QueryMain.Eof do begin
Application.ProcessMessages;
if FormPrintInfo.PrintState=3 then
Break;
FormPrintInfo.ProgressBar.Position:=FormPrintInfo.ProgressBar.Position+1;
FillReport(True);
RepRunShouFei.Print;
QueryMain.Next;
SpinEditPiaoHao.Value:=SpinEditPiaoHao.Value+1;
end;
end;
QueryMain.Close;
QueryMain.Open;
DBGridFldRef(QueryMain);
end;
if ChkIdx=2 then begin
if (ToolButtonSelPrn.Down) or (QueryWDFP.RecordCount=1) then begin
FillReport(True);
RepRunShouFei.Print;
SpinEditPiaoHao.Value:=SpinEditPiaoHao.Value+1;
end
else begin
FormPrintInfo.ProgressBar.Max:=QueryWDFP.RecordCount;
if QueryWDFP.RecordCount>2 then
FormPrintInfo.Show;
QueryWDFP.First;
while not QueryWDFP.Eof do begin
Application.ProcessMessages;
if FormPrintInfo.PrintState=3 then
Break;
FormPrintInfo.ProgressBar.Position:=FormPrintInfo.ProgressBar.Position+1;
FillReport(True);
RepRunShouFei.Print;
QueryWDFP.Next;
SpinEditPiaoHao.Value:=SpinEditPiaoHao.Value+1;
end;
end;
QueryWDFP.Close;
QueryWDFP.Open;
DBGridFldRef(QueryWDFP);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -