📄 ydhsdw.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "YDhsdw.h"
#include "YDdatam.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "CSPIN"
#pragma resource "*.dfm"
TFhsdw *Fhsdw;
//---------------------------------------------------------------------------
__fastcall TFhsdw::TFhsdw(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFhsdw::SpeedButton4Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TFhsdw::FormCreate(TObject *Sender)
{
YDData->TBhsdw->Open();
if (YDData->TBhsdw->RecordCount>0)
{
DateTimePicker1->Date=YDData->TBhsdw->FieldByName("XT_QYRQ")->AsDateTime;
CSpinEdit1->Value=StrToInt(YDData->TBhsdw->FieldByName("XT_PQBM")->AsString.SubString(1,1));
CSpinEdit2->Value=StrToInt(YDData->TBhsdw->FieldByName("XT_PQBM")->AsString.SubString(3,1));
CSpinEdit3->Value=StrToInt(YDData->TBhsdw->FieldByName("XT_PQBM")->AsString.SubString(5,1));
CSpinEdit4->Value=StrToInt(YDData->TBhsdw->FieldByName("XT_PQBM")->AsString.SubString(7,1));
SpeedButton1->Enabled=false;
SpeedButton2->Enabled=false;
Panel1->Enabled=false;
}
else
{
Panel1->Enabled=true;
SpeedButton1->Enabled=true;
SpeedButton2->Enabled=false;
SpeedButton1->Click();
}
}
//---------------------------------------------------------------------------
void __fastcall TFhsdw::SpeedButton2Click(TObject *Sender)
{
if (Trim(DBEdit2->Text)=="")
{
MessageBox(NULL,"单位名称不能为空!","提示",MB_OK|MB_ICONWARNING);
return;
}
YDData->TBhsdw->FieldByName("XT_PQBM")->AsString=IntToStr(CSpinEdit1->Value)+"-"+
IntToStr(CSpinEdit2->Value)+"-"+IntToStr(CSpinEdit3->Value)+"-"+IntToStr(CSpinEdit4->Value);
YDData->TBhsdw->FieldByName("XT_QYRQ")->AsDateTime=DateTimePicker1->Date;
YDData->TBhsdw->Post();
SpeedButton1->Enabled=false;
SpeedButton2->Enabled=false;
Panel1->Enabled=false;
try
{
AnsiString SQLstmt,bq;
bq=DateToStr(DateTimePicker1->Date).SubString(1,4);
SQLstmt=SQLstmt+"CREATE TABLE "+"YHDA"+bq;
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"+bq;
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"+bq+"(";
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"+bq+"(";
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=bq;
Table1->Post();
}
Table1->Close();
delete Table1;
}
catch (...)
{
;
}
}
//---------------------------------------------------------------------------
void __fastcall TFhsdw::SpeedButton1Click(TObject *Sender)
{
YDData->TBhsdw->Append();
DateTimePicker1->Date=Date();
YDData->TBhsdw->FieldByName("XT_DWDM")->AsString="01";
SpeedButton1->Enabled=false;
SpeedButton2->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TFhsdw::FormKeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
{
SendMessage(this->Handle,WM_NEXTDLGCTL,0,0);
Key=0;
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -