📄 busjlzbunit.pas
字号:
DealProc1('JG11','JG02','JG05','/');
end;
if((curRecordStr='JG07') or (curRecordStr='JG02'))then
begin
DealProc1('JG12','JG07','JG02','/');
end;
if((curRecordStr='JG16') or (curRecordStr='JG02'))then
begin
DealProc1('JG13','JG16','JG02','/');
end;
if((curRecordStr='JG48') or (curRecordStr='JG02'))then
begin
DealProc1('JG14','JG48','JG02','/');
end;
if((curRecordStr='JG18') or (curRecordStr='JG22'))then
begin
DealProc1('JG17','JG18','JG22','+');
end;
if((curRecordStr='JG26') or (curRecordStr='JG28'))then
begin
DealProc1('JG25','JG26','JG28','+');
end;
if((curRecordStr='JG35') or (curRecordStr='JG36') or (curRecordStr='JG37'))then
begin
DealProc1('JG34','JG35','JG36','+');
DealProc1('JG34','JG34','JG37','+');
end;
if((curRecordStr='JG41') or (curRecordStr='JG42') or (curRecordStr='JG43'))then
begin
DealProc1('JG40','JG41','JG42','+');
DealProc1('JG34','JG40','JG43','+');
end;
}
end;
procedure DealProc(var ResultValue:single;Oper1Value:single;Oper2Value:single;curSigh:string);
begin
if(curSigh='+')then
ResultValue:=Oper1Value+Oper2Value;
if(curSigh='-')then
ResultValue:=Oper1Value-Oper2Value;
if(curSigh='*')then
ResultValue:=Oper1Value*Oper2Value;
if(curSigh='/')then
begin
if(Oper2Value=0)then exit;
ResultValue:=(Oper1Value/Oper2Value);
end;
end;
procedure TBusJLZBForm.LookUpZB(var OperValue:single;OperName:string;var curPos:integer);
var
V1,V2,V3,V4: Variant;
begin
V1:=QueryPageLeft1.Lookup('指标代码',OperName,'本年实际');
if not (VarType(V1) in [varNull]) then
begin
OperValue:=V1;
curPos:=0;
end;
V2:=QueryPageRight1.Lookup('指标代码',OperName,'本年实际');
if not (VarType(V2) in [varNull]) then
begin
OperValue:=V2;
curPos:=1;
end;
end;
procedure TBusJLZBForm.DealProc1(ResultValue:string;Oper1Value:string;Oper2Value:string;curSigh:string);
var
Oper1,Oper2,curResult:single;
curPos:integer;
begin
LookUpZB(Oper1,Oper1Value,curPos);
LookUpZB(Oper2,Oper2Value,curPos);
LookUpZB(curResult,ResultValue,curPos);
DealProc(curResult,Oper1,Oper2,curSigh);
IsModifyIndex:=True;
case curPos of
0:
begin
QueryPageLeft1.Locate('指标代码',ResultValue,[]);
QueryPageLeft1.Edit;
QueryPageLeft1.fieldbyname('本年实际').AsFloat:=curResult;
QueryPageLeft1.Post;
end;
1:
begin
QueryPageRight1.Locate('指标代码',ResultValue,[]);
QueryPageRight1.Edit;
QueryPageRight1.fieldbyname('本年实际').AsFloat:=curResult;
QueryPageRight1.Post;
end;
end;
IsModifyIndex:=False;
end;
procedure TBusJLZBForm.DealProc2(ResultValue:string;Oper1Value:string;Oper2Value:single;curSigh:string);
var
Oper1,Oper2,curResult,temp:single;
curPos:integer;
begin
LookUpZB(Oper1,Oper1Value,curPos);
Oper2:=Oper2Value;
DealProc(curResult,Oper1,Oper2,curSigh);
LookUpZB(temp,ResultValue,curPos);
IsModifyIndex:=True;
case curPos of
0:
begin
QueryPageLeft1.Locate('指标代码',ResultValue,[]);
QueryPageLeft1.Edit;
QueryPageLeft1.fieldbyname('本月实际').AsFloat:=curResult;
QueryPageLeft1.Post;
end;
1:
begin
QueryPageRight1.Locate('指标代码',ResultValue,[]);
QueryPageRight1.Edit;
QueryPageRight1.fieldbyname('本月实际').AsFloat:=curResult;
QueryPageRight1.Post;
end;
end;
IsModifyIndex:=False;
end;
procedure TBusJLZBForm.FormShow(Sender: TObject);
begin
PostIndex:='';
end;
procedure TBusJLZBForm.RefreshPage;
begin
QueryPageLeft1.Next;
QueryPageLeft1.Prior;
QueryPageRight1.Next;
QueryPageRight1.Prior;
end;
procedure TBusJLZBForm.OpenAllPage;
begin
QueryPageLeft1.Close;
QueryPageLeft1.SQL.Clear;
QueryPageLeft1.SQL.Add('select * from 公交行业城市交流指标表_z where 统计年份='+ComboBox1.text+
' and 城市代码='+''''+Edit9.Text+''''+
' and 指标代码 in (select 指标代码 from 公交行业城市交流指标定义表 where 显示位置=1)');
QueryPageLeft1.Open;
QueryPageRight1.Close;
QueryPageRight1.SQL.Clear;
QueryPageRight1.SQL.Add('select * from 公交行业城市交流指标表_z where 统计年份='+ComboBox1.text+
' and 城市代码='+''''+Edit9.Text+''''+
' and 指标代码 in (select 指标代码 from 公交行业城市交流指标定义表 where 显示位置=2)');
QueryPageRight1.Open;
ADOQuery4.SQL.Clear;
ADOQuery4.SQL.Add('select * from 公交行业城市交流指标表 where 统计年份='+
ComboBox1.Text+
' and 城市代码='+''''+Edit9.text+'''');
ADOQuery4.Open;
end;
procedure TBusJLZBForm.SpeedButton2Click(Sender: TObject);
begin
if(Edit9.text='')then
begin
showmessage('请选择城市代码!');
exit;
end;
if(not CheckYearMon)then exit;
if(BitBtn3.Enabled=true)then
begin
MessageBox(self.Handle,'请先确认你的添加,修改,删除结果。','注意',MB_OK);
exit;
end;
ButtonEnable(nil);
DBMemo1.ReadOnly:=true;
OpenAllPage;
AddPrnQuery;
curYear:= ComboBox1.Text;
if(ADOQPrintMon.RecordCount<=0)then
begin
MessageBox(self.Handle,'没有数据','消息',MB_OK);
end;
BitBtn8.Enabled:=true;
end;
function TBusJLZBForm.AddPrnQuery:boolean;
begin
if(not CheckYearMon)then
begin
AddPrnQuery:=false;
exit;
end;
ADOQPrintMon.Close;
ADOQPrintMon.SQL.Clear;
ADOQPrintMon.SQL.Add('select * from 公交行业城市交流指标表_z where 统计年份='+ComboBox1.text+
' and 城市代码='+''''+Edit9.text+''''+' order by 指标代码');
try
ADOQPrintMon.Open;
AddPrnQuery:=true;
except
AddPrnQuery:=false;
end;
end;
procedure TBusJLZBForm.BitBtn7Click(Sender: TObject);
begin
Close;
end;
procedure TBusJLZBForm.BitBtn8Click(Sender: TObject);
var iRow,iCol,iRecNum,i:integer;
begin
if(ADOQPrintMon.Active=false)then
begin
if(not AddPrnQuery)then
begin
exit;
end;
end;
if DeviceDetect=0 then
begin
exit;
end;
if(PrnInfoFrm.ShowModal<>mrOK)then
begin
exit;
end;
PrintInit(ExtractFilePath(Application.ExeName),'CityComm');
iRow := 1 ;
iRecNum := 1 ;
ADOQPrintMon.First;
for i:=4 to 28 do
begin
WriteCell(i,4,Converter(ADOQPrintMon.FieldByName('本年实际').AsString));
ADOQPrintMon.Next;
end;
for i:=4 to 27 do
begin
WriteCell(i,8,Converter(ADOQPrintMon.FieldByName('本年实际').AsString));
ADOQPrintMon.Next;
end;
PrintExcelShow;
PrintPreview;
CloseActiveBook;
end;
procedure TBusJLZBForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
QueryPageLeft1.close;
QueryPageRight1.close;
end;
procedure TBusJLZBForm.ComboBox1Change(Sender: TObject);
begin
if((curYear<>ComboBox1.text))then
begin
BitBtn2.Enabled:=false;
BitBtn4.Enabled:=false;
BitBtn6.Enabled:=false;
BitBtn3.Enabled:=False;
BitBtn5.Enabled:=False;
BitBtn8.Enabled:=false;
end else
begin
ButtonEnable(nil);
end;
end;
procedure TBusJLZBForm.QueryPageLeft1AfterInsert(DataSet: TDataSet);
begin
if(DataSet.FieldByName('指标代码').AsString='')then
DataSet.Cancel;
end;
procedure TBusJLZBForm.QueryPageLeft1AfterEdit(DataSet: TDataSet);
begin
if(((DataSet.FieldByName('指标类型').AsString='固定指标') or (DataSet.FieldByName('指标类型').AsString='')) and (not IsModifyIndex))then
DataSet.Cancel;
end;
procedure TBusJLZBForm.QueryPageLeft1AfterPost(DataSet: TDataSet);
begin
{ if(not IsModifyIndex) then
PostIndex:=DataSet.FieldByName('指标代码').AsString; }
end;
procedure TBusJLZBForm.QueryPageLeft1AfterScroll(DataSet: TDataSet);
var
SavePlace: TBookmark;
tmpstr:string;
begin
{ if(PostIndex<>'')then
begin
tmpstr:=PostIndex;
PostIndex:='';
SavePlace := DataSet.GetBookmark;
try
CheckBalanceRel(tmpstr);
except
try
CheckBalanceRel(tmpstr);
except
end;
end;
DataSet.GotoBookmark(SavePlace);
DataSet.FreeBookmark(SavePlace);
end; }
end;
procedure TBusJLZBForm.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if(Key=Char(VK_RETURN))then
DBGrid1.DataSource.DataSet.Next;
end;
procedure TBusJLZBForm.DBGrid2KeyPress(Sender: TObject; var Key: Char);
begin
if(Key=Char(VK_RETURN))then
DBGrid2.DataSource.DataSet.Next;
end;
procedure TBusJLZBForm.SpeedButton1Click(Sender: TObject);
begin
if(CitySelectForm.showmodal=mrok)then
BusJLZBForm.Edit9.Text:=CitySelectForm.Edit1.Text;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -