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

📄 srethquery.cpp

📁 速达开源ERP系统
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "SrethQuery.h"
#include "SretdView.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "QueryBaseForm"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmSrethQuery *frmSrethQuery;
//---------------------------------------------------------------------------
__fastcall TfrmSrethQuery::TfrmSrethQuery(TComponent* Owner)
        : TQueryBaseForm(Owner)
{
 FilterStr="";
 sSQL="";
}
//---------------------------------------------------------------------------
bool __fastcall TfrmSrethQuery::ShowQueryWindow()
{
  TfrmQuForm *FQuery=new TfrmQuForm(this,"frmSrethQuery");
  FQuery->ShowModal();
  if(FQuery->CancelQuery)
    return false;
  FilterStr=FQuery->CreateSqlString;
  delete FQuery;
  return true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethQuery::ClearControl(bool BringToNext)
{
 return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethQuery::GetDataFromComObject()
{
 return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethQuery::WaitUserInput()
{
 return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethQuery::RefreshGridData(int mAction)
{
 return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethQuery::DisplayBill()
{
 return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethQuery::GetBill(AnsiString BillID)
{
 return;
}
//---------------------------------------------------------------------------
//获取查询语句
AnsiString __fastcall TfrmSrethQuery::GetQueryStr()
{
 AnsiString Selectstr,Fromstr,Wherestr,Orderstr;
 Selectstr =AnsiString("select DISTINCT SRETHFMONTH,SRETHCLIENT,SRETHCODE,SRETHTYPENAME,SRETHDATE,SRETHCHECKID,SRETHCURRENCYNAME,")+
            AnsiString("SRETHENRATE,SRETHTAXNAME,SRETHAMT,SRETHTAXAMT,SRETHSUMAMT,SRETHUSERNAME,SRETHCHECKERNAME from sdvw_Sreth");
 if(FilterStr=="")
  Wherestr="";
 else
  Wherestr=" where "+FilterStr;
 Orderstr=" order by srethfmonth,SrethClient,SrethDate";
 sSQL=Selectstr+Wherestr+Orderstr;
 return(sSQL);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethQuery::FillGridWithData()
{
 TComResultSet *RsQuery;
 AnsiString ItemStr,sSql;
 //获取查询语句
 sSql=GetQueryStr();
 if(sSql=="")
  return;
 sgSreth->RowCount=1;
 RsQuery=NewResultSet();
 RsQuery->Open(WideString(sSql),WideString(""));
 RsQuery->MoveFirst();
 while( RsQuery->Eof == 0)
 {
  ItemStr="\t"+RsQuery->FieldByName("SRETHFMONTH")+
          "\t"+RsQuery->FieldByName("SRETHCLIENT")+
          "\t"+RsQuery->FieldByName("SRETHCODE")+
          "\t"+RsQuery->FieldByName("SRETHTYPENAME")+
          "\t"+RsQuery->FieldByName("SRETHDATE")+
          "\t"+RsQuery->FieldByName("SRETHCHECKID")+
          "\t"+RsQuery->FieldByName("SRETHCURRENCYNAME")+
          "\t"+RsQuery->FieldByName("SRETHENRATE")+
          "\t"+RsQuery->FieldByName("SRETHTAXNAME")+
          "\t"+RsQuery->FieldByName("SRETHAMT")+
          "\t"+RsQuery->FieldByName("SRETHTAXAMT")+
          "\t"+RsQuery->FieldByName("SRETHSUMAMT")+
          "\t"+RsQuery->FieldByName("SRETHUSERNAME")+
          "\t"+RsQuery->FieldByName("SRETHCHECKERNAME");
  sgSreth->AddItem(ItemStr);
  RsQuery->MoveNext();
 }
 RsQuery->Close();
 delete RsQuery;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethQuery::muFirstClick(TObject *Sender)
{
  if(sgSreth->RowCount>1)
      sgSreth->Row=1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethQuery::muPreviousClick(TObject *Sender)
{
 if(sgSreth->Row>1)
  sgSreth->Row--;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethQuery::muNextClick(TObject *Sender)
{
 if(sgSreth->Row<sgSreth->RowCount-1)
   sgSreth->Row++;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethQuery::muLastClick(TObject *Sender)
{
  sgSreth->Row=sgSreth->RowCount-1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethQuery::sgSrethDblClick(TObject *Sender)
{
  if(sgSreth->Row>0&&sgSreth->Row<sgSreth->RowCount)
  {
    try{
         TfrmSretdView *frmSretdView= new TfrmSretdView(this);
         frmSretdView->BillNumID=Trim(sgSreth->TextMatrix[sgSreth->Row][3]);
         frmSretdView->ShowModal();
         }
      catch(...)
         {
         delete frmSretdView;
          }
      delete frmSretdView;
    }

}
//---------------------------------------------------------------------------
void __fastcall TfrmSrethQuery::tbQueryClick(TObject *Sender)
{
  if(!ShowQueryWindow())
    return;
  try{
    StartWaitForm("正在查询,请稍候...");
    FillGridWithData();
  }
  __finally
  {
    EndWaitForm();
  }
}
//---------------------------------------------------------------------------

void __fastcall TfrmSrethQuery::tbRefreshClick(TObject *Sender)
{
       if(sSQL=="")
       return;
       FillGridWithData();
}
//---------------------------------------------------------------------------


⌨️ 快捷键说明

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