intax.cpp

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

CPP
164
字号
//---------------------------------------------------------------------------
#include <vcl.h>
#include "InTax.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "RecBaseForm"
#pragma link "fpanel"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"

TfrmInTax *frmInTax;
//---------------------------------------------------------------------------
__fastcall TfrmInTax::TfrmInTax(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
        : TRecBaseForm(Owner,chWnd,MidCode,WhereStr)
{

}
//---------------------------------------------------------------------------
void __fastcall TfrmInTax::InitEditControl()
{    // int mSection, bool NewAct,bool EditAct,bool BrowseAct
    ClientGroup->AddComponent(2,true,true,false, sgInTax,sgInTax->Name);
    ClientGroup->AddComponent(2,false,false,true, seInTaxBegAmt,seInTaxBegAmt->Name);
    ClientGroup->AddComponent(2,false,false,true, seInTaxEndAmt,seInTaxEndAmt->Name);
    ClientGroup->AddComponent(2,false,false,true, seInTaxRate,seInTaxRate->Name);
    ClientGroup->AddComponent(2,false,false,false, seInTaxLine,seInTaxLine->Name);

}
//---------------------------------------------------------------------------
void __fastcall TfrmInTax::ClearControl(bool BringToNext)
{
    if(!BringToNext)
    {
      seInTaxLine->Text  = AnsiString(GetMaxInTaxLine().ToInt()+1);
      seInTaxBegAmt->Text= "0";
      seInTaxEndAmt->Text= "0";
      seInTaxRate->Text  = "0.00";
    }
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmInTax::GetMaxInTaxLine()
{
    /*
    int MaxLine=1;
    for(int i=1;i<sgInTax->RowCount;i++)
    {
       if(StrToInt(sgInTax->Cells[0][i])>MaxLine)
          MaxLine=StrToInt(sgInTax->Cells[0][i]);
    }
    return AnsiString(MaxLine);
    */
    //-----------
    int MaxLine=0;
    comServer->Query();
    comServer->MoveFirst();
    while(comServer->Eof == 0)
    {
      if (MaxLine<StrToInt(GetFieldValue("InTaxLine")))
      {
        MaxLine=StrToInt(GetFieldValue("InTaxLine"));
      }
      comServer->MoveNext();
    }
    return AnsiString(MaxLine);
    //-------------
}
//---------------------------------------------------------------------------
void __fastcall TfrmInTax::GetDataFromComObject()
{
    seInTaxLine->Text  = GetFieldValue("InTaxLine");
    seInTaxBegAmt->Text= GetFieldValue("InTaxBegAmt");
    seInTaxEndAmt->Text= GetFieldValue("InTaxEndAmt");
    seInTaxRate->Text  = GetFieldValue("InTaxRate");
    sgInTax->LocateGrid(0,seInTaxLine->Text);
}
//---------------------------------------------------------------------------
void __fastcall TfrmInTax::SendDataToComObject()
{
    SetFieldValue("InTaxLine",seInTaxLine->Text);
    SetFieldValue("InTaxBegAmt",seInTaxBegAmt->Text);
    SetFieldValue("InTaxEndAmt",seInTaxEndAmt->Text);
    SetFieldValue("InTaxRate",seInTaxRate->Text);
}
//---------------------------------------------------------------------------
void __fastcall TfrmInTax::WaitUserInput()
{
    if(seInTaxBegAmt->Enabled)
      seInTaxBegAmt->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmInTax::GetDataToGrid()
{
    AnsiString  ItemStr;
    ItemStr = GetFieldValue("InTaxLine") +
       "\t" + GetFieldValue("InTaxBegAmt") +
       "\t" + GetFieldValue("InTaxEndAmt")+
       "\t" + GetFieldValue("InTaxRate") ;
    return(ItemStr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmInTax::RefreshGridData(int mAction)
{
    AnsiString ItemStr;
    ItemStr = GetDataToGrid();
    if (mAction ==  0)   //Add
    {
        sgInTax->AddItem(ItemStr);
    }
    else if(mAction ==  1)   //Modify
    {
        int i   =   sgInTax->Row;
        sgInTax->ChangeItem(ItemStr,i);
    }
    else if(mAction ==  2)      //Delete
    {
        sgInTax->RemoveItem(sgInTax->Row);
    }
      
}
//---------------------------------------------------------------------------
void __fastcall TfrmInTax::FillGridWithData()
{
    AnsiString ItemStr;
    comServer->MoveFirst();
    sgInTax->RowCount = 1;
    while(comServer->Eof == 0)
    {
        ItemStr = GetDataToGrid();
        sgInTax->AddItem(ItemStr);
        comServer->MoveNext();
    }
 
}
//---------------------------------------------------------------------------

void __fastcall TfrmInTax::FormShow(TObject *Sender)
{
    FillGridWithData();
    comServer->MoveFirst();
    GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmInTax::sgInTaxClick(TObject *Sender)
{
    if(sgInTax->Row > 0)
      comServer->LocateByKey(sgInTax->TextMatrix[sgInTax->Row][0]);
    if(!comServer->Eof)
      GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmInTax::seInTaxLineKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    if(Key==13 && CurrentState==caNormal)
    {
      comServer->LocateByKey(seInTaxLine->Text);
      GetDataFromComObject();
    }
}
//---------------------------------------------------------------------------


⌨️ 快捷键说明

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