aplt.cpp

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

CPP
162
字号
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Aplt.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "RecBaseForm"
#pragma link "fpanel"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "SDComboBox"
#pragma resource "*.dfm"
TfrmAplt *frmAplt;
//---------------------------------------------------------------------------
__fastcall TfrmAplt::TfrmAplt(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
        : TRecBaseForm(Owner,chWnd,MidCode,WhereStr)
{  SetAutoCodeString(seApltCode,"Acm-77");
   InitRsGlkm("");
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TfrmAplt::ClearControl(bool BringToNext)
{
    if(!BringToNext)
    {
      seApltCode->Text    ="";  //类型编码
      seApltName->Text    ="";  //类型名称
      memApltDesc->Text   ="";  //说明
      seApltGlkm->Text    ="";  //科目
      rbApltDirj->Checked =true; //方向
      scApltFrom->ItemIndex  =0;//应付来源
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmAplt::InitEditControl()
{
       ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
       ClientGroup->AddComponent(2,true,true,false, sgAplt,sgAplt->Name);
       ClientGroup->AddComponent(2,false,false,false, seApltCode,seApltCode->Name);
       scApltFrom->AddItems("物料","1");
       scApltFrom->AddItems("劳务","2");
       scApltFrom->AddItems("费用","3");
       scApltFrom->AddItems("其它","4");
}
//---------------------------------------------------------------------------
void __fastcall TfrmAplt::GetDataFromComObject()
{
      seApltCode->Text   =GetFieldValue("ApltCode");
      sgAplt->LocateGrid(1,seApltCode->Text);
      seApltName->Text   =GetFieldValue("ApltName");
      memApltDesc->Text   =GetFieldValue("ApltDesc");
      seApltGlkm->Text  =GetFieldValue("ApltGlkm");
      if(GetFieldValue("ApltDir")=="1")
        rbApltDirj->Checked =true;
      else
        rbApltDird->Checked =true;
      scApltFrom->LocateKey(GetFieldValue("ApltFrom"));
      scApltFrom->Text  =scApltFrom->ItemData[0];
}
//---------------------------------------------------------------------------
void __fastcall TfrmAplt::SendDataToComObject()
{
      SetFieldValue("ApltCode",seApltCode->Text);
      SetFieldValue("ApltName",seApltName->Text);
      SetFieldValue("ApltDesc",memApltDesc->Text);
      SetFieldValue("ApltGlkm",seApltGlkm->Text);
      SetFieldValue("ApltDir",(rbApltDirj->Checked==true?"1":"-1"));
      SetFieldValue("ApltFrom",scApltFrom->ItemData[1]);
}
//---------------------------------------------------------------------------
void __fastcall TfrmAplt::WaitUserInput()
{
      seApltCode->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmAplt::GetDataToGrid()
{
      AnsiString  s;
      s = "\t" + GetFieldValue("ApltCode")    +
          "\t" + GetFieldValue("ApltName")    ;
      return s;
}
//---------------------------------------------------------------------------
void __fastcall TfrmAplt::RefreshGridData(int mAction)
{
      AnsiString ItemStr;
      ItemStr = GetDataToGrid();
      if (mAction ==  0)   //Add
      {
          sgAplt->AddItem(ItemStr);
      }
      else if(mAction ==  1)   //Modify
      {
          int i   =   sgAplt->Row;
          sgAplt->ChangeItem(ItemStr,i);
      }
      else if(mAction ==  2)      //Delete
      {
          sgAplt->RemoveItem(sgAplt->Row);
      }
}
//---------------------------------------------------------------------------
void __fastcall TfrmAplt::FillGridWithData()
{
      AnsiString ItemStr;
      comServer->MoveFirst();
      sgAplt->RowCount    =   1;
      while (comServer->Eof   ==  0)
      {
         ItemStr =  GetDataToGrid();
         sgAplt->AddItem(ItemStr);
         comServer->MoveNext();
      }
      comServer->MoveFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmAplt::FormShow(TObject *Sender)
{
      FillGridWithData();
      comServer->MoveFirst();
      GetDataFromComObject();

}
//---------------------------------------------------------------------------
void __fastcall TfrmAplt::seApltCodeKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
      if(Key==13 && CurrentState==caNormal)
      {
       comServer->LocateByKey(WideString(seApltCode->Text));
       GetDataFromComObject();
      }

}
//---------------------------------------------------------------------------
void __fastcall TfrmAplt::sgApltClick(TObject *Sender)
{
      if (sgAplt->Row > 0)
          comServer->LocateByKey(WideString(sgAplt->TextMatrix[sgAplt->Row][1]));
      if (!comServer->Eof)
       GetDataFromComObject();

}
//---------------------------------------------------------------------------
void __fastcall TfrmAplt::seApltGlkmButtonClick(TObject *Sender)
{
   
   if(OpenGlkmForm ())
   {
     seApltGlkm->Text=GetGlkmValue(gtOpenForm,"GLKMCODE");
     if(GetGlkmValue(gtOpenForm,"GLKMDIR")=="1")
        rbApltDirj->Checked =true;
     else
        rbApltDird->Checked =true;
   }

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

⌨️ 快捷键说明

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