glbqtyneedget.cpp
来自「科思ERP部分源码及控件」· C++ 代码 · 共 294 行
CPP
294 行
//---------------------------------------------------------------------------
#include <vcl.h>
#include "GlbQtyNeedGet.h"
#include "GlbmQtyNeedGet.h"
#include "GlbQF_NeedGet.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "QueryBaseForm"
#pragma link "SDGrid"
#pragma link "KSAdvReport"
#pragma resource "*.dfm"
TfrmGlbQtyNeedGet *frmGlbQtyNeedGet;
TfrmGlbmQtyNeedGet *GlbmQtyNeedGetfrm;
TfrmGlbQF_NeedGet *frmTmpGlbQF_NeedGet;
//---------------------------------------------------------------------------
__fastcall TfrmGlbQtyNeedGet::TfrmGlbQtyNeedGet(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TQueryBaseForm(Owner,chWnd,MidCode,WhereStr)
{
//InitGridControl();
labMemory->Caption="";
QueryGrid=sgGlbQtyNeedGet;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::InitGridControl()
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::tbQueryClick(TObject *Sender)
{
if(!ShowQueryWindow())
return;
try{
StartWaitForm("正在查询,请稍候...");
labMemory->Caption="--"+FGfcmonthInfo;
FillGridWithData();
}
__finally
{
EndWaitForm();
}
}
//---------------------------------------------------------------------------
bool __fastcall TfrmGlbQtyNeedGet::ShowQueryWindow()
{
frmTmpGlbQF_NeedGet=new TfrmGlbQF_NeedGet(this);
frmTmpGlbQF_NeedGet->Caption="应收帐款总帐查询过滤";
frmTmpGlbQF_NeedGet->FQtyAmtSign="1";
frmTmpGlbQF_NeedGet->ShowModal();
if(frmTmpGlbQF_NeedGet->CancelQuery)
{
delete frmTmpGlbQF_NeedGet;
return false;
}
FilterStr=frmTmpGlbQF_NeedGet->CreateSqlString;
FGfcmonthInfo=frmTmpGlbQF_NeedGet->FmonthInfo;
delete frmTmpGlbQF_NeedGet;
return true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::ClearControl(bool BringToNext)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::GetDataFromComObject()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::WaitUserInput()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::RefreshGridData(int mAction)
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::DisplayBill()
{
return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::GetBill(AnsiString BillID)
{
return;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmGlbQtyNeedGet::GetHeadQueryStr()
{
AnsiString Selectstr,Fromstr,Wherestr,Orderstr;
//客户编码,客户名称,财务月份,摘要,方向,
Selectstr = "select PzdClient,ClientName,PzhFmonth,NoteBookText=IsNULL(NoteBookText,''),PzdDir,KmName = IsNULL(GlkmName,'')";
Selectstr += ",GlbBopAmt,GlbDopAmt,GlbCopAmt,GlbDoyAmt,GlbCoyAmt,GlbAoyAmt";
Fromstr = " From sdPzd,sdPzh,sdClient,sdNoteBook,sdGlkm,sdGlb";
Wherestr = " where PzdClient=IsNULL(ClientCode,'') and PzhCode=PzdCode and PzdZy*=NoteBookCode and PzdGlkm*=GlkmCode and PzhCheck=1";
Wherestr += " and pzdGlkm like '113%'";
Wherestr += " and pzhFmonth=GlbFmonth and pzdGlkm=Glbglkm";
if(FilterStr.Trim() != "")
Wherestr += " and " + FilterStr;
Orderstr = " order by PzdClient,PzhFmonth";
sSQL = Selectstr + Fromstr + Wherestr + Orderstr;
return(sSQL);
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmGlbQtyNeedGet::GetSpace(int iNum)
{
AnsiString strSpace;
for(int i=1;i<iNum;i++)
strSpace=strSpace+AnsiString(" ");
return strSpace;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::FillGridWithData()
{
TComResultSet *RsQuery;
AnsiString ItemStr0,ItemStr1,ItemStr2,sSql;
sSql=GetHeadQueryStr(); //取Head查询的SQL语句
if(sSql=="")
return;
sgGlbQtyNeedGet->RowCount=1;
RecentBillCode="";
RsQuery=new TComResultSet(Handle,g_ClientHandle);
RsQuery->Open(sSql,"");
RsQuery->MoveFirst();
ItemStr0 = "";
ItemStr1 = "";
ItemStr2 = "";
while(RsQuery->Eof == 0)
{
double pAmtsum = RsQuery->FieldByName("GlbDopAmt").ToDouble() - RsQuery->FieldByName("GlbCopAmt").ToDouble(); //本期余额
double yAmtsum = RsQuery->FieldByName("GlbAoyAmt").ToDouble(); //本年累计
//期初
ItemStr0 = RsQuery->FieldByName("pzdClient") + "\t" +
RsQuery->FieldByName("ClientName") + "\t" +
RsQuery->FieldByName("PzhFmonth") + "\t" +
"期初余额\t\t\t" ;
if(RsQuery->FieldByName("GlbBopAmt")==0)
ItemStr0 += "平\t0.00" ;
else
ItemStr0 += (RsQuery->FieldByName("PzdDir")=="1" ? "借":"贷") ;
ItemStr0 += "\t" + FormatFloat("#,##0.00",RsQuery->FieldByName("GlbBopAmt").ToDouble());
//本期 --------------------------------------------------------------------------
ItemStr1 = "\t\t" +
RsQuery->FieldByName("PzhFmonth") + "\t" +
"本期合计\t" +
FormatFloat("#,##0.00",RsQuery->FieldByName("GlbDopAmt").ToDouble()) + "\t" +
FormatFloat("#,##0.00",RsQuery->FieldByName("GlbCopAmt").ToDouble()) + "\t" ;
if(pAmtsum == 0)
ItemStr1 += "平\t0.00" ;
else
ItemStr1 += (RsQuery->FieldByName("PzdDir")=="1" ? "借":"贷") ;
ItemStr1 += "\t" + FormatFloat("#,##0.00",pAmtsum) ;
//本年---------------------------------------------------------------------------
ItemStr2 = "\t\t" +
RsQuery->FieldByName("PzhFmonth") + "\t" +
"本年合计\t" +
FormatFloat("#,##0.00",RsQuery->FieldByName("GlbDoyAmt").ToDouble()) + "\t" +
FormatFloat("#,##0.00",RsQuery->FieldByName("GlbCoyAmt").ToDouble()) + "\t" ;
if(yAmtsum == 0)
ItemStr2 += "平\t0.00" ;
else
ItemStr2 += (RsQuery->FieldByName("PzdDir")=="1" ? "借":"贷") ;
ItemStr2 += "\t" + FormatFloat("#,##0.00",yAmtsum) ;
sgGlbQtyNeedGet->AddItem(ItemStr0);
sgGlbQtyNeedGet->AddItem(ItemStr1);
sgGlbQtyNeedGet->AddItem(ItemStr2);
RsQuery->MoveNext();
}
RsQuery->Close();
delete RsQuery;
//SpaceGrid(sgGlbQtyNeedGet); //
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::muFirstClick(TObject *Sender)
{
if(sgGlbQtyNeedGet->RowCount > 1)
sgGlbQtyNeedGet->Row=1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::muNextClick(TObject *Sender)
{
if(sgGlbQtyNeedGet->RowCount > 1 && sgGlbQtyNeedGet->Row < sgGlbQtyNeedGet->RowCount-1)
sgGlbQtyNeedGet->Row=sgGlbQtyNeedGet->Row+1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::muLastClick(TObject *Sender)
{
if(sgGlbQtyNeedGet->RowCount > 1)
sgGlbQtyNeedGet->Row=sgGlbQtyNeedGet->RowCount-1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::muPreviousClick(TObject *Sender)
{
if(sgGlbQtyNeedGet->RowCount > 1 && sgGlbQtyNeedGet->Row > 1)
sgGlbQtyNeedGet->Row=sgGlbQtyNeedGet->Row-1;
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::tbRefreshClick(TObject *Sender)
{
if(sSQL=="")
return;
FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::FormShow(TObject *Sender)
{
tbQueryClick(this);
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::sgGlbQtyNeedGetDblClick(TObject *Sender)
{
int iRow;
iRow=sgGlbQtyNeedGet->Row;
if(iRow > 1)
if(sgGlbQtyNeedGet->Cells[2][iRow].Trim()!="")
{
try
{
GlbmQtyNeedGetfrm=new TfrmGlbmQtyNeedGet(this);
//GlbmQtyNeedGetfrm->FQtyAmtGlkm=Trim(sgGlbQtyNeedGet->Cells[0][iRow]);
GlbmQtyNeedGetfrm->FQtyAmtFmonth=Trim(sgGlbQtyNeedGet->Cells[2][iRow]);
GlbmQtyNeedGetfrm->FMfcmonthInfo=FGfcmonthInfo;
GlbmQtyNeedGetfrm->FGlbQtyAmtSign=1;
GlbmQtyNeedGetfrm->ShowModal();
}
__finally
{
delete GlbmQtyNeedGetfrm;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmGlbQtyNeedGet::SpaceGrid(int AType,TSDGrid *ASDGrid) //把同一值的去掉
{
switch(AType)
{
case 0:
{
for(int i=1; i<=ASDGrid->RowCount; ++i)
{
AnsiString Starstr = ASDGrid->Cells[0][i].Trim();
if(Starstr == "")
continue;
AnsiString Endstr = "";
for(int j=i+1; j<=ASDGrid->RowCount; ++j)
{
Endstr = ASDGrid->Cells[0][j].Trim();
if(Endstr.UpperCase() == Starstr.UpperCase())
{
ASDGrid->Cells[0][j] = "";
ASDGrid->Cells[1][j] = "";
}
}
}
}
break;
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?