socr.cpp

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

CPP
134
字号
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "SoCr.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "RecBaseForm"
#pragma link "fpanel"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmSoCr *frmSoCr;
//---------------------------------------------------------------------------

void __fastcall TfrmSoCr::ClearControl(bool BringToNext)
{
    // BringToNext为真时,不清空
    if(BringToNext)
        return;

    seSoCrCode->Text   =   "";
    seSoCrDesc->Text   =   "";
}

void __fastcall TfrmSoCr::GetDataFromComObject()
{
    seSoCrCode->Text  =   GetFieldValue("SoCrCode");
    seSoCrDesc->Text  =   GetFieldValue("SoCrDesc");
    sgSoCr->LocateGrid(1,seSoCrCode->Text);    
}

void __fastcall TfrmSoCr::SendDataToComObject()
{
    SetFieldValue("SoCrCode",WideString(seSoCrCode->Text));
    SetFieldValue("SoCrDesc",WideString(seSoCrDesc->Text));
}

void __fastcall TfrmSoCr::WaitUserInput()
{
    if(seSoCrCode->Enabled)
    seSoCrCode->SetFocus();
}

AnsiString __fastcall TfrmSoCr::GetDataToGrid()
{
    AnsiString  s;

    s   =   "\t" + GetFieldValue("SoCrCode")    +
            "\t" + GetFieldValue("SoCrDesc");
    return(s);
}

void __fastcall TfrmSoCr::RefreshGridData(int mAction)
{
    AnsiString ItemStr;

    ItemStr =   GetDataToGrid();
    // 新增
    if (mAction ==  0)
    {
        sgSoCr->AddItem(ItemStr);
        sgSoCr->Row=sgSoCr->RowCount-1;        
    }
    // 修改
    else if(mAction ==  1)
    {
     sgSoCr->ChangeItem(ItemStr,sgSoCr->Row);
     }
    // 删除
    else if(mAction ==  2)
    {
        sgSoCr->RemoveItem(sgSoCr->Row);
    }
}



void __fastcall TfrmSoCr::FillGridWithData()
{
    AnsiString ItemStr;

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

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


void __fastcall TfrmSoCr::InitEditControl()
{
    ClientGroup->AddComponent(2,true,true,false, sgSoCr,sgSoCr->Name);
    ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
}


__fastcall TfrmSoCr::TfrmSoCr(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
    : TRecBaseForm(Owner,chWnd,MidCode,WhereStr)
{
 AutoCtl=seSoCrCode;
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoCr::FormCreate(TObject *Sender)
{
 /*
    AnsiString FormIniFile="D:\Test.Ini";
    SetGridWidth(Name,sgSoCr,FormIniFile);
*/   
}
//---------------------------------------------------------------------------
void __fastcall TfrmSoCr::FormShow(TObject *Sender)
{
    FillGridWithData();
    comServer->MoveFirst();
    GetDataFromComObject();
}
//---------------------------------------------------------------------------

void __fastcall TfrmSoCr::sgSoCrClick(TObject *Sender)
{
    if (sgSoCr->Row    >   0)
         comServer->LocateByKey(WideString(sgSoCr->TextMatrix[sgSoCr->Row][1]));
    if (!comServer->Eof)
         GetDataFromComObject();

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

⌨️ 快捷键说明

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