paymode.cpp

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

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

TfrmPayMode *frmPayMode;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::ClearControl(bool BringToNext)
{
    if(!BringToNext)
    {
      sePayModeCode->Text  =   "";
      sePayModeName->Text  =   "";
      memPayModeDesc->Text =   "";
      sePayModeTerm->Text  =   "0";
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::GetDataFromComObject()
{
  sePayModeCode->Text  =   GetFieldValue("PayModeCode");
    sgPayMode->LocateGrid(1,sePayModeCode->Text);
  sePayModeName->Text  =   GetFieldValue("PayModeName");
  memPayModeDesc->Text =   GetFieldValue("PayModeDesc");
  sePayModeTerm->Text  =   GetFieldValue("PayModeTerm");
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::SendDataToComObject()
{
    SetFieldValue("PayModeCode",sePayModeCode->Text);
    SetFieldValue("PayModeName",sePayModeName->Text);
    SetFieldValue("PayModeDesc",memPayModeDesc->Text);
    SetFieldValue("PayModeTerm",sePayModeTerm->Text);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::WaitUserInput()
{
    sePayModeCode->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPayMode::GetDataToGrid()
{
    AnsiString  s;
  s = "\t" + GetFieldValue("PayModeCode") +
      "\t" + GetFieldValue("PayModeName") ;
    return(s);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::RefreshGridData(int mAction)
{
    AnsiString ItemStr;
    ItemStr =   GetDataToGrid();
    if (mAction == 0)     //Add
    {
        sgPayMode->AddItem(ItemStr);
    }
    else if(mAction == 1) //Edit
    {
        int i   =   sgPayMode->Row;
        sgPayMode->RemoveItem(i);
        sgPayMode->AddItem(ItemStr,i);
    }
    else if(mAction ==  2)//Del
    {
        sgPayMode->RemoveItem(sgPayMode->Row);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::FillGridWithData()
{
    AnsiString ItemStr;

    comServer->MoveFirst();
    sgPayMode->RowCount = 1;

    while (comServer->Eof == 0)
    {
        ItemStr = GetDataToGrid();
        sgPayMode->AddItem(ItemStr);
        comServer->MoveNext();
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmPayMode::InitEditControl()
{
    ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
    ClientGroup->AddComponent(2,true,true,false, sgPayMode,sgPayMode->Name);
    ClientGroup->AddComponent(2,false,false,false,sePayModeCode,sePayModeCode->Name);
}
//---------------------------------------------------------------------------

__fastcall TfrmPayMode::TfrmPayMode(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
    : TRecBaseForm(Owner,chWnd,MidCode,WhereStr)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::FormShow(TObject *Sender)
{
    comServer->MoveFirst();
    GetDataFromComObject();
    FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPayMode::sePayModeCodeKeyDown(TObject *Sender,
      WORD &Key, TShiftState Shift)
{
    if(Key==13 && CurrentState==caNormal)
    {
      comServer->LocateByKey(sePayModeCode->Text);
      GetDataFromComObject();
    }

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

void __fastcall TfrmPayMode::sgPayModeClick(TObject *Sender)
{
    if (sgPayMode->Row > 0)
         comServer->LocateByKey(sgPayMode->TextMatrix[sgPayMode->Row][1]);
    if (!comServer->Eof)
         GetDataFromComObject();

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

⌨️ 快捷键说明

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