glbmqtyneedget.cpp

来自「科思ERP部分源码及控件」· C++ 代码 · 共 423 行 · 第 1/2 页

CPP
423
字号
    TComResultSet *RsGlbQuery;
    RsGlbQuery=new  TComResultSet(Handle,g_ClientHandle);
    if(FGlbQtyAmtSign==1)
      sSql="select GlbDir,GlbBopQty,GlbBopAmt,GlbDopAmt,GlbCopAmt,GlbDopQty,GlbCopQty,GlbDoyAmt,GlbCoyAmt,GlbDoyQty,GlbCoyQty from sdGlb where GlbFmonth='"+FQtyAmtFmonth+"' and GlbGlkm='"+Trim(FQtyAmtGlkm)+"'";
    else
      sSql="select GlbDir,GlbBopQty,GlbBopAmt,GlbDopAmt,GlbCopAmt,GlbDopQty,GlbCopQty,GlbDoyAmt,GlbCoyAmt,GlbDoyQty,GlbCoyQty from sdGlb where GlbFmonth='"+RstGlkm->FieldByName("GlbFmonth")+"' and GlbGlkm='"+Trim(RstGlkm->FieldByName("GlbGlkm"))+"'";
    RsGlbQuery->Open(sSql,"");
    RsGlbQuery->MoveFirst();

    if(FGlbQtyAmtSign==1)
      labMemory->Caption="--"+FMfcmonthInfo+",科目:["+FQtyAmtGlkm+"]";
    else
      labMemory->Caption="--第"+RstGlkm->FieldByName("GlbFmonth")+"期,科目:["+RstGlkm->FieldByName("GlbGlkm")+"]";

    if(RsGlbQuery->Eof==1)
      throw Exception("科目:'"+FQtyAmtGlkm+"'在期间:'"+FQtyAmtFmonth+"'的帐务没有初始化");
    ItemStr="";
    //显示科目期初的余额
    ItemStr = "\t\t\t期初余额";
    if(RsGlbQuery->FieldByName("GlbBopAmt")==0)
    ItemStr += "\t0.00\t0.00\t平\t0.00";
    else
    {
        ItemStr += AnsiString("\t0.00\t0.00\t") + (RsGlbQuery->FieldByName("GlbDir")==1 ? "借":"贷") + "\t" +
        FormatFloat("#,##0.00",RsGlbQuery->FieldByName("GlbBopAmt").ToDouble());
    }
    sgGlbmQtyNeedGet->AddItem(ItemStr);

    double fBopAmt,fBopQty;
    fBopAmt=0;
    fBopQty=0;
    while(RsQuery->Eof == 0)
    {
      if(fBopAmt==0)
        fBopAmt=RsGlbQuery->FieldByName("GlbBopAmt").ToDouble()+
                RsQuery->FieldByName("PzdDir").ToDouble()*
                RsQuery->FieldByName("GlkmDir").ToDouble()*
                RsQuery->FieldByName("PzdAmt").ToDouble();
      else
        fBopAmt=fBopAmt+RsQuery->FieldByName("PzdAmt").ToDouble()*
                RsQuery->FieldByName("PzdDir").ToDouble()*
                RsQuery->FieldByName("GlkmDir").ToDouble();

      if(fBopQty==0)
        fBopQty=RsGlbQuery->FieldByName("GlbBopQty").ToDouble()+
                RsQuery->FieldByName("PzdDir").ToDouble()*
                RsQuery->FieldByName("GlkmDir").ToDouble()*
                RsQuery->FieldByName("PzdQty").ToDouble();
      else
        fBopQty=fBopAmt+RsQuery->FieldByName("PzdQty").ToDouble()*
                RsQuery->FieldByName("PzdDir").ToDouble()*
                RsQuery->FieldByName("GlkmDir").ToDouble();

      if(RsQuery->FieldByName("PzdDir")=="1")
        ItemStr=RsQuery->FieldByName("PzhDate")+"\t"+ RsQuery->FieldByName("FvctName") + "\t" +
                RsQuery->FieldByName("PzhCode")+"\t"+
                RsQuery->FieldByName("NoteBookText")+"\t"+
                FormatFloat("#,##0.00",fBopQty)+"\t"+
                FormatFloat("#,##0.00",fBopAmt);
      else
        ItemStr=RsQuery->FieldByName("PzhDate")+"\t"+ RsQuery->FieldByName("PzhCode")+"\t"+
                RsQuery->FieldByName("PzhCode")+"\t"+
                RsQuery->FieldByName("NoteBookText")+"\t"+
                FormatFloat("#,##0.00",RsQuery->FieldByName("PzdQty").ToDouble())+"\t"+
                FormatFloat("#,##0.00",RsQuery->FieldByName("PzdAmt").ToDouble())+"\t"+
                FormatFloat("#,##0.00",fBopQty)+"\t"+
                FormatFloat("#,##0.00",fBopAmt);
      sgGlbmQtyNeedGet->AddItem(ItemStr);
      RsQuery->MoveNext();
    }
    if(sgGlbmQtyNeedGet->RowCount >= 2)
    {
        AnsiString tempStr;
        tempStr=sgGlbmQtyNeedGet->Cells[6][sgGlbmQtyNeedGet->RowCount-1]+"\t"+sgGlbmQtyNeedGet->Cells[7][sgGlbmQtyNeedGet->RowCount-1];

        ItemStr=AnsiString("")+"\t"+AnsiString("")+"\t"+AnsiString("")+"\t"+
                "本期合计:"+"\t"+
                FormatFloat("#,##0.00",RsGlbQuery->FieldByName("GlbDopAmt").ToDouble())+"\t"+
                FormatFloat("#,##0.00",RsGlbQuery->FieldByName("GlbCopAmt").ToDouble())+"\t";
        ItemStr=ItemStr+tempStr;
        sgGlbmQtyNeedGet->AddItem(ItemStr);

        ItemStr=AnsiString("")+"\t"+AnsiString("")+"\t"+AnsiString("")+"\t"+
                "本年累计:"+"\t"+
                FormatFloat("#,##0.00",RsGlbQuery->FieldByName("GlbDoyAmt").ToDouble())+"\t"+
                FormatFloat("#,##0.00",RsGlbQuery->FieldByName("GlbCoyAmt").ToDouble())+"\t";
        ItemStr=ItemStr+tempStr;
        sgGlbmQtyNeedGet->AddItem(ItemStr);
    }

    RsQuery->Close();
    RsGlbQuery->Close();
    delete RsQuery;
    delete RsGlbQuery;
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbmQtyNeedGet::muFirstClick(TObject *Sender)
{
    if(FGlbQtyAmtSign==1 || FCancelQuery==true)
      return;
    if(RstGlkm->RecordCount>1)
    {
      RstGlkm->MoveFirst();
      FillGridWithData();
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbmQtyNeedGet::muNextClick(TObject *Sender)
{
    if(FGlbQtyAmtSign==1 || FCancelQuery==true)
      return;
    if(RstGlkm->RecordCount > 1 && RstGlkm->CurRecNo < RstGlkm->RecordCount-1)
    {
      RstGlkm->MoveNext();
      FillGridWithData();
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbmQtyNeedGet::muLastClick(TObject *Sender)
{
    if(FGlbQtyAmtSign==1 || FCancelQuery==true)
      return;
    if(RstGlkm->RecordCount > 1)
    {
      RstGlkm->MoveLast();
      FillGridWithData();
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbmQtyNeedGet::muPreviousClick(TObject *Sender)
{
    if(FGlbQtyAmtSign==1 || FCancelQuery==true)
      return;
    if(RstGlkm->RecordCount > 1 && RstGlkm->CurRecNo > 1)
    {
      RstGlkm->MovePrious();
      FillGridWithData();
    }
}
//---------------------------------------------------------------------------


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

void __fastcall TfrmGlbmQtyNeedGet::FormShow(TObject *Sender)
{
    if(FGlbQtyAmtSign==1)
    {
      tbQuery->Enabled=false;
      tbControl->Enabled=false;
    }
    else
    {
      tbQuery->Enabled=true;
      tbControl->Enabled=true;
    }
    tbQueryClick(Sender);
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbmQtyNeedGet::FormClose(TObject *Sender,
      TCloseAction &Action)
{
   if(FGlbQtyAmtSign!=1 && RstGlkm!=NULL)
   {
      RstGlkm->Close();
      delete RstGlkm;
   }
   TQueryBaseForm::FormClose(Sender,Action);
}
//---------------------------------------------------------------------------

void __fastcall TfrmGlbmQtyNeedGet::sgGlbmQtyNeedGetDblClick(
      TObject *Sender)
{
    int iRow;
    AnsiString tPzhCode;
    iRow=sgGlbmQtyNeedGet->Row;
    tPzhCode= Trim(sgGlbmQtyNeedGet->Cells[2][iRow]);
    if(tPzhCode.IsEmpty())
      return;
    try
    {
      StartWaitForm("正在调阅凭证,请稍候......");
      TmpNeedGet=new TfrmPzh(this,g_ClientHandle,"1100302","");
      TmpNeedGet->comServer->FilterString="PzhCode='"+tPzhCode+"'";
      TmpNeedGet->comServer->Query();
      TmpNeedGet->Transfered=1;
      EndWaitForm();
      TmpNeedGet->ShowModal();
    }
    catch (Exception &e)
    {
      delete TmpNeedGet;
      throw Exception(e.Message);
    }
    delete TmpNeedGet;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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