⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stype.cpp

📁 速达开源ERP系统
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Stype.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "RecBaseForm"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmStype *frmStype;
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmStype::GetFieldValue(int FieldIndex)
{
    WideString S;
    S  = ReadFieldValue(comServer,FieldIndex);
    return(S);
}
//---------------------------------------------------------------------------

void __fastcall TfrmStype::ClearControl(bool BringToNext)
{
    if(BringToNext)
    {
       return;
    }
    seStypeCode->Text   =   "";
    seStypeName->Text   =   "";
    seStypeDesc->Text   =   "";
}
//---------------------------------------------------------------------------

void __fastcall TfrmStype::GetDataFromComObject()
{
    seStypeCode->Text  =   GetFieldValue(fiStypeCode);
    seStypeName->Text  =   GetFieldValue(fiStypeName);
    seStypeDesc->Text  =   GetFieldValue(fiStypeDesc);
    sgStype->LocateGrid(1,seStypeCode->Text);    
}
//---------------------------------------------------------------------------

void __fastcall TfrmStype::SendDataToComObject()
{
    WriteFieldValue(comServer,fiStypeCode,WideString(seStypeCode->Text));
    WriteFieldValue(comServer,fiStypeName,WideString(seStypeName->Text));
    WriteFieldValue(comServer,fiStypeDesc,WideString(seStypeDesc->Text));

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

void __fastcall TfrmStype::WaitUserInput()
{
    if(seStypeCode->Enabled)
    seStypeCode->SetFocus();
}
//---------------------------------------------------------------------------

AnsiString __fastcall TfrmStype::GetDataToGrid()
{
    AnsiString  s;
    s = "\t" + GetFieldValue(fiStypeCode)    +
        "\t" + GetFieldValue(fiStypeName)    +
        "\t" + GetFieldValue(fiStypeDesc);
    return(s);
}
//---------------------------------------------------------------------------

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

    ItemStr =   GetDataToGrid();
    // 新增
    if (mAction ==  0)
    {
        sgStype->AddItem(ItemStr);
        sgStype->Row=sgStype->RowCount-1;        
    }
    // 修改
    else if(mAction ==  1)
    {
     sgStype->ChangeItem(ItemStr,sgStype->Row);
    }
    // 删除
    else if(mAction ==  2)
    {
        sgStype->RemoveItem(sgStype->Row);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmStype::FillGridWithData()
{
    AnsiString ItemStr;

    comServer->MoveFirst();
    sgStype->RowCount = 1;
    while (comServer->Eof == 0)
    {
        ItemStr =   GetDataToGrid();
        sgStype->AddItem(ItemStr);
        comServer->MoveNext();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmStype::InitEditControl()
{
    ClientGroup->AddComponent(2,true,true,false, sgStype,sgStype->Name);
    ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
}
//---------------------------------------------------------------------------

__fastcall TfrmStype::TfrmStype(TComponent* Owner)
    : TRecBaseForm(Owner,euSdStype,"")
{
    AutoCtl=seStypeCode;
}
//---------------------------------------------------------------------------
void __fastcall TfrmStype::FormShow(TObject *Sender)
{
    FillGridWithData();
    comServer->MoveFirst();
    GetDataFromComObject();
}

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

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

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

⌨️ 快捷键说明

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