📄 mainform.~pas
字号:
procedure TFormMain.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
FldName:String;
I:Integer;
TempStr:String[40];
begin
case Key of
VK_F1:
if ToolBarLB.Enabled then begin
EditHuHao.SetFocus;
EditHuHao.SelectAll;
end;
VK_RETURN:
if ToolBarLB.Enabled then
begin
EditHuHao.SetFocus;
EditHuHao.SelectAll;
KillMessage(Self.Handle,WM_CHAR);
if EditHuHao.Text='' then
exit;
TempStr:=EditHuHao.Text;
FldName:='户号';
for I:=1 to Length(TempStr) do
if(Ord(TempStr[I])>128)then begin
FldName:='名称';
Break;
end;
if RadioButtonWSH.Down then begin
if BrowSqlLst.Strings[2]='' then
OpenQueryProc(BrowSqlLst.Strings[0]+BrowSqlLst.Strings[1]+' where '+FldName+'='''+EditHuHao.Text+''''+BrowSqlLst.Strings[3]+BrowSqlLst.Strings[4],QueryMain)
else
OpenQueryProc(BrowSqlLst.Strings[0]+BrowSqlLst.Strings[1]+BrowSqlLst.Strings[2]+' and '+FldName+'='''+EditHuHao.Text+''''+BrowSqlLst.Strings[3]+BrowSqlLst.Strings[4],QueryMain);
DataSourceGrid.DataSet:=QueryMain;
DBGridFldRef(QueryMain);
if (QueryMain.RecordCount=1) and DirectPreview then
MenuP_ViewClick(nil);
end;
if RadioButtonWDFP.Down then begin
OpenQueryProc(WDFPLst.Strings[0]+WDFPLst.Strings[1]+' where 发票已打=''F'' and '
+FldName+'='''+EditHuHao.Text+''''+WDFPLst.Strings[3]+WDFPLst.Strings[4],QueryWDFP);
DataSourceGrid.DataSet:=QueryWDFP;
DBGridFldRef(QueryWDFP);
end;
if RadioButtonYSH.Down then begin
if not QueryYiShou.Locate(FldName,EditHuHao.Text,[]) then
ShowMessage('没有找到指定的收费记录');
end;
end;
end;
end;
procedure TFormMain.DBGridFldRef(Query:TAdoQuery);
var
I:Integer;
CanShow:Boolean;
begin
CanShow:=True;
DBGridMain.Options:=DBGridMain.Options-[dgEditing];
for I:=0 to Query.FieldCount-1 do begin
case Query.Fields[I].DataType of
ftString:Query.Fields[I].DisplayWidth:=25;
ftDate,ftDateTime:
begin
TDateTimeField(Query.Fields[I]).DisplayFormat:='yyyy-mm-dd';
Query.Fields[I].DisplayWidth:=15;
end;
else
Query.Fields[I].DisplayWidth:=15;
end;
if UpperCase(Query.Fields[I].FieldName)='HIDE' then
CanShow:=False;
Query.Fields[I].Visible:=CanShow;
end;
end;
procedure TFormMain.FormKeyPress(Sender: TObject; var Key: Char);
begin
if(EditHuHao.Focused)then
exit;
if ChangeMySelf then
Exit;
if not (CEditShiShou.Focused or CurrencyEditZHNJ.Focused or SpinEditPiaoHao.Focused) then begin
ChangeMySelf:=True;
EditHuHao.Perform(WM_CHAR,ord(Key),0);
ChangeMySelf:=False;
end;
end;
procedure TFormMain.MenuS_QuitClick(Sender: TObject);
begin
if MessageDlg('真的要退出收费程序吗?',mtInformation,[mbYes,mbNo],0)=mrYes then
Close;
end;
procedure TFormMain.MenuS_ShouFeiSetClick(Sender: TObject);
var
FormSetup: TFormSetup;
begin
if HaveThesePower(OpID,'sf_xt_zhanghu','系统设置')<>1 then begin
ShowMessage('当前帐号没有进入收费设置的权利!');
Exit;
end;
FormSetup:=TFormSetup.Create(Self);
FormSetup.ShowModal;
FormSetup.Free;
LoadBasicSeting;
end;
procedure TFormMain.FormDestroy(Sender: TObject);
begin
IniFile.Free;
BrowSqlLst.Free;
RecallSqlLst.Free;
WDFPLst.Free;
SumSqlStr.Free;
if FormInfoList<>nil then
FormInfoList.Free;
end;
procedure TFormMain.LoadBasicSeting;
var
I:Integer;
TempList:TStringList;
begin
UnSqlStr(IniFile.ReadString('最新设置','缴费浏览',''),BrowSqlLst);
UnSqlStr(IniFile.ReadString('最新设置','已打发票',''),RecallSqlLst);
UnSqlStr(IniFile.ReadString('最新设置','收费统计',''),SumSqlStr);
UnSqlStr(IniFile.ReadString('最新设置','未打发票',''),WDFPLst);
TempList:=TStringList.Create;
IniFile.ReadSection('发票格式',TempList);
ComboBoxCurFP.Items.Clear;
for I:=0 to TempList.Count-1 do
ComboBoxCurFP.Items.Add(TempList.Strings[i]);
ComboBoxCurFP.ItemIndex:=ComboBoxCurFP.Items.IndexOf(IniFile.ReadString('最新设置','默认发票',''));
if (ComboBoxCurFP.Items.Count>0) and (ComboBoxCurFP.ItemIndex=-1) then
ComboBoxCurFP.ItemIndex:=0;
TempList.Free;
FenCiShouFei:=IniFile.ReadBool('设置','分次收费',False);
YuShouFei:=IniFile.ReadBool('设置','预收费',False);
ZHIDINGZHNJ:=IniFile.ReadBool('设置','指定滞纳金',False);
JINEQUZHENG:=IniFile.ReadBool('设置','金额取整',False);
DirectPreView:=IniFile.ReadBool('设置','直接预览',False);
ViewDetail:=IniFile.ReadBool('设置','显示明细',False);
QUZHENGWS:=IniFile.ReadInteger('设置','取整到',1);
Menu_Prepay.Visible:=YuShouFei;
if (QUZHENGWS<0)or (QUZHENGWS>1) then
QUZHENGWS:=1;
Label9.Visible:=ViewDetail;
LabelSYYE.Visible:=ViewDetail;
Label6.Visible:=ViewDetail;
LabelYJ.Visible:=ViewDetail;
Label7.Visible:=ViewDetail;
LabelYC.Visible:=ViewDetail;
Label11.Visible:=ViewDetail;
LabelYSZNJ.Visible:=ViewDetail;
Label4.Visible:=ZHIDINGZHNJ;
CurrencyEditZHNJ.Visible:=ZHIDINGZHNJ;
Caption:=IniFile.ReadString('设置','标题','');
if Caption='' then
Caption:='营业大厅收费程序';
end;
procedure TFormMain.RadioButtonWSHClick(Sender: TObject);
begin
ChkIdx:=0;
DataSourceGrid.DataSet:=QueryMain;
EnableButtons;
if QueryMain.Active then
QueryMain.First;
QueryMainAfterScroll(nil);
if(ToolButtonSelPrn.Down)and(not (dgRowSelect in DBGridMain.Options)) then
DBGridMain.Options:=DBGridMain.Options+[dgRowSelect];
end;
procedure TFormMain.ToolButtonSelClick(Sender: TObject);
var
FormCase:TFormCase;
I:Integer;
WhereSql:String;
TempList:TStringList;
CollNames,CollSQLList,ConList:TStringList;
begin
FormCase:=TFormCase.Create(Self);
CollNames:=TStringList.Create;
CollSQLList:=TStringList.Create;
ConList:=TStringList.Create;
TempList:=TStringList.Create;
CutStr(IniFile.ReadString('最新设置','集合浏览',''),CollNames,';');
for I:=0 to CollNames.Count-1 do begin
TempList.Clear;
CutStr(IniFile.ReadString('最新设置',CollNames.Strings[I],''),TempList,'|');
if TempList.Count>1 then begin
CollSQLList.Add(TempList.Strings[0]);
ConList.Add(TempList.Strings[1]);
end
else begin
CollSQLList.Add('');
ConList.Add('');
end;
end;
TempList.Free;
with FormCase do
if MakeFace(CollNames,CollSQLList) then
if ShowModal=mrOK then begin
for I:=0 to ComboList.Count-1 do
if TComboBox(ComboList.Items[I]).ItemIndex>-1 then begin
if Length(ConList.Strings[i])>0 then
WhereSql:=' and '+ConList.Strings[i];
end;
if RadioButtonWSH.Down then //需要缴费的用户
with QueryMain do begin
Close;
SQL.Clear;
if BrowSqlLst.Strings[2]<>'' then
SQL.Add(BrowSqlLst.Strings[0]
+BrowSqlLst.Strings[1]
+BrowSqlLst.Strings[2]
+WhereSql
+BrowSqlLst.Strings[3]
+BrowSqlLst.Strings[4])
else
SQL.Add(BrowSqlLst.Strings[0]
+BrowSqlLst.Strings[1]
+' where 1=1 '
+WhereSql
+BrowSqlLst.Strings[3]
+BrowSqlLst.Strings[4]);
for I:=0 to ComboList.Count-1 do
if TComboBox(ComboList.Items[I]).ItemIndex>-1 then begin
//adoQuery的bug,无法使用动态parameter,只好直接生成sql
Sql.Text:=StringReplace(Sql.Text,
':'+CollNames.Strings[i],
''''+TComboBox(ComboList.Items[I]).Items[TComboBox(ComboList.Items[I]).ItemIndex]+'''',
[rfReplaceAll]);
end;
try
Open;
DBGridFldRef(QueryMain);
except
ShowMessage('执行出错,请检查集合浏览的SQL语句');
end;
end
else if RadioButtonWDFP.Down then //未打发票
with QueryWDFP do begin
Close;
SQL.Clear;
SQL.Add(WDFPLst.Strings[0]
+WDFPLst.Strings[1]
+' where 发票已打=''F'' '
+WhereSql
+WDFPLst.Strings[3]
+WDFPLst.Strings[4]);
for I:=0 to ComboList.Count-1 do
if TComboBox(ComboList.Items[I]).ItemIndex>-1 then begin
if QueryWDFP.Parameters.FindParam(CollNames.Strings[i])<>nil then begin
QueryWDFP.Parameters.FindParam(CollNames.Strings[i]).DataType:=ftString;
QueryWDFP.Parameters.FindParam(CollNames.Strings[i]).Size:=50;
QueryWDFP.Parameters.FindParam(CollNames.Strings[i]).Value:=TComboBox(ComboList.Items[I]).Items[TComboBox(ComboList.Items[I]).ItemIndex];
end;
end;
try
Open;
DBGridFldRef(QueryWDFP);
except
ShowMessage('执行出错,请检查集合浏览的SQL语句');
end;
end;
end;
CollNames.Free;
CollSQLList.Free;
ConList.Free;
FormCase.Free;
end;
procedure TFormMain.MenuH_SumClick(Sender: TObject);
begin
FormOpDate:=TFormOpDate.Create(Self);
try
if FormOpDate.ShowModal=mrOK then begin
if SumSqlStr.Strings[2]='' then begin
if Abs(FormOpDate.DateT-FormOpDate.DateF)>1 then
OpenQueryProc(SumSqlStr[0]+SumSqlStr[1]+' where 收费日期 between '''+FormatDateTime('mm/dd/yyyy',FormOpDate.DateF)+''' and '''+FormatDateTime('mm/dd/yyyy',FormOpDate.DateT)+''' '+SumSqlStr[3]+SumSqlStr[4],DataMD.QueryPublic)
else
OpenQueryProc(SumSqlStr[0]+SumSqlStr[1]+' where datediff(dd,收费日期,'''+FormatDateTime('mm/dd/yyyy',FormOpDate.DateF)+''')=0 '+SumSqlStr[3]+SumSqlStr[4],DataMD.QueryPublic);
end
else begin
if Abs(FormOpDate.DateT-FormOpDate.DateF)>1 then
OpenQueryProc(SumSqlStr[0]+SumSqlStr[1]+SumSqlStr[2]+' and 收费日期 between '''+FormatDateTime('mm/dd/yyyy',FormOpDate.DateF)+''' and '''+FormatDateTime('mm/dd/yyyy',FormOpDate.DateT)+''' '+SumSqlStr[3]+SumSqlStr[4],DataMD.QueryPublic)
else
OpenQueryProc(SumSqlStr[0]+SumSqlStr[1]+SumSqlStr[2]+' and datediff(dd,收费日期,'''+FormatDateTime('mm/dd/yyyy',FormOpDate.DateF)+''')=0 '+SumSqlStr[3]+SumSqlStr[4],DataMD.QueryPublic);
end;
DataSourceGrid.DataSet:=DataMD.QueryPublic;
ToolButtonSum.Down:=True;
Application.ProcessMessages;
StringGridDETAIL.Visible:=False;
ShowMessage('按确定恢复原来显示');
StringGridDETAIL.Visible:=True;
if RadioButtonWSH.Down then
DataSourceGrid.DataSet:=QueryMain
else if RadioButtonWDFP.Down then
DataSourceGrid.DataSet:=QueryWDFP
else
DataSourceGrid.DataSet:=QueryYiShou;
ToolButtonSum.Down:=False;
end;
finally
FormOpDate.Free;
end;
end;
procedure TFormMain.MenuS_SeleteClick(Sender: TObject);
begin
if dgRowSelect in DBGridMain.Options then
DBGridMain.Options:=DBGridMain.Options-[dgRowSelect]
else begin
DBGridMain.Options:=DBGridMain.Options+[dgRowSelect];
DBGridMain.SelectedRows.CurrentRowSelected:=True;
end;
MenuS_Selete.Checked:=not MenuS_Selete.Checked;
ToolButtonSelPrn.Down:=MenuS_Selete.Checked;
end;
procedure TFormMain.SpdBtnClearClick(Sender: TObject);
begin
JieDuanHeJi:=0;
PanelHeJi.Caption:='阶段合计金额:¥0.00';
end;
procedure TFormMain.QueryMainAfterOpen(DataSet: TDataSet);
var
TempList : TStringList;
SqlString: String;
begin
RefreshUIFee:=True; //全部打印过程中不需要刷新界面,打印完毕则需要
EnableButtons;
QueryMainAfterScroll(nil);
TempList := TStringList.Create;
UnSqlStr(QueryMain.SQL.Text,TempList);
SqlString:='select sum(应收金额) from sf_shoufei '+TempList.Strings[2];
with DataMD.OpenQuery(SqlString) do begin
LabelSum.Caption:=Fields[0].AsString;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -