📄 weizhangdatoutdlg.~cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "WeiZhangDatOutDLg.h"
#include <IniFiles.hpp>
#include "stdio.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TDat_OutForm *Dat_OutForm;
//---------------------------------------------------------------------------
__fastcall TDat_OutForm::TDat_OutForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TDat_OutForm::BitBtnFileChoiceClick(TObject *Sender)
{
if( SaveDialogThe->Execute())
{
FileNameEdit->Text = SaveDialogThe->FileName;
LayoutFileName = FileNameEdit->Text ;
BitBtnBeginLayout->Enabled = true ;
}
}
//---------------------------------------------------------------------------
void __fastcall TDat_OutForm::BitBtnBeginLayoutClick(TObject *Sender)
{
if( FileNameEdit->Text.IsEmpty() )
{
ShowMessage("请选择导出数据文件!");
FileNameEdit->Focused() ;
return;
}
LayoutDataInfo();
LabelLayout->Visible = false;
ProgressBarThe->Visible = false;
BitBtnClearData->Enabled = true ;
}
//---------------------------------------------------------------------------
void __fastcall TDat_OutForm::BitBtnFinishClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TDat_OutForm::RadioButtonAllDataClick(TObject *Sender)
{
if (RadioButtonAllData->Checked )
{
LabelFrom->Enabled = false;
LabelTo->Enabled = false;
DateTimePickerStart->Enabled = false;
DateTimePickerEnd->Enabled = false;
}
}
//---------------------------------------------------------------------------
void __fastcall TDat_OutForm::RadioButtonAssignTimeClick(TObject *Sender)
{
if (RadioButtonAssignTime->Checked )
{
LabelFrom->Enabled = true;
LabelTo->Enabled = true;
DateTimePickerStart->Enabled = true;
DateTimePickerEnd->Enabled = true;
}
}
//---------------------------------------------------------------------------
void __fastcall TDat_OutForm::LayoutDataInfo()
{
FILE *fpInfo = fopen(FileNameEdit->Text.c_str() , "wt");
if( fpInfo == NULL)
{
ShowMessage("无法打开导出违章数据文件!");
return;
}
fprintf(fpInfo, "%-15s","地区/城市");
fprintf(fpInfo, "%-25s" ,"资金收入");
fprintf(fpInfo ,"%-25s" ,"资金支出" );
fprintf(fpInfo, "%-25s" ,"资金余额");
fprintf(fpInfo, "%-13s","入录日期");
fprintf(fpInfo, "%-13s" ,"入录时间");
fprintf(fpInfo ,"%-65s" ,"财务摘要");
fprintf(fpInfo, "\n" );
AnsiString BeginRq, EndRq ,SQLStr;
if( RadioButtonAssignTime->Checked||CheckBoxDataOut->Checked&&!RadioButtonAllData->Checked )
{
if(RadioButtonAssignTime->Checked&&!CheckBoxDataOut->Checked)
{
BeginRq = DateTimePickerStart->Date.FormatString("yyyy-mm-dd") ;
EndRq = DateTimePickerEnd->Date.FormatString("yyyy-mm-dd");
SQLStr = "SELECT * FROM MMTable where RiQi >= '" + BeginRq + "' And RiQi <= '"+ EndRq + "' ";
}
else if(CheckBoxDataOut->Checked)
{
BeginRq = DateTimePickerStart->Date.FormatString("yyyy-mm-dd") ;
EndRq = DateTimePickerEnd->Date.FormatString("yyyy-mm-dd");
SQLStr = "SELECT * FROM MMTable where RiQi >= '" + BeginRq + "' And RiQi <= '"+ EndRq + "' and DiShi='"+ComboBoxDataOut->Text.Trim()+"' ";
}
}
else if( RadioButtonAllData->Checked||CheckBoxDataOut->Checked&&!RadioButtonAssignTime->Checked )
{
if(!CheckBoxDataOut->Checked)
{
SQLStr = "SELECT * FROM MMTable ";
}
else
SQLStr = "SELECT * FROM MMTable where DiShi='"+ComboBoxDataOut->Text.Trim()+"'";
}
QueryInfo->Close();
QueryInfo->SQL->Clear() ;
QueryInfo->SQL->Add( SQLStr );
QueryInfo->Open() ;
QueryInfo->Active = true ;
ProgressBarThe->Min = 0 ;
ProgressBarThe->Max = QueryInfo->RecordCount;
AnsiString DiShi,ShouRu,ZhiChu,YuE,RiQi,ShiJian,ZhaiYao;
LabelLayout->Visible = true;
ProgressBarThe->Visible = true;
Application->ProcessMessages() ;
QueryInfo->First() ;
for(int i = 0 ;i < QueryInfo->RecordCount ; i++)
{
ProgressBarThe->Position = i;
DiShi= QueryInfo->FieldByName("DiShi")->AsString ;
ShouRu= QueryInfo->FieldByName("ShouRu")->AsString;
ZhiChu= QueryInfo->FieldByName("ZhiChu")->AsString;
YuE = QueryInfo->FieldByName("YuE")->AsString;
RiQi= QueryInfo->FieldByName("RiQi")->AsString;
ShiJian = QueryInfo->FieldByName("ShiJian")->AsString;
ZhaiYao = QueryInfo->FieldByName("ZhaiYao")->AsString;
fprintf(fpInfo, "%-15s",DiShi.c_str());
fprintf(fpInfo, "%-25s" ,ShouRu.c_str());
fprintf(fpInfo ,"%-25s" ,ZhiChu.c_str());
fprintf(fpInfo, "%-25s" ,YuE.c_str());
fprintf(fpInfo, "%-13s",RiQi.c_str());
fprintf(fpInfo, "%-13s" ,ShiJian.c_str());
fprintf(fpInfo ,"%-65s" ,ZhaiYao.c_str());
fprintf(fpInfo, "\n" );
QueryInfo->Next();
}
fclose(fpInfo);
QueryInfo->Close() ;
}
//---------------------------------------------------------------------------
void __fastcall TDat_OutForm::CheckBoxDataOutClick(TObject *Sender)
{
if(CheckBoxDataOut->Checked)
{
ComboBoxDataOut->Enabled=true;
CountryEdit->Enabled=true;
}
else
{
ComboBoxDataOut->Enabled=false;
CountryEdit->Enabled=false;
ComboBoxDataOut->Text="";
}
}
//---------------------------------------------------------------------------
void __fastcall TDat_OutForm::FormShow(TObject *Sender)
{
CheckBoxDataOut->Checked=false;
ComboBoxDataOut->Text="";
LabelLayout->Visible=false;
ProgressBarThe->Visible=false;
DateTimePickerStart->Date=Now().CurrentDate();
DateTimePickerEnd->Date=Now().CurrentDate();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -