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

📄 ydhsrltj.cpp

📁 营业用电管理系统(网络版)是本公司推出的新一代软件产品
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "YDhsrltj.h"
#include "YDdatam.h"
#include "YDmain.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFhsrltj *Fhsrltj;
//---------------------------------------------------------------------------
__fastcall TFhsrltj::TFhsrltj(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFhsrltj::FormCreate(TObject *Sender)
{
 YDData->TBxlcs->Open();
 YDData->TBxlcs->First();
 while (!YDData->TBxlcs->Eof)
   {
     ComboBox1->Items->Add(YDData->TBxlcs->FieldByName("XLMC")->AsString);
     YDData->TBxlcs->Next();
   }
 YDData->TBpqdm->Open();
 YDData->TBpqdm->First();
 while (!YDData->TBpqdm->Eof)
 {
   ComboBox2->Items->Add(Trim(YDData->TBpqdm->FieldByName("PQDM")->AsString)+":"+Trim(YDData->TBpqdm->FieldByName("PQMC")->AsString));
   YDData->TBpqdm->Next();
 }
 TQuery *Query1=new TQuery(this);
 Query1->DatabaseName="YDDB";
 Query1->SQL->Add("select 'mc'=RTRIM(hhhh)+':'+RTRIM(yhmc) from yhda0000 where ydfl='计量箱'");
 Query1->ExecSQL();
 Query1->Open();
 Query1->First();
 while (!Query1->Eof)
   {
     ComboBox3->Items->Add(Query1->FieldByName("mc")->AsString);
     Query1->Next();
   }
 delete Query1;
}
//---------------------------------------------------------------------------
void __fastcall TFhsrltj::SpeedButton3Click(TObject *Sender)
{
 Close();        
}
//---------------------------------------------------------------------------
void __fastcall TFhsrltj::FormClose(TObject *Sender, TCloseAction &Action)
{

 YDData->TBpqdm->Close();
 YDData->TBxlcs->Close();
 Query1->Close();
 Query2->Close();
 Query3->Close();
 Query4->Close();
 Fmain->gnjs(Fmain->tcjc);

}
//---------------------------------------------------------------------------


void __fastcall TFhsrltj::ScrollBar2Change(TObject *Sender)
{
  if (ScrollBar2->Enabled )
  DBChart1->View3DOptions->Orthogonal=false;
  if (dynamic_cast<TPieSeries*>(DBChart1->Series[0]))
    DBChart1->View3DOptions->Elevation=ScrollBar2->Position;
  else
    DBChart1->View3DOptions->Rotation=ScrollBar2->Position;

}
//---------------------------------------------------------------------------

void __fastcall TFhsrltj::ScrollBar3Change(TObject *Sender)
{
  if (ScrollBar3->Enabled) {
    DBChart1->View3DOptions->Orthogonal=false;
    DBChart1->View3DOptions->Elevation=ScrollBar3->Position;
  }

}
//---------------------------------------------------------------------------


void __fastcall TFhsrltj::SpeedButton1Click(TObject *Sender)
{

 AnsiString pq=ComboBox2->Text.SubString(2,ComboBox1->Text.AnsiPos(")")-2);
 Query1->SQL->Clear();
 if (RadioButton1->Checked)
   Query1->SQL->Add("select '  户别'=YDFL,'  户数'=COUNT(*),'  容量'=SUM(syrl),'  负荷'=SUM(FH) FROM YHDA0000 GROUP BY YDFL");
 if (RadioButton2->Checked)
   Query1->SQL->Add("select '  户别'=YDFL,'  户数'=COUNT(*),'  容量'=SUM(syrl),'  负荷'=SUM(FH) FROM YHDA0000 WHERE KLBS='"+ComboBox1->Text+"' GROUP BY YDFL");
 if (RadioButton3->Checked)
   Query1->SQL->Add("select '  户别'=YDFL,'  户数'=COUNT(*),'  容量'=SUM(syrl),'  负荷'=SUM(FH) FROM YHDA0000 WHERE XZQ LIKE '"+ComboBox2->Text.SubString(1,ComboBox2->Text.AnsiPos(":")-1)+"%' GROUP BY YDFL");
 if (RadioButton4->Checked)
   Query1->SQL->Add("select '  户别'=YDFL,'  户数'=COUNT(*),'  容量'=SUM(syrl),'  负荷'=SUM(FH) FROM YHDA0000 WHERE tbjs='"+ComboBox3->Text.SubString(1,ComboBox3->Text.AnsiPos(":")-1)+"' GROUP BY YDFL");

 Query1->ExecSQL();
 Query1->Open();
 Query1->First();
 int x1=0,x2=0,x3=0;
 while (!Query1->Eof)
  {
    x1=x1+Query1->Fields->Fields[1]->AsInteger;
    x2=x2+Query1->Fields->Fields[2]->AsInteger;
    x3=x3+Query1->Fields->Fields[3]->AsInteger;
   Query1->Next();
  }
 StringGrid1->RowCount=Query1->RecordCount+2;
 StringGrid1->ColCount=Query1->FieldCount;
 Query1->First();
 for (int i=0;i<Query1->RecordCount;i++)
   {
    for (int j=0;j<Query1->FieldCount;j++)
     {
       if (i==0)
          StringGrid1->Cells[j][0]=Query1->Fields->Fields[j]->FieldName;
          StringGrid1->Cells[j][i+1]=Query1->Fields->Fields[j]->AsString;
     }
     Query1->Next();
   }
 int h=Query1->RecordCount+1;;
 StringGrid1->Cells[0][h]="  合计";
 StringGrid1->Cells[1][h]=IntToStr(x1);
 StringGrid1->Cells[2][h]=IntToStr(x2);
 StringGrid1->Cells[3][h]=IntToStr(x3);
//
 Query3->Close();
 Query3->SQL->Clear();
 if (RadioButton1->Checked)
   Query3->SQL->Add("select '表别'=DBLB,'其中暂停'=COUNT(*) FROM DBDA0000 WHERE YXZT='停运' GROUP BY DBLB");
 if (RadioButton2->Checked)
   Query3->SQL->Add("select '表别'=DBLB,'其中暂停'=COUNT(*) FROM DBDA0000,yhda0000 WHERE dbda0000.hhhh=yhda0000.hhhh and DBDA0000.YXZT='停运' and yhda0000.KLBS='"+ComboBox1->Text+"' GROUP BY DBLB");
 if (RadioButton3->Checked)
   Query3->SQL->Add("select '表别'=DBLB,'其中暂停'=COUNT(*) FROM DBDA0000,yhda0000 WHERE dbda0000.hhhh=yhda0000.hhhh and DBDA0000.YXZT='停运' and yhda0000.XZQ LIKE '"+ComboBox2->Text.SubString(1,ComboBox2->Text.AnsiPos(":")-1)+"%' GROUP BY DBLB");
 if (RadioButton4->Checked)
   Query3->SQL->Add("select '表别'=DBLB,'其中暂停'=COUNT(*) FROM DBDA0000,yhda0000 WHERE dbda0000.hhhh=yhda0000.hhhh and DBDA0000.YXZT='停运' and yhda0000.tbjs='"+ComboBox3->Text.SubString(1,ComboBox3->Text.AnsiPos(":")-1)+"' GROUP BY DBLB");

 Query3->ExecSQL();
 Query3->Open();
 Query3->First();
 int y2=0;
 AnsiString zt[2][8];
 for (int i=0;i<Query3->RecordCount;i++)
   {
       for (int j=0;j<2;j++)
          {
           zt[j][i]=Query3->Fields->Fields[j]->AsString;
          }
      y2=y2+Query3->Fields->Fields[1]->AsInteger;
     Query3->Next();
   }

 Query2->Close();
 Query2->SQL->Clear();
  if (RadioButton1->Checked)
     Query2->SQL->Add("select '表别'=DBLB,'表卡户数'=COUNT(*) FROM DBDA0000,YHDA0000 GROUP BY DBLB");
  if (RadioButton2->Checked)
     Query2->SQL->Add("select '表别'=DBLB,'表卡户数'=COUNT(*) FROM DBDA0000,YHDA0000 WHERE dbda0000.hhhh=yhda0000.hhhh and yhda0000.KLBS='"+ComboBox1->Text+"' GROUP BY DBLB");
  if (RadioButton3->Checked)
     Query2->SQL->Add("select '表别'=DBLB,'表卡户数'=COUNT(*) FROM DBDA0000,YHDA0000 WHERE dbda0000.hhhh=yhda0000.hhhh and yhda0000.XZQ LIKE '"+ComboBox2->Text.SubString(1,ComboBox2->Text.AnsiPos(":")-1)+"%' GROUP BY DBLB");
  if (RadioButton4->Checked)
     Query2->SQL->Add("select '表别'=DBLB,'表卡户数'=COUNT(*) FROM DBDA0000,YHDA0000 WHERE dbda0000.hhhh=yhda0000.hhhh and yhda0000.tbjs='"+ComboBox3->Text.SubString(1,ComboBox3->Text.AnsiPos(":")-1)+"' GROUP BY DBLB");

 Query2->ExecSQL();
 Query2->Open();
 Query2->First();
 int y1=0;
 while (!Query2->Eof)
  {
    y1=y1+Query2->Fields->Fields[1]->AsInteger;
    Query2->Next();
  }
 StringGrid2->RowCount=Query2->RecordCount+2;
 StringGrid2->ColCount=Query2->FieldCount+1;
 Query2->First();
  StringGrid2->Cells[2][0]="其中暂停";
 for (int i=0;i<Query2->RecordCount;i++)
   {
    for (int j=0;j<Query2->FieldCount;j++)
     {
       if (i==0)
          StringGrid2->Cells[j][0]=Query2->Fields->Fields[j]->FieldName;
          StringGrid2->Cells[j][i+1]=Query2->Fields->Fields[j]->AsString;
          for (int k=0;k<8;k++)
           {
            if (Query2->Fields->Fields[0]->AsString==zt[0][k])
            StringGrid2->Cells[2][i+1]=zt[1][k];
           }
     }
     Query2->Next();
   }
 int b=Query2->RecordCount+1;
 StringGrid2->Cells[0][b]="合计";
 StringGrid2->Cells[1][b]=IntToStr(y1);
 StringGrid2->Cells[2][b]=IntToStr(y2);
 Query4->Close();
 Query4->SQL->Clear();
 if (RadioButton1->Checked)
   Query4->SQL->Add("select kplb,'btsl'=count(*) from yhda0000 where kplb<>'无' and kplb<>'    ' group by kplb");
 if (RadioButton2->Checked)
   Query4->SQL->Add("select kplb,'btsl'=count(*) from yhda0000 where kplb<>'无' and kplb<>'    ' and KLBS='"+ComboBox1->Text+"' group by kplb");
 if (RadioButton3->Checked)
   Query4->SQL->Add("select kplb,'btsl'=count(*) from yhda0000 where kplb<>'无' and kplb<>'    ' and XZQ LIKE '"+ComboBox2->Text.SubString(1,ComboBox2->Text.AnsiPos(":")-1)+"%' group by kplb");
 if (RadioButton4->Checked)
   Query4->SQL->Add("select kplb,'btsl'=count(*) from yhda0000 where kplb<>'无' and kplb<>'    ' and tbjs='"+ComboBox3->Text.SubString(1,ComboBox3->Text.AnsiPos(":")-1)+"' group by kplb");
 Query4->ExecSQL();
 Query4->Open();
 int btsl=0;
 Label8->Caption="";
 Label9->Caption="";
 Query4->First();
 while (!Query4->Eof)
   {
    if (Query4->FieldByName("kplb")->AsString=="专用")
      Label8->Caption=IntToStr(Query4->FieldByName("btsl")->AsInteger)+"  台";
    else
      Label9->Caption=IntToStr(Query4->FieldByName("btsl")->AsInteger)+"  台";
      Query4->Next();
    btsl=btsl+Query4->FieldByName("btsl")->AsInteger;
   }
   Label10->Caption=IntToStr(btsl)+"  台";
 }
//---------------------------------------------------------------------------







void __fastcall TFhsrltj::ScrollBar1Change(TObject *Sender)
{
  DBChart1->Chart3DPercent=ScrollBar1->Position;

}
//---------------------------------------------------------------------------


void __fastcall TFhsrltj::SpeedButton2Click(TObject *Sender)
{
  DBChart2->Print();  
 }
//---------------------------------------------------------------------------

void __fastcall TFhsrltj::ScrollBar5Change(TObject *Sender)
{
  if (ScrollBar5->Enabled )
  DBChart2->View3DOptions->Orthogonal=false;
  if (dynamic_cast<TPieSeries*>(DBChart2->Series[0]))
    DBChart2->View3DOptions->Elevation=ScrollBar5->Position;
  else
    DBChart2->View3DOptions->Rotation=ScrollBar5->Position;

}
//---------------------------------------------------------------------------

void __fastcall TFhsrltj::ScrollBar4Change(TObject *Sender)
{
  DBChart2->Chart3DPercent=ScrollBar4->Position;

}
//---------------------------------------------------------------------------

void __fastcall TFhsrltj::ScrollBar6Change(TObject *Sender)
{
  if (ScrollBar6->Enabled) {
    DBChart2->View3DOptions->Orthogonal=false;
    DBChart2->View3DOptions->Elevation=ScrollBar6->Position;
  }

}
//---------------------------------------------------------------------------

void __fastcall TFhsrltj::RadioButton1Click(TObject *Sender)
{
 ComboBox1->Text="";
 ComboBox1->Enabled=false;
 ComboBox2->Text="";
 ComboBox2->Enabled=false;
 ComboBox3->Text="";
 ComboBox3->Enabled=false;

}
//---------------------------------------------------------------------------

void __fastcall TFhsrltj::RadioButton2Click(TObject *Sender)
{
 ComboBox1->Text="";
 ComboBox1->Enabled=true;
 ComboBox2->Text="";
 ComboBox2->Enabled=false;
 ComboBox3->Text="";
 ComboBox3->Enabled=false;

}
//---------------------------------------------------------------------------

void __fastcall TFhsrltj::RadioButton3Click(TObject *Sender)
{
 ComboBox1->Text="";
 ComboBox1->Enabled=false;
 ComboBox2->Text="";
 ComboBox2->Enabled=true;
 ComboBox3->Text="";
 ComboBox3->Enabled=false;

}
//---------------------------------------------------------------------------

void __fastcall TFhsrltj::RadioButton4Click(TObject *Sender)
{
 ComboBox1->Text="";
 ComboBox1->Enabled=false;
 ComboBox2->Text="";
 ComboBox2->Enabled=false;
 ComboBox3->Text="";
 ComboBox3->Enabled=true;

}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -