glbqtywillget.cpp

来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 261 行

CPP
261
字号
//---------------------------------------------------------------------------
#include <vcl.h>
#include "GlbQtyWillGet.h"
#include "GlbmQtyWillGet.h"
#include "GlbQF_NeedGet.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "QueryBaseForm"
#pragma link "SDGrid"
#pragma link "KSAdvReport"
#pragma resource "*.dfm"

TfrmGlbQtyWillGet *frmGlbQtyWillGet;
TfrmGlbmQtyWillGet *TmpGlbmQtyWillGet;
TfrmGlbQF_NeedGet *TmpGlbQF_WillGet;
//---------------------------------------------------------------------------
__fastcall TfrmGlbQtyWillGet::TfrmGlbQtyWillGet(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
   : TQueryBaseForm(Owner,chWnd,MidCode,WhereStr)
{
   //InitGridControl();
   labMemory->Caption="";
   QueryGrid=sgGlbQtyWillGet;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbQtyWillGet::InitGridControl()
{

}
//---------------------------------------------------------------------------

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

bool __fastcall TfrmGlbQtyWillGet::ShowQueryWindow()
{
   TmpGlbQF_WillGet=new TfrmGlbQF_NeedGet(this);
   TmpGlbQF_WillGet->Caption="预收帐款总帐查询过滤";
   TmpGlbQF_WillGet->FQtyAmtSign="1";
   TmpGlbQF_WillGet->ShowModal();
   if(TmpGlbQF_WillGet->CancelQuery)
   {
     delete TmpGlbQF_WillGet;
     return false;
   }
   FilterStr=TmpGlbQF_WillGet->CreateSqlString;
   FGfcmonthInfo=TmpGlbQF_WillGet->FmonthInfo;
   delete TmpGlbQF_WillGet;
   return true;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbQtyWillGet::ClearControl(bool BringToNext)
{
   return;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbQtyWillGet::GetDataFromComObject()
{
   return;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbQtyWillGet::WaitUserInput()
{
   return;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbQtyWillGet::RefreshGridData(int mAction)
{
   return;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbQtyWillGet::DisplayBill()
{
   return;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbQtyWillGet::GetBill(AnsiString BillID)
{
   return;
}
//---------------------------------------------------------------------------

AnsiString __fastcall TfrmGlbQtyWillGet::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=ClientCode and PzhCode=PzdCode and PzdZy*=NoteBookCode and PzdGlkm*=GlkmCode and PzhCheck=1";
    Wherestr += " and pzdGlkm like '204%'";
    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 TfrmGlbQtyWillGet::GetSpace(int iNum)
{
    AnsiString strSpace;
    for(int i=1;i<iNum;i++)
      strSpace=strSpace+AnsiString(" ");
    return strSpace;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbQtyWillGet::FillGridWithData()
{
    TComResultSet *RsQuery;
    AnsiString ItemStr0,ItemStr1,ItemStr2,sSql;

    sSql=GetHeadQueryStr();  //取Head查询的SQL语句
    if(sSql=="")
      return;
    sgGlbQtyWillGet->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)                          ;

      sgGlbQtyWillGet->AddItem(ItemStr0);
      sgGlbQtyWillGet->AddItem(ItemStr1);
      sgGlbQtyWillGet->AddItem(ItemStr2);
      RsQuery->MoveNext();
    }
    RsQuery->Close();
    delete RsQuery;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbQtyWillGet::muFirstClick(TObject *Sender)
{
    if(sgGlbQtyWillGet->RowCount > 1)
      sgGlbQtyWillGet->Row=1;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbQtyWillGet::muNextClick(TObject *Sender)
{
    if(sgGlbQtyWillGet->RowCount > 1 && sgGlbQtyWillGet->Row < sgGlbQtyWillGet->RowCount-1)
      sgGlbQtyWillGet->Row=sgGlbQtyWillGet->Row+1;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbQtyWillGet::muLastClick(TObject *Sender)
{
    if(sgGlbQtyWillGet->RowCount > 1)
      sgGlbQtyWillGet->Row=sgGlbQtyWillGet->RowCount-1;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbQtyWillGet::muPreviousClick(TObject *Sender)
{
    if(sgGlbQtyWillGet->RowCount > 1 && sgGlbQtyWillGet->Row > 1)
      sgGlbQtyWillGet->Row=sgGlbQtyWillGet->Row-1;
}
//---------------------------------------------------------------------------

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

void __fastcall TfrmGlbQtyWillGet::FormShow(TObject *Sender)
{
    tbQueryClick(this);
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbQtyWillGet::sgGlbQtyWillGetDblClick(TObject *Sender)
{
    int iRow;
    iRow=sgGlbQtyWillGet->Row;
    if(iRow > 1)
    if(sgGlbQtyWillGet->Cells[2][iRow].Trim()!="")
    {
      try
      {
        TmpGlbmQtyWillGet=new TfrmGlbmQtyWillGet(this);
        //TmpGlbmQtyWillGet->FQtyAmtGlkm=Trim(sgGlbQtyWillGet->Cells[0][iRow]);
        TmpGlbmQtyWillGet->FQtyAmtFmonth=Trim(sgGlbQtyWillGet->Cells[2][iRow]);
        TmpGlbmQtyWillGet->FMfcmonthInfo=FGfcmonthInfo;
        TmpGlbmQtyWillGet->FGlbQtyAmtSign=1;
        TmpGlbmQtyWillGet->ShowModal();
      }
      __finally
      {
        delete TmpGlbmQtyWillGet;
      }
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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