?? busscalezbunit.pas
字號:
DealProc1('TO02','TO13','TO15','+');
DealProc1('TO02','TO02','TO17','+');
DealProc1('TO02','TO02','TO19','+');
DealProc1('TO02','TO02','TO21','+');
DealProc1('TO02','TO02','TO22','+');
DealProc1('TO02','TO02','TO23','+');
DealProc1('TO02','TO02','TO26','+');
DealProc1('TO02','TO02','TO28','+');
DealProc1('TO02','TO02','TO30','+');
DealProc1('TO02','TO02','TO32','+');
DealProc1('TO02','TO02','TO34','+');
end;
if((curRecordStr='TO14') or (curRecordStr='TO16') or (curRecordStr='TO18')
or (curRecordStr='TO20') or (curRecordStr='TO24') or (curRecordStr='TO26')
or (curRecordStr='TO29') or (curRecordStr='TO31') or (curRecordStr='TO33')
or (curRecordStr='TO35'))then
begin
DealProc1('TO03','TO14','TO16','+');
DealProc1('TO03','TO03','TO18','+');
DealProc1('TO03','TO03','TO20','+');
DealProc1('TO03','TO03','TO24','+');
DealProc1('TO03','TO03','TO26','+');
DealProc1('TO03','TO03','TO29','+');
DealProc1('TO03','TO03','TO31','+');
DealProc1('TO03','TO03','TO33','+');
DealProc1('TO03','TO03','TO35','+');
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 TBusScaleForm.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 TBusScaleForm.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 TBusScaleForm.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 TBusScaleForm.FormShow(Sender: TObject);
begin
PostIndex:='';
end;
procedure TBusScaleForm.RefreshPage;
begin
QueryPageLeft1.Next;
QueryPageLeft1.Prior;
QueryPageRight1.Next;
QueryPageRight1.Prior;
end;
procedure TBusScaleForm.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 TBusScaleForm.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);
OpenAllPage;
AddPrnQuery;
curYear:= ComboBox1.Text;
if(ADOQPrintMon.RecordCount<=0)then
begin
MessageBox(self.Handle,'沒有數據','消息',MB_OK);
end;
end;
function TBusScaleForm.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+'''');
try
ADOQPrintMon.Open;
AddPrnQuery:=true;
except
AddPrnQuery:=false;
end;
end;
procedure TBusScaleForm.BitBtn7Click(Sender: TObject);
begin
Close;
end;
procedure TBusScaleForm.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),'CityScale');
iRow := 1 ;
iRecNum := 1 ;
ADOQPrintMon.First;
for i:=4 to 27 do
begin
WriteCell(i,4,Converter(ADOQPrintMon.FieldByName('本年實際').AsString));
ADOQPrintMon.Next;
end;
for i:=4 to 28 do
begin
WriteCell(i,8,Converter(ADOQPrintMon.FieldByName('本年實際').AsString));
ADOQPrintMon.Next;
end;
PrintExcelShow;
PrintPreview;
CloseActiveBook;
end;
procedure TBusScaleForm.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 TBusScaleForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
QueryPageLeft1.close;
QueryPageRight1.close;
end;
procedure TBusScaleForm.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 TBusScaleForm.QueryPageLeft1AfterInsert(DataSet: TDataSet);
begin
if(((DataSet.FieldByName('指標類型').AsString='固定指標') or (DataSet.FieldByName('指標類型').AsString='')) and (not IsModifyIndex))then
DataSet.Cancel;
end;
procedure TBusScaleForm.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if(Key=Char(VK_RETURN))then
DBGrid1.DataSource.DataSet.Next;
end;
procedure TBusScaleForm.DBGrid2KeyPress(Sender: TObject; var Key: Char);
begin
if(Key=Char(VK_RETURN))then
DBGrid2.DataSource.DataSet.Next;
end;
procedure TBusScaleForm.SpeedButton1Click(Sender: TObject);
begin
if(CitySelectForm.showmodal=mrok)then
BusScaleForm.Edit9.Text:=CitySelectForm.Edit1.Text;
end;
procedure TBusScaleForm.QueryPageLeft1AfterEdit(DataSet: TDataSet);
begin
if(((DataSet.FieldByName('指標類型').AsString='固定指標') or (DataSet.FieldByName('指標類型').AsString='')) and (not IsModifyIndex))then
DataSet.Cancel;
end;
procedure TBusScaleForm.QueryPageLeft1AfterPost(DataSet: TDataSet);
begin
if(not IsModifyIndex) then
PostIndex:=DataSet.FieldByName('指標代碼').AsString;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -