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

📄 ydymjz.cpp

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

#include <vcl.h>
#pragma hdrstop

#include "YDymjz.h"
#include "YDdatam.h"
#include "YDmain.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFymjz *Fymjz;
//---------------------------------------------------------------------------
__fastcall TFymjz::TFymjz(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFymjz::FormCreate(TObject *Sender)
{

 YDData->TBxtcs->Open();
 Label3->Caption=YDData->TBxtcs->FieldByName("XT_HSQX")->AsString.SubString(1,4)+"年"+
YDData->TBxtcs->FieldByName("XT_HSQX")->AsString.SubString(6,2)+"月";
}
//---------------------------------------------------------------------------
void __fastcall TFymjz::SpeedButton3Click(TObject *Sender)
{
 Close();
}
//---------------------------------------------------------------------------
void __fastcall TFymjz::SpeedButton1Click(TObject *Sender)
{

 ProgressBar1->Position=0;
 TQuery *Qcsjc=new TQuery(this);
 Qcsjc->DatabaseName="YDDB";
 Qcsjc->SQL->Add("SELECT * FROM dbda0000 WHERE cszt='1'");
 Qcsjc->ExecSQL();
 Qcsjc->Open();
 if (Qcsjc->RecordCount>0)
   {
      MessageBox(NULL,"本月抄算尚未结束,不能结转!","提示",MB_OK|MB_ICONWARNING);
      Qcsjc->Close();
      delete Qcsjc;
      ProgressBar1->Position=0;
      return;
   }
 Qcsjc->Close();
 delete Qcsjc;
 AnsiString bq=YDData->TBxtcs->FieldByName("XT_HSQX")->AsString;
 AnsiString hsqx;
 if (bq.SubString(6,2)=="12")
   {
   try
   {
    AnsiString SQLstmt;
    hsqx=IntToStr(StrToInt(bq.SubString(1,4))+1)+"-"+"01";
    SQLstmt=SQLstmt+"CREATE TABLE "+"YHDA"+IntToStr(StrToInt(bq.SubString(1,4))+1);
    SQLstmt=SQLstmt+"(yhda_id int NULL,";
    SQLstmt=SQLstmt+"hsqx char(7) NULL,";
    SQLstmt=SQLstmt+"hhhh char(10) NULL,";
    SQLstmt=SQLstmt+"yhmc char(20) NULL,";
    SQLstmt=SQLstmt+"yhdz char(40) NULL,";
    SQLstmt=SQLstmt+"gds char(30) NULL,";
    SQLstmt=SQLstmt+"klbs char(30) NULL,";
    SQLstmt=SQLstmt+"dz char(30) NULL,";
    SQLstmt=SQLstmt+"xzq char(12) NULL,";
    SQLstmt=SQLstmt+"ydfl char(6) NULL,";
    SQLstmt=SQLstmt+"gddy char(16) NULL,";
    SQLstmt=SQLstmt+"byqxh char(12) NULL,";
    SQLstmt=SQLstmt+"jffs char(8) NULL,";
    SQLstmt=SQLstmt+"kplb char(4) NULL,";
    SQLstmt=SQLstmt+"bzrl decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"syrl decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"jbdj decimal(5, 2) NULL,";
    SQLstmt=SQLstmt+"jbdf decimal(12, 2) NULL,";
    SQLstmt=SQLstmt+"yxzt char(4) NULL,";
    SQLstmt=SQLstmt+"zj char(12) NULL,";
    SQLstmt=SQLstmt+"yxts decimal(2, 0) NULL,";
    SQLstmt=SQLstmt+"bz char(2) NULL,";
    SQLstmt=SQLstmt+"zjwgdl decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"zjygdl decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"bzll decimal(4, 2) NULL,";
    SQLstmt=SQLstmt+"byll decimal(5, 2) NULL,";
    SQLstmt=SQLstmt+"jfbl decimal(8, 5) NULL,";
    SQLstmt=SQLstmt+"lldf decimal(12, 2) NULL,";
    SQLstmt=SQLstmt+"sdl decimal(10, 2) NULL,";
    SQLstmt=SQLstmt+"dddf decimal(12, 2) NULL,";
    SQLstmt=SQLstmt+"fjf decimal(12, 2) NULL,";
    SQLstmt=SQLstmt+"zjdf decimal(12, 2) NULL,";
    SQLstmt=SQLstmt+"wgf decimal(12, 2) NULL,";
    SQLstmt=SQLstmt+"www decimal(12, 2) NULL,";
    SQLstmt=SQLstmt+"hjdf decimal(12, 2) NULL,";
    SQLstmt=SQLstmt+"tjbsdl decimal(10, 2) NULL,";
    SQLstmt=SQLstmt+"tjxsdl decimal(10, 2) NULL,";
    SQLstmt=SQLstmt+"yjdfye decimal(12, 2) NULL,";
    SQLstmt=SQLstmt+"syye decimal(18, 2) NULL,";
    SQLstmt=SQLstmt+"fh decimal(10, 3) NULL,";
    SQLstmt=SQLstmt+"tbjs char(12) NULL,";
    SQLstmt=SQLstmt+"bzsj datetime NULL,";
    SQLstmt=SQLstmt+"jfrq int NULL,";
    SQLstmt=SQLstmt+"sfrq datetime NULL,";
    SQLstmt=SQLstmt+"sfy char(10) NULL,";
    SQLstmt=SQLstmt+"skfs char(10) NULL,";
    SQLstmt=SQLstmt+"fpbh char(10) NULL,";
    SQLstmt=SQLstmt+"cby char(10) NULL,";
    SQLstmt=SQLstmt+"cl decimal(8, 2) NULL,";
    SQLstmt=SQLstmt+"cszt char(1) NULL,";
    SQLstmt=SQLstmt+"BS_ZYG decimal(18, 2) NULL ,";
    SQLstmt=SQLstmt+"BS_ZWG decimal(18, 2) NULL ,";
    SQLstmt=SQLstmt+"BS_YGSS decimal(18, 2) NULL ,";
    SQLstmt=SQLstmt+"BS_WGSS decimal(18, 2) NULL ,";
    SQLstmt=SQLstmt+"BS_YGBSL int NULL ,";
    SQLstmt=SQLstmt+"BS_WGBSL int NULL)";
    YDData->YYYD->Execute(SQLstmt, NULL, false, NULL);     //创建新年度电表数据表
    SQLstmt="";
    SQLstmt=SQLstmt+"CREATE TABLE "+"DBDA"+IntToStr(StrToInt(bq.SubString(1,4))+1);
    SQLstmt=SQLstmt+"(db_id int NULL,";
    SQLstmt=SQLstmt+"hsqx char(7) NULL,";
    SQLstmt=SQLstmt+"hhhh char(10) NULL,";
    SQLstmt=SQLstmt+"gddy char(16) NULL,";
    SQLstmt=SQLstmt+"hydm char(40) NULL,";
    SQLstmt=SQLstmt+"bh char(12) NULL,";
    SQLstmt=SQLstmt+"dbbh char(4) NULL,";
    SQLstmt=SQLstmt+"bz char(10) NULL,";
    SQLstmt=SQLstmt+"bbzj char(10) NULL,";
    SQLstmt=SQLstmt+"zjbx char(4) NULL,";
    SQLstmt=SQLstmt+"dblb char(6) NULL,";
    SQLstmt=SQLstmt+"p_fg char(1) NULL,";
    SQLstmt=SQLstmt+"	fgp char(8) NULL,";
    SQLstmt=SQLstmt+"bs char(4) NULL,";
    SQLstmt=SQLstmt+"jsbs decimal(8, 0) NULL,";
    SQLstmt=SQLstmt+"xshbs char(1) NULL,";
    SQLstmt=SQLstmt+"xs int NULL,";
    SQLstmt=SQLstmt+"fxcjdl decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"bl decimal(6, 0) NULL,";
    SQLstmt=SQLstmt+"ws decimal(1, 0) NULL,";
    SQLstmt=SQLstmt+"fx char(4) NULL,";
    SQLstmt=SQLstmt+"bsf decimal(4, 0) NULL,";
    SQLstmt=SQLstmt+"sycj decimal(10, 1) NULL,";
    SQLstmt=SQLstmt+"bycj decimal(10, 1) NULL,";
    SQLstmt=SQLstmt+"cs decimal(10, 1) NULL,";
    SQLstmt=SQLstmt+"bldl decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"fldl decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"zjdl decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"lsdl decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"hbdl decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"tzdl decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"bsdl decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"xsdl decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"hjdl decimal(18, 0) NULL,";
    SQLstmt=SQLstmt+"zdl decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"blf decimal(6, 0) NULL,";
    SQLstmt=SQLstmt+"wsf decimal(1, 0) NULL,";
    SQLstmt=SQLstmt+"fxf char(4) NULL,";
    SQLstmt=SQLstmt+"bsff decimal(4, 0) NULL,";
    SQLstmt=SQLstmt+"sycjf decimal(10, 1) NULL,";
    SQLstmt=SQLstmt+"bycjf decimal(10, 1) NULL,";
    SQLstmt=SQLstmt+"csf decimal(10, 1) NULL,";
    SQLstmt=SQLstmt+"bldlf decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"fldlf decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"zjdlf decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"lsdlf decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"hbdlf decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"tzdlf decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"bsdlf decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"xsdlf decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"hjdlf decimal(18, 0) NULL,";
    SQLstmt=SQLstmt+"zdlf decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"blg decimal(6, 0) NULL,";
    SQLstmt=SQLstmt+"wsg decimal(1, 0) NULL,";
    SQLstmt=SQLstmt+"fxg char(4) NULL,";
    SQLstmt=SQLstmt+"bsfg decimal(4, 0) NULL,";
    SQLstmt=SQLstmt+"sycjg decimal(10, 1) NULL,";
    SQLstmt=SQLstmt+"bycjg decimal(10, 1) NULL,";
    SQLstmt=SQLstmt+"csg decimal(10, 1) NULL,";
    SQLstmt=SQLstmt+"bldlg decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"fldlg decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"zjdlg decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"lsdlg decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"hbdlg decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"tzdlg decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"bsdlg decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"xsdlg decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"hjdlg decimal(18, 0) NULL,";
    SQLstmt=SQLstmt+"zdlg decimal(10, 0) NULL,";
    SQLstmt=SQLstmt+"bzsm char(20) NULL,";
    SQLstmt=SQLstmt+"azsj char(10) NULL,";
    SQLstmt=SQLstmt+"jysj char(10) NULL,";
    SQLstmt=SQLstmt+"sccj char(20) NULL,";
    SQLstmt=SQLstmt+"xh char(10) NULL,";
    SQLstmt=SQLstmt+"dl char(10) NULL,";
    SQLstmt=SQLstmt+"dy char(10) NULL,";
    SQLstmt=SQLstmt+"cq char(4) NULL,";
    SQLstmt=SQLstmt+"yxzt char(4) NULL,";
    SQLstmt=SQLstmt+"cszt char(1) NULL)";
    YDData->YYYD->Execute(SQLstmt, NULL, false, NULL);     //创建新年度电表数据表
    SQLstmt="";
    SQLstmt=SQLstmt+"CREATE TABLE "+"DJKP"+IntToStr(StrToInt(bq.SubString(1,4))+1)+"(";
    SQLstmt=SQLstmt+"kp_id int NULL,";
    SQLstmt=SQLstmt+"hsqx char(7) NULL,";
    SQLstmt=SQLstmt+"hhhh char(10) NULL,";
    SQLstmt=SQLstmt+"klbs char(30) NULL,";
    SQLstmt=SQLstmt+"xzq char(12) NULL,";
    SQLstmt=SQLstmt+"dbbh char(4) NULL,";
    SQLstmt=SQLstmt+"gddy char(16) NULL,";
    SQLstmt=SQLstmt+"kh char(4) NULL,";
    SQLstmt=SQLstmt+"jsfsf char(14) NULL,";
    SQLstmt=SQLstmt+"jsfsp char(14) NULL,";
    SQLstmt=SQLstmt+"jsfsg char(14) NULL,";
    SQLstmt=SQLstmt+"lb char(16) NULL,";
    SQLstmt=SQLstmt+"ydfl char(8) NULL,";
    SQLstmt=SQLstmt+"pdbl char(12) NULL,";
    SQLstmt=SQLstmt+"gfbl char(12) NULL,";
    SQLstmt=SQLstmt+"dgbl char(12) NULL,";
    SQLstmt=SQLstmt+"dlf decimal(18, 0) NULL,";
    SQLstmt=SQLstmt+"djf decimal(8, 5) NULL,";
    SQLstmt=SQLstmt+"jef decimal(18, 2) NULL,";
    SQLstmt=SQLstmt+"dlp decimal(18, 0) NULL,";
    SQLstmt=SQLstmt+"djp decimal(8, 5) NULL,";
    SQLstmt=SQLstmt+"jep decimal(18, 2) NULL,";
    SQLstmt=SQLstmt+"dlg decimal(18, 0) NULL,";
    SQLstmt=SQLstmt+"djg decimal(8, 5) NULL,";
    SQLstmt=SQLstmt+"jeg decimal(18, 2) NULL,cszt char(1) NULL)";
    YDData->YYYD->Execute(SQLstmt, NULL, false, NULL);     //创建新年度电表数据表
    SQLstmt="";
    SQLstmt=SQLstmt+"CREATE TABLE "+"FJJJ"+IntToStr(StrToInt(bq.SubString(1,4))+1)+"(";
    SQLstmt=SQLstmt+"FJ_ID int NULL,";
    SQLstmt=SQLstmt+"HSQX char(7) NULL,";
    SQLstmt=SQLstmt+"FJ_HHHH char(10) NULL,";
    SQLstmt=SQLstmt+"FJ_KLBS char(30) NULL,";
    SQLstmt=SQLstmt+"FJ_XZQ char(12) NULL,";
    SQLstmt=SQLstmt+"FJ_DM char(2) NULL,";
    SQLstmt=SQLstmt+"FJ_MC char(12) NULL,";
    SQLstmt=SQLstmt+"FJ_DJ decimal(8, 5) NULL,";
    SQLstmt=SQLstmt+"FJ_DL decimal(18, 2) NULL,";
    SQLstmt=SQLstmt+"FJ_JE decimal(18, 2) NULL)";
    YDData->YYYD->Execute(SQLstmt, NULL, false, NULL);     //创建新年度电表数据表
    TTable *Table1=new TTable(this);
    Table1->DatabaseName="YDDB";
    Table1->TableName="H_YEAR";
    Table1->IndexFieldNames="Y_YEAR";
    Table1->Open();
    if (!Table1->FindKey(new TVarRec(IntToStr(StrToInt(bq.SubString(1,4))+1)),0) )
    {
     Table1->Append();
     Table1->FieldByName("Y_YEAR")->AsString=IntToStr(StrToInt(bq.SubString(1,4))+1);
     Table1->Post();
    }
    Table1->Close();
    delete Table1;
   }
    catch (...)
    {
     ProgressBar1->Position=0;
    }
   }
 else
   if (StrToInt(bq.SubString(6,2))>=9)
     hsqx=bq.SubString(1,4)+"-"+IntToStr(StrToInt(bq.SubString(6,2))+1);
   else
     hsqx=bq.SubString(1,4)+"-"+"0"+IntToStr(StrToInt(bq.SubString(6,2))+1);
 YDData->TBxtcs->Edit();
 YDData->TBxtcs->FieldByName("XT_HSQX")->AsString=hsqx;
 YDData->TBxtcs->Post();
 ProgressBar1->Position+=100/10;
 TTable *Table1=new TTable(this);
 Table1->DatabaseName="YDDB";
 Table1->TableName="YHDA0000";
 Table1->Open();
 TTable *Table2=new TTable(this);
 Table2->DatabaseName="YDDB";
 Table2->TableName="YHDA"+bq.SubString(1,4);
 Table2->Open();
 BatchMove1->Source =Table1;
 BatchMove1->Destination = Table2;
 BatchMove1->Mode = batAppend;
 BatchMove1->Execute();
 Table1->Close();
 Table2->Close();
 ProgressBar1->Position+=100/10;
 Table1->TableName="DBDA0000";
 Table1->Open();
 Table2->TableName="DBDA"+bq.SubString(1,4);
 Table2->Open();
 BatchMove1->Source =Table1;
 BatchMove1->Destination = Table2;
 BatchMove1->Mode = batAppend;
 BatchMove1->Execute();
 Table1->Close();
 Table2->Close();
 ProgressBar1->Position+=100/10;
 Table1->TableName="DJKP0000";
 Table1->Open();
 Table2->TableName="DJKP"+bq.SubString(1,4);
 Table2->Open();
 BatchMove1->Source =Table1;
 BatchMove1->Destination = Table2;
 BatchMove1->Mode = batAppend;
 BatchMove1->Execute();
 Table1->Close();
 Table2->Close();
 ProgressBar1->Position+=100/10;
 Table1->TableName="FJJJ0000";
 Table1->Open();
 Table2->TableName="FJJJ"+bq.SubString(1,4);
 Table2->Open();
 BatchMove1->Source =Table1;
 BatchMove1->Destination = Table2;
 BatchMove1->Mode = batAppend;
 BatchMove1->Execute();
 Table1->Close();
 Table2->Close();
   ProgressBar1->Position+=100/10;
   AnsiString sql;
   TQuery *Query1=new TQuery(this);
   Query1->DatabaseName="YDDB";
   sql="update yhda0000 set yjdfye=hjdf where cszt='2'";
   Query1->SQL->Add(sql);
   Query1->ExecSQL();
   ProgressBar1->Position+=100/10;
   Query1->SQL->Clear();
   sql="update yhda0000 set hsqx='"+hsqx+"',jbdf=0,zjygdl=0,zjwgdl=0,byll=0,jfbl=0,";
   sql=sql+"lldf=0,sdl=0,dddf=0,fjf=0,zjdf=0,wgf=0,www=0,hjdf=0,tjbsdl=0,tjxsdl=0,";
   sql=sql+"syye=syye+yjdfye,yjdfye=0,sfrq=NULL,skfs='',sfy='',fpbh='',cszt='0',bs_zyg=0,";
   sql=sql+"bs_zwg=0,bs_ygss=0,bs_wgss=0,bs_ygbsl=0,bs_wgbsl=0";
   Query1->SQL->Add(sql);
   Query1->ExecSQL();
  ProgressBar1->Position+=100/10;
  Query1->SQL->Clear();
  sql="update dbda0000 set hsqx='"+hsqx+"',fxcjdl=0,";
  sql=sql+"sycj=bycj,cs=0,bldl=0,fldl=0,zjdl=0,lsdl=0,hbdl=0,tzdl=0,bsdl=0,xsdl=0,hjdl=0,zdl=0,";
  sql=sql+"sycjf=bycjf,csf=0,bldlf=0,fldlf=0,zjdlf=0,lsdlf=0,hbdlf=0,tzdlf=0,bsdlf=0,xsdlf=0,hjdlf=0,zdlf=0,";
  sql=sql+"sycjg=bycjg,csg=0,bldlg=0,fldlg=0,zjdlg=0,lsdlg=0,hbdlg=0,tzdlg=0,bsdlg=0,xsdlg=0,hjdlg=0,zdlg=0,";
  sql=sql+"cszt='0'";
  Query1->SQL->Add(sql);
  Query1->ExecSQL();
  ProgressBar1->Position+=100/10;
  Query1->SQL->Clear();
  sql="update djkp0000 set hsqx='"+hsqx+"',";
  sql=sql+"dlp=0,jep=0,dlf=0,jef=0,dlg=0,jeg=0,cszt='0'";
  Query1->SQL->Add(sql);
  Query1->ExecSQL();
  ProgressBar1->Position+=100/10;
  Query1->SQL->Clear();
  sql="update fjjj0000 set hsqx='"+hsqx+"',";
  sql=sql+"fj_dl=0,fj_je=0";
  Query1->SQL->Add(sql);
  Query1->ExecSQL();
  ProgressBar1->Position+=100/10;
  delete Table1;
  delete Table2;
  delete Query1;
  SpeedButton1->Enabled=false;
}
//---------------------------------------------------------------------------

void __fastcall TFymjz::FormClose(TObject *Sender, TCloseAction &Action)
{

 YDData->TBxtcs->Close();
 Fmain->gnjs(Fmain->tcjc);
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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