wl.cpp

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

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

TfrmWl *frmWl;
//---------------------------------------------------------------------------
__fastcall TfrmWl::TfrmWl(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
        : TRecBaseForm(Owner,chWnd,MidCode,WhereStr)
{
    AutoCtl=seWlCode;
}
//---------------------------------------------------------------------------

void __fastcall TfrmWl::ClearControl(bool BringToNext)
{
    if(!BringToNext)
    {
      seWlCode->Text  = "";
      seWlDesc->Text  = "";
      seWlFix->Text   = "0";
      seWlBorus->Text = "0";
      seWlAnce->Text  = "0";
      seWlOther->Text = "0";
      LbWlSum->Caption= "0.00";
    }
}

void __fastcall TfrmWl::GetDataFromComObject()
{
    seWlCode->Text=GetFieldValue("WlCode");
    sgWl->LocateGrid(0,seWlCode->Text);
    seWlDesc->Text=GetFieldValue("WlDesc");
    seWlFix->Text=GetFieldValue("WlFix");
    seWlBorus->Text=GetFieldValue("WlBorus");
    seWlAnce->Text=GetFieldValue("WlAnce");
    seWlOther->Text=GetFieldValue("WlOther");
    LbWlSum->Caption=GetFieldValue("WlSum");
}

void __fastcall TfrmWl::SendDataToComObject()
{
    SetFieldValue("WlCode",seWlCode->Text);
    SetFieldValue("WlDesc",seWlDesc->Text);
    SetFieldValue("WlFix",seWlFix->Text);
    SetFieldValue("WlBorus",seWlBorus->Text);
    SetFieldValue("WlAnce",seWlAnce->Text);
    SetFieldValue("WlOther",seWlOther->Text);
    SetFieldValue("WlSum",LbWlSum->Caption);
}

void __fastcall TfrmWl::WaitUserInput()
{
    if(seWlCode->Enabled)
       seWlCode->SetFocus();
}

AnsiString __fastcall TfrmWl::GetDataToGrid()
{
    AnsiString  ItemStr;
    ItemStr = GetFieldValue("WlCode")+
              "\t" + GetFieldValue("WlFix")+
              "\t" + GetFieldValue("WlBorus")+
              "\t"+ GetFieldValue("WlAnce");
    return(ItemStr);
}

void __fastcall TfrmWl::RefreshGridData(int mAction)
{
   AnsiString ItemStr;
   ItemStr=GetDataToGrid();
   if(mAction==0)
   {
     sgWl->AddItem(ItemStr);
     sgWl->Row=sgWl->RowCount-1;
   }
   else if(mAction==1)
   {
     sgWl->ChangeItem(ItemStr,sgWl->Row);
   }
   else if(mAction==2)
   {
     sgWl->RemoveItem(sgWl->Row);
   }
}

void __fastcall TfrmWl::FillGridWithData()
{
    AnsiString ItemStr;
    comServer->MoveFirst();
    sgWl->RowCount = 1;
    while (comServer->Eof == 0)
    {
       ItemStr = GetDataToGrid();
       sgWl->AddItem(ItemStr);
       comServer->MoveNext();
    }
}

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

void __fastcall TfrmWl::FormShow(TObject *Sender)
{
    FillGridWithData();
    ClearControl(false);
    comServer->MoveFirst();
    GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmWl::sgWlClick(TObject *Sender)
{
    if(sgWl->Row > 0)
       //comServer->LocateByKey(WideString(sgWl->TextMatrix[sgWl->Row][0]));
       comServer->LocateByIndex(sgWl->Row-1);
    if(!comServer->Eof)
       GetDataFromComObject();
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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