qu_cd.cpp

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

CPP
179
字号
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Qu_Cd.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "QueryBaseForm"
#pragma link "SDGrid"
#pragma link "KSAdvReport"
#pragma resource "*.dfm"
TfrmQu_Cd *frmQu_Cd;
//---------------------------------------------------------------------------
__fastcall TfrmQu_Cd::TfrmQu_Cd(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
        : TQueryBaseForm(Owner,chWnd,MidCode,WhereStr)
{
       l_SQL="";      //查询语句
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_Cd::ClearControl(bool BringToNext)
{
 return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_Cd::GetDataFromComObject()
{
 return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_Cd::WaitUserInput()
{
 return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_Cd::RefreshGridData(int mAction)
{
 return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_Cd::DisplayBill()
{
 return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_Cd::GetBill(AnsiString BillID)
{
 return;
}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_Cd::FillGridWithData()
{ 
    TComResultSet *RsQuery=new  TComResultSet(Handle,g_ClientHandle);
    AnsiString  ItemStr="",l_FiStr="";
    if(FilterStr=="")
        l_FiStr="";
    else
        l_FiStr=" where "+FilterStr;
    l_SQL=" select * from sdVW_Cd  "+l_FiStr+" order by CDFMONTH";
    sgCdB->RowCount=1;
    sgCdP->RowCount=1;
    try
    {
     RsQuery->Open(l_SQL,"");
     RsQuery->MoveFirst();
     while( RsQuery->Eof == 0)
     {
      ItemStr="\t"+RsQuery->FieldByName("CdFmonth")+       //财务月份
           "\t"+RsQuery->FieldByName("CdGoods")+       //物料编码
           "\t"+RsQuery->FieldByName("GoodsName")+       //物料名称
           "\t"+(RsQuery->FieldByName("CdInitFlg")=="1"? "是":"否")+       //初始化标志
           "\t"+RsQuery->FieldByName("CdBopQty")+       //期初数量
           "\t"+RsQuery->FieldByName("CdBopPrice")+       //期初单价
           "\t"+RsQuery->FieldByName("CdBopAmt")+       //期初金额
           "\t"+RsQuery->FieldByName("CdIopQty")+         //本期收入量
           "\t"+RsQuery->FieldByName("CdIopAmt")+       //本期收入金额
           "\t"+RsQuery->FieldByName("CdSopQty")+       //本期发出量
           "\t"+RsQuery->FieldByName("CdSopAmt")+       //本期发出金额
           "\t"+RsQuery->FieldByName("CdPopPrice")+       //前一笔单价
           "\t"+RsQuery->FieldByName("CdNopPrice")+       //当前单价
           "\t"+RsQuery->FieldByName("CdNopQty")+       //当前数量
           "\t"+RsQuery->FieldByName("CdNopAmt");       //当前金额
     sgCdB->AddItem(ItemStr);
          ItemStr="\t"+RsQuery->FieldByName("CdGoods")+       //物料编码
           "\t"+RsQuery->FieldByName("CdBoyQty")+       //年初数量
           "\t"+RsQuery->FieldByName("CdBoyPrice")+       //年初单价
           "\t"+RsQuery->FieldByName("CdBoyAmt")+       //年初金额
           "\t"+RsQuery->FieldByName("CdIoyQty")+       //本年累计收入量
           "\t"+RsQuery->FieldByName("CdIoyAmt")+       //本年累计收入金额
           "\t"+RsQuery->FieldByName("CdSoyQty")+       //本年发出累计数量
           "\t"+RsQuery->FieldByName("CdSoyAmt")+       //本年发出累计金额
           "\t"+RsQuery->FieldByName("CdFopPrice")+       //结存单价
           "\t"+RsQuery->FieldByName("CdFopQty")+       //结存数量
           "\t"+RsQuery->FieldByName("CdFopAmt")+       //结存金额
           "\t"+(RsQuery->FieldByName("CdClose")=="1"?"是":"否");        //关闭标志
     sgCdP->AddItem(ItemStr);
     RsQuery->MoveNext();
     }
     RsQuery->Close();
    } 
    __finally
    {
      delete RsQuery;
    }
}
//----------------------------------------------------------------------------

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

}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_Cd::tbRefreshClick(TObject *Sender)
{
    if(l_SQL!="")
    FillGridWithData();
}
//---------------------------------------------------------------------------

void __fastcall TfrmQu_Cd::muFirstClick(TObject *Sender)
{
   if(sgCdB->RowCount > 1)
    sgCdB->Row=1;
   if(sgCdP->RowCount > 1)
    sgCdP->Row=1;

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

void __fastcall TfrmQu_Cd::muPreviousClick(TObject *Sender)
{
   if( sgCdB->Row>1)
    sgCdB->Row--;
   if( sgCdP->Row>1)
    sgCdP->Row--;

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

void __fastcall TfrmQu_Cd::muNextClick(TObject *Sender)
{
   if( sgCdB->Row < sgCdB->RowCount-1)
    sgCdB->Row++;
   if( sgCdP->Row < sgCdP->RowCount-1)
    sgCdP->Row++;

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

void __fastcall TfrmQu_Cd::muLastClick(TObject *Sender)
{
   if(sgCdB->RowCount > 1)
    sgCdB->Row=sgCdB->RowCount-1;
   if(sgCdP->RowCount > 1)
    sgCdP->Row=sgCdP->RowCount-1;

}
//---------------------------------------------------------------------------
void __fastcall TfrmQu_Cd::tbExportClick(TObject *Sender)
{
  if(PageControl1->ActivePageIndex==0)
    QueryGrid=sgCdB;
  else
    QueryGrid=sgCdP;
  TQueryBaseForm::tbExportClick(Sender);
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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