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

📄 smode.cpp

📁 速达开源ERP系统
💻 CPP
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "Smode.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "RecBaseForm"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmSmode *frmSmode;
//---------------------------------------------------------------------------
__fastcall TfrmSmode::TfrmSmode(TComponent* Owner)
        : TRecBaseForm(Owner,euSdSmode,"")
{
 AutoCtl=seSmodeCode;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmSmode::GetFieldValue(int FieldIndex)
{
    WideString S;
    S   =   ReadFieldValue(comServer,FieldIndex);
    return(S);
}

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

    seSmodeCode->Text   =   "";
    seSmodeName->Text   =   "";
    seSmodeDesc->Text   =   "";
}

void __fastcall TfrmSmode::GetDataFromComObject()
{
    seSmodeCode->Text  =   GetFieldValue(fiSmodeCode);
    seSmodeName->Text  =   GetFieldValue(fiSmodeName);
    seSmodeDesc->Text  =   GetFieldValue(fiSmodeDesc);
    sgSmode->LocateGrid(1,seSmodeCode->Text);
}

void __fastcall TfrmSmode::SendDataToComObject()
{
    WriteFieldValue(comServer,fiSmodeCode,WideString(seSmodeCode->Text));
    WriteFieldValue(comServer,fiSmodeName,WideString(seSmodeName->Text));
    WriteFieldValue(comServer,fiSmodeDesc,WideString(seSmodeDesc->Text));
}

void __fastcall TfrmSmode::WaitUserInput()
{
    if(seSmodeCode->Enabled)
    seSmodeCode->SetFocus();
}

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

    s   =   "\t" + GetFieldValue(fiSmodeCode)    +
            "\t" + GetFieldValue(fiSmodeName)    +
            "\t" + GetFieldValue(fiSmodeDesc);
    return(s);
}

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

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



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

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

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


void __fastcall TfrmSmode::InitEditControl()
{
    ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
    ClientGroup->AddComponent(2,true,true,false, sgSmode,sgSmode->Name);
}
//---------------------------------------------------------------------------
void __fastcall TfrmSmode::FormClose(TObject *Sender, TCloseAction &Action)
{
    TRecBaseForm::FormClose(Sender,Action);
/*
    AnsiString FormIniFile = "D:\Test.Ini";
    WriteGridWidth(Name,sgSmode,FormIniFile);
*/
}
//---------------------------------------------------------------------------
void __fastcall TfrmSmode::FormShow(TObject *Sender)
{
    FillGridWithData();
    comServer->MoveFirst();
    GetDataFromComObject();
}
//---------------------------------------------------------------------------

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

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

⌨️ 快捷键说明

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