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

📄 weizhangdatindlg.cpp

📁 用C++ Builder编写的个人财务管理软件
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "WeiZhangDatInDLg.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TDat_InForm *Dat_InForm;
//---------------------------------------------------------------------------
__fastcall TDat_InForm::TDat_InForm(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TDat_InForm::BitBtnFileChoiceClick(TObject *Sender)
{
if(OpenDialogThe->Execute())
{
  FileNameEdit->Text=OpenDialogThe->FileName;
  BitBtnLayIn->Enabled=true;
}
}
//---------------------------------------------------------------------------

void __fastcall TDat_InForm::BitBtnFinishClick(TObject *Sender)
{
Close();        
}
//---------------------------------------------------------------------------

void __fastcall TDat_InForm::BitBtnLayInClick(TObject *Sender)
{
 LabelLayin->Visible=true;
 ProgressBarThe->Visible=true;

 LayInDataInfo();
 LabelLayin->Visible=false;
 BitBtnClearData->Enabled=true;

}
//---------------------------------------------------------------------------
void __fastcall TDat_InForm::LayInDataInfo()
{
 TStringList *FList=new TStringList;
 if(!FileExists(FileNameEdit->Text))
 {
  ShowMessage("财务数据文件不存在!");
  return;
 }
 FList->LoadFromFile(FileNameEdit->Text);
 if(FList->Count==0)
 {
  ShowMessage("财务数据文件为空!");
  return;
 }
  if(!ADOTableThe->Active)
  {
  ADOTableThe->Active=true;
  }
   ProgressBarThe->Min = 0;
  ProgressBarThe->Max = ((FList->Count)-2);
  AnsiString DiShi,ShouRu,ZhiChu,YuE,RiQi,ShiJian,ZhaiYao;

  AnsiString str1;

  LabelLayin->Visible     = true;
  ProgressBarThe->Visible = true;
  Application->ProcessMessages() ;

  int index0;
  for(int i = 1; i< FList->Count; i++)
  {
    ProgressBarThe->Position = i;
    //sqy = scllx = szpdw      = "";

    str1 = FList->Strings [i];
    index0 = str1.Length();
    if ( str1.Length()  != 181 )
    {
      ShowMessage("数据格式不对,导入中止!");
      break;
    }

    if ( str1.Trim() == "")
         continue;

    DiShi = str1.SubString(1,15).Trim() ;
    str1 = str1.Delete(1,15) ;

    ShouRu= str1.SubString(1,25).Trim() ;
    str1 = str1.Delete(1,25) ;

    ZhiChu= str1.SubString(1,25).Trim() ;
    str1 = str1.Delete(1,25);

    YuE = str1.SubString(1,25).Trim() ;
    str1 = str1.Delete(1,25);

    RiQi = str1.SubString(1,13).Trim() ;
    str1 = str1.Delete(1,13);

    ShiJian = str1.SubString(1,13).Trim() ;
    str1 = str1.Delete(1,13);

    ZhaiYao = str1.SubString(1,65).Trim() ;
    str1 = str1.Delete(1,65);

     if ( CheckBoxCheckDupRec->Checked ) //查重复数据
    {
       QueryThe->Close();
       QueryThe->SQL->Clear() ;
       QueryThe->SQL->Add(  "Select * FROM MMTable WHERE DiShi like '%" + DiShi + "%' and RiQi = '" +  RiQi + "' and ShiJian = '" + ShiJian + "'" );
       //QueryThe->SQL->Add(  " and ZhaiYao like '%" + ZhaiYao + "%'" );
       //QueryThe->ExecSQL() ;
      // QueryThe->Active = true ;
       QueryThe->Open() ;

       if ( QueryThe->RecordCount > 0 )
         continue;
    }
    ADOTableThe->Append();
    ADOTableThe->Edit();
    //TableThe->Append();

     ADOTableThe->FieldByName("DiShi")->AsString  = DiShi;
    ADOTableThe->FieldByName("ShouRu")->AsString   = ShouRu;
    ADOTableThe->FieldByName("ZhiChu")->AsString    = ZhiChu;
    ADOTableThe->FieldByName("YuE")->AsString    = YuE;
    ADOTableThe->FieldByName("RiQi")->AsString  = RiQi;
    ADOTableThe->FieldByName("ShiJian")->AsString    = ShiJian;
    ADOTableThe->FieldByName("ZhaiYao")->AsString   = ZhaiYao;

}
  delete FList;

  ADOTableThe->Close() ;

  ProgressBarThe->Visible = false;

}
void __fastcall TDat_InForm::FormShow(TObject *Sender)
{
 LabelLayin->Visible=false;
 ProgressBarThe->Visible=false;       
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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