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

📄 psd.cpp

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

#include "Psd.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "RecBaseForm"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "DateEdit"
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma resource "*.dfm"
TfrmPsd *frmPsd;
AnsiString LastPsdSupply;
//---------------------------------------------------------------------------

__fastcall TfrmPsd::TfrmPsd(TComponent* Owner)
    : TRecBaseForm(Owner,euSdPsd,"")
{
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPsd::GetFieldValue(int FieldIndex)
{
    AnsiString S;
    S = ReadFieldValue(comServer,FieldIndex);
    return(S);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPsd::ClearControl(bool BringToNext)
{
    if(BringToNext)
    {
        return;
    }
    scPsdCurrencyCode->ItemIndex=   -1;    // 币种
    sePsdBankName->Text         =   "";    // 银行名称
    sePsdBankNo->Text           =   "";    // 银行帐号
    chkPsdPrimary->Checked      =   false; //主币种
}
//---------------------------------------------------------------------------


void __fastcall TfrmPsd::GetDataFromComObject()
{
    scPsdCurrencyCode->LocateKey(GetFieldValue(fiPsdCurrencyCode));
    sgPsd->LocateGrid(1,GetFieldValue(fiPsdCurrencyCode));
    sePsdBankName->Text         =   GetFieldValue(fiPsdBankName);
    sePsdBankNo->Text           =   GetFieldValue(fiPsdBankNo);
    chkPsdPrimary->Checked      =   (GetFieldValue(fiPsdPrimary)=="1");
}
//---------------------------------------------------------------------------

void __fastcall TfrmPsd::SendDataToComObject()
{
    WriteFieldValue(comServer,fiPsdSupplyCode,WideString(scPsdSupplyCode->ItemData[1]));
    WriteFieldValue(comServer,fiPsdCurrencyCode,WideString(scPsdCurrencyCode->ItemData[1]));
    WriteFieldValue(comServer,fiPsdBankName,WideString(sePsdBankName->Text));
    WriteFieldValue(comServer,fiPsdBankNo,WideString(sePsdBankNo->Text));
    if(chkPsdPrimary->Checked)
     WriteFieldValue(comServer,fiPsdPrimary,WideString("1"));
    else
     WriteFieldValue(comServer,fiPsdPrimary,WideString("0"));
}
//---------------------------------------------------------------------------

void __fastcall TfrmPsd::WaitUserInput()
{
    scPsdCurrencyCode->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPsd::GetDataToGrid()
{

   scPsdCurrencyCode->LocateKey(GetFieldValue(fiPsdCurrencyCode));
   AnsiString  s;
    s = "\t" + scPsdCurrencyCode->ItemData[1]+
        "\t" + scPsdCurrencyCode->Text+
        "\t" + GetFieldValue(fiPsdBankName)+
        "\t" + GetFieldValue(fiPsdBankNo)+
        "\t" + (GetFieldValue(fiPsdPrimary)=="1"?"主币种":"辅币种");
    return(s);
}
//---------------------------------------------------------------------------

void __fastcall TfrmPsd::RefreshGridData(int mAction)
{
    AnsiString ItemStr;
    ItemStr =   GetDataToGrid();
    if (mAction == 0)
    {
        sgPsd->AddItem(ItemStr);
    }
    else if(mAction == 1)
    {
        int i   =   sgPsd->Row;
        sgPsd->ChangeItem(ItemStr,i);
    }
    else if(mAction == 2)
    {
        sgPsd->RemoveItem(sgPsd->Row);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPsd::FillGridWithData()
{
    AnsiString ItemStr;
    comServer->MoveFirst();
    sgPsd->RowCount = 1;
    while (comServer->Eof == 0)
    {
        ItemStr = GetDataToGrid();
        sgPsd->AddItem(ItemStr);
        comServer->MoveNext();
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmPsd::InitEditControl()
{
    ClientGroup->AddComponent(2,true,true,false,FloatPanel2,FloatPanel2->Name);
    ClientGroup->AddComponent(2,true,true,false, sgPsd,sgPsd->Name);
    ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
    FillComboBox(scPsdSupplyCode,"SELECT SUPPLYCODE,supplyName FROM SDSUPPLY   where supplycancel=0  order by SupplyCode","supplyName","SupplyCode");
    FillComboBox(scPsdCurrencyCode,"select  CurrencyCode,Currencyname from sdCurrency order By CurrencyCode","CurrencyName","CurrencyCode");
}
//---------------------------------------------------------------------------

void __fastcall TfrmPsd::FormClose(TObject *Sender, TCloseAction &Action)
{
    TRecBaseForm::FormClose(Sender,Action);
    //AnsiString FormIniFile = "D:\Test.Ini";
    //WriteGridWidth(Name,sgPsd,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPsd::FormCreate(TObject *Sender)
{
   //AnsiString FormIniFile="D:\Test.Ini";
   //SetGridWidth(Name,sgPsd,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPsd::FormShow(TObject *Sender)
{
    ClearControl(false);
    LastPsdSupply="";
    if(scPsdSupplyCode->Items->Count > 0)
    {
     scPsdSupplyCode->ItemIndex=0;
     scPsdSupplyCodeClick(NULL);
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmPsd::scPsdSupplyCodeClick(TObject *Sender)
{
   AnsiString s;
   if(scPsdSupplyCode->ItemIndex==-1)
    return;
   s=scPsdSupplyCode->ItemData[1];
   if(s.IsEmpty())
     return;
   if(LastPsdSupply==s)
     return;
   LastPsdSupply=s;
   s = "PsdSupplyCode = '" + s + "'";
   comServer->FilterString = WideString(s);
   comServer->Query();
   FillGridWithData();
   comServer->MoveFirst();
   GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPsd::sgPsdClick(TObject *Sender)
{
    int ARow=sgPsd->Row;
    AnsiString KeyStr;
    if (ARow > 0)
    {
         KeyStr=scPsdSupplyCode->ItemData[1]+sgPsd->TextMatrix[ARow][1];
         comServer->LocateByKey(WideString(KeyStr));
    }
    if (!comServer->Eof)
         GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPsd::RefreshUpdateData(int MsgSrc,int MsgType)
{
  switch(MsgSrc)
  {
   case euSdSupply:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scPsdSupplyCode,"SELECT SUPPLYCODE,supplyName FROM SDSUPPLY   where supplycancel=0  order by SupplyCode","supplyName","SupplyCode");
     scPsdSupplyCodeClick(NULL);
    }
    break;
   case euSdCurrency:
    if(ShowUpdateMessage(MsgSrc,MsgType))
    {
     FillComboBox(scPsdCurrencyCode,"select  CurrencyCode,Currencyname from sdCurrency order By CurrencyCode","CurrencyName","CurrencyCode");
    }
    break;
   default:
    break;
  }
}
//---------------------------------------------------------------------------


⌨️ 快捷键说明

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