⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 busscalezbunit.pas

📁 公交行业的管理系统
💻 PAS
📖 第 1 页 / 共 2 页
字号:
                 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 + -