sivohcheck.cpp

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

CPP
247
字号
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "SivohCheck.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ListBaseForm"
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmSivohCheck *frmSivohCheck;

//---------------------------------------------------------------------------
__fastcall TfrmSivohCheck::TfrmSivohCheck(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
        :TListBaseForm(Owner,chWnd,MidCode,WhereStr)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmSivohCheck::InitEditControl()
{
 FillComboBox(Handle,scSivohSaler,"Select SalerCode from sdSaler","SalerCode");
 FillComboBox(Handle,scSivohClient,"Select ClientCode from sdClient where ClientCancel=0","ClientCode");
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::ClearControl()
{
           seSivohCodeF->Text            ="";
           seSivohCodeT->Text            ="";
           deSivohDateF->Text            ="";
           deSivohDateT->Text            ="";
           scSivohClient->Text           ="";
           scSivohSaler->Text            ="";

           SivohGrid->RowCount=1;
           SivodGrid->RowCount=1;
           btnCheck->Enabled=false;
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::GetDataFromComObject(int Section)
{
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::SendDataToComObject(int Section)
{
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::WaitUserInput(int Section)
{
}
void __fastcall TfrmSivohCheck::ChangeToBrowseState(bool Browse)
{
  ClearControl();
}
//---------------------------------------------------------------------------
void __fastcall TfrmSivohCheck::DisplayBill()
{
        FillHeadGridWithData();
        comServer->MoveFirst();
        FillDetailGridWithData();
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::GetBill(AnsiString WhereStr)
{
    comServer->FilterString=WideString(WhereStr);
    comServer->Query();
    if (comServer->RecordCount!=0)      //Found it
       {
         btnCheck->Enabled=true;
         DisplayBill();
       }
       else
        ShowMessageWindow("在数据库中没有查到记录,请重新输入条件",mwsInformation);
   RecodCount->Caption="查询单据数为:"+IntToStr(comServer->RecordCount);  
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::FillDetailGridWithData()
{
      int i;
      AnsiString ItemStr;
      SivodGrid->RowCount=1;
      for (i=0;i<comServer->ItemCount;i++)
      {
          comServer->LocateItemByIndex(i);
          ItemStr="\t"+GetDetailValue("SivodLine")+"\t"+
                    GetDetailValue("SivodGoods")+"\t"+GetDetailValue("SivodUnit)+"\t"+
                    GetDetailValue("SivodPrice")+"\t"+GetDetailValue("SivodQty)+"\t"+
                    GetDetailValue("SivodAmt")+"\t"+GetDetailValue("SivodTaxAmt)+"\t"+
                    GetDetailValue("SivodZkAmt")+"\t"+GetDetailValue("SivodSumAmt);
          SivodGrid->AddItem(ItemStr);
      }
}
void __fastcall TfrmSivohCheck::FillHeadGridWithData()
{
      int i;
      AnsiString HeadStr;
      SivohGrid->RowCount=1;
      for (i=0;i<comServer->RecordCount;i++)
      {
          comServer->LocateByIndex(i);
          HeadStr="\t"+AnsiString("  ")+"\t"+GetHeadValue("SivohCode")+"\t"+GetHeadValue("SivohSoCode)+"\t"+
                       GetHeadValue("SivohClient")+"\t"+GetHeadValue("SivohDate)+"\t"+
                       GetHeadValue("SivohCurrency")+"\t"+GetHeadValue("SivohSettleMode)+"\t"+
                       GetHeadValue("SivohSaler");
          SivohGrid->AddItem(HeadStr);
      }

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

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------



void __fastcall TfrmSivohCheck::FormShow(TObject *Sender)
{
//       InitEditControl();
       ClearControl();
       ChangeToBrowseState(true);

}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSivohCheck::GetWhereSQLString()
{
     AnsiString WhereStr;
     WhereStr="SivohCheck=0 and SivohCancel=0";
     WhereStr=WhereStr+" and SivohClient in (select ClientCode from sdClient where ClientCancel=0)";
     if(!seSivohCodeF->Text.IsEmpty())
        WhereStr=WhereStr+" and SivohCode>='"+Trim(seSivohCodeF->Text)+"'";
     if(!seSivohCodeT->Text.IsEmpty())
        WhereStr=WhereStr+" and SivohCode<='"+Trim(seSivohCodeT->Text)+"'";
     if(!scSivohSaler->Text.IsEmpty())
        WhereStr=WhereStr+" and SivohSaler='"+Trim(scSivohSaler->Text)+"'";
     if(!deSivohDateF->Text.IsEmpty())
        WhereStr=WhereStr+" and SivohDate>='"+FormatDateTime("YYYY-MM-DD",deSivohDateF->Date)+"'";
     if(!deSivohDateT->Text.IsEmpty())
        WhereStr=WhereStr+" and SivohDate<='"+FormatDateTime("YYYY-MM-DD",deSivohDateT->Date)+"'";
     if(!scSivohClient->Text.IsEmpty())
        WhereStr=WhereStr+" and SivohClient='"+Trim(scSivohClient->Text)+"'";
   return(WhereStr);
}


void __fastcall TfrmSivohCheck::btnClearClick(TObject *Sender)
{
       ClearControl();
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::btnQueryClick(TObject *Sender)
{
           SivohGrid->RowCount=1;
           SivodGrid->RowCount=1;
           btnCheck->Enabled=false;

  AnsiString WhereStr=GetWhereSQLString();
  GetBill(WhereStr);
}
//---------------------------------------------------------------------------



void __fastcall TfrmSivohCheck::SivohGridClick(TObject *Sender)
{
   //DONE:BUG NO.569 FIXED 2001-8-26
   if(SivohGrid->Row>0 && MR<=SivohGrid->Row && MR>0)//if(SivohGrid->Col == 1&&SivohGrid->Row>0)
     {
      if(SivohGrid->TextMatrix[MR][1]=="√")
        {
           SivohGrid->TextMatrix[MR][1]="";
         }
        else
         {
           SivohGrid->TextMatrix[MR][1]="√";
         }
      }
   comServer->LocateByKey(WideString(SivohGrid->TextMatrix[MR][2]));
   FillDetailGridWithData();
   //======== END OF FIX ============
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::btnCheckClick(TObject *Sender)
{
  AnsiString sBillCode;
  for(int i=1; i<SivohGrid->RowCount;i++)
  {
   if(SivohGrid->TextMatrix[i][1]=="√")
   {
    sBillCode=SivohGrid->TextMatrix[i][2];
    comServer->LocateByKey(WideString(sBillCode));
    SetHeadValue("SivohChecker",g_sdUserCode);
    try
    {
     comServer->Check(1);
    }
    catch(Exception &e)
    {
     throw Exception("审核发票<"+sBillCode+">出现错误!\n"+e.Message);
    }
   }
 }
  ClearControl();
  btnQueryClick(Sender);
}
//---------------------------------------------------------------------------


void __fastcall TfrmSivohCheck::btnQuiteClick(TObject *Sender)
{
 Close();
}
//---------------------------------------------------------------------------

void __fastcall TfrmSivohCheck::SivohGridMouseMove(TObject *Sender,
      TShiftState Shift, int X, int Y)
{
   int Column,Row;
   SivohGrid->MouseToCell(X,Y,Column,Row);
   //DONE:BUG NO.569 FIXED 2001-8-26
   MC = Column;
   MR = Row;
   //======== END OF FIX ===========
   if(Column==1&&Row>0)
      SivohGrid->Cursor=crHandPoint;
   else
      SivohGrid->Cursor=crDefault;

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

⌨️ 快捷键说明

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