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

📄 rate.cpp

📁 速达开源ERP系统
💻 CPP
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Rate.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "RecBaseForm"
#pragma link "fpanel"
#pragma link "SDComboBox"
#pragma link "SDGrid"
#pragma link "SDEdit"
#pragma resource "*.dfm"

TfrmRate *frmRate;
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmRate::GetFieldValue(int FieldIndex)
{
    WideString S;  
    S = ReadFieldValue(comServer,FieldIndex);
    return(S);
}
//---------------------------------------------------------------------------
void __fastcall TfrmRate::ClearControl(bool BringToNext)
{
    if(!BringToNext)
    {

        scRateCurrency->ItemIndex =-1; 
        seRateRatio->Text         = "0.00";
        seRateCurrencyName->Text  = "";
        seRateCurrencySym->Text   = "";
        seRateAmtDec->Text        = "";
        seRatePriceDec->Text      = "";
        scRateCarry->Text         = "";
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmRate::GetDataFromComObject()
{
    scRateCurrency->LocateKey(GetFieldValue(fiRateCurrency));
    scRateCurrency->Text    =scRateCurrency->ItemData[0];
    sgRate->LocateGrid(1,scRateCurrency->Text);
    seRateCurrencyName->Text=scRateCurrency->ItemData[1];
    seRateCurrencySym->Text=scRateCurrency->ItemData[2];
    seRateAmtDec->Text      = scRateCurrency->ItemData[3];
    seRatePriceDec->Text    = scRateCurrency->ItemData[4];
    scRateCarry->LocateKey(scRateCurrency->ItemData[5]);
    scRateCarry->Text       =scRateCarry->ItemData[0];
    seRateRatio->Text       = GetFieldValue(fiRateRatio);

}
//---------------------------------------------------------------------------
void __fastcall TfrmRate::SendDataToComObject()
{
    if(scRateFmon->Text<g_sdFMonth)
      throw Exception("不能设置以前月份汇率");
    WriteFieldValue(comServer,fiRateFmonth,scRateFmon->Text);
    WriteFieldValue(comServer,fiRateCurrency,scRateCurrency->Text);
    WriteFieldValue(comServer,fiRateRatio,seRateRatio->Text);
}
//---------------------------------------------------------------------------
void __fastcall TfrmRate::WaitUserInput()
{
    scRateCurrency->SetFocus();
}
//---------------------------------------------------------------------------

AnsiString __fastcall TfrmRate::GetDataToGrid()
{
    AnsiString  s;
    scRateCurrency->LocateKey(GetFieldValue(fiRateCurrency));
    s = "\t" + scRateCurrency->ItemData[0] +
        "\t" + GetFieldValue(fiRateRatio);
    return(s);
}
//---------------------------------------------------------------------------
void __fastcall TfrmRate::RefreshGridData(int mAction)
{
    AnsiString ItemStr;
    ItemStr = GetDataToGrid();
    if (mAction == 0)
    {
        sgRate->AddItem(ItemStr);
    }
    else if(mAction == 1)
    {
        int i = sgRate->Row;
        sgRate->RemoveItem(i);
        sgRate->AddItem(ItemStr,i);
    }
    else if(mAction == 2)
    {
        sgRate->RemoveItem(sgRate->Row);
    }
}
//---------------------------------------------------------------------------

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

void __fastcall TfrmRate::InitEditControl()
{
    ClientGroup->AddComponent(2,false,false,true, scRateCurrency,scRateCurrency->Name);
    ClientGroup->AddComponent(2,false,false,true, seRateRatio,seRateRatio->Name);
    ClientGroup->AddComponent(2,true,true,false, scRateFmon,scRateFmon->Name);
    ClientGroup->AddComponent(2,true,true,false, sgRate,sgRate->Name);
    ClientGroup->AddComponent(2,true,true,true, Panel1,Panel1->Name );
    FillComboBox(scRateFmon,"select FcMonth from sdFc order By FcMonth desc","FcMonth");
    AnsiString m_SqlStr;
    m_SqlStr=AnsiString("select CurrencyCode,CurrencyName,CurrencySym,CurrencyAmtDec,CurrencyPriceDec,")+
             AnsiString("CurrencyCarry,CurrencyLocal from sdCurrency  where CURRENCYLOCAL=0 Order by CurrencyCode");
    FillComboBox(scRateCurrency,m_SqlStr,"CurrencyCode","CurrencyName","CurrencySym","CurrencyAmtDec","CurrencyPriceDec","CurrencyCarry","CurrencyLocal");
    scRateCarry->AddItems("四舍五入","1");
    scRateCarry->AddItems("取整","2");
    scRateCarry->AddItems("向上取整","3");
}
//---------------------------------------------------------------------------
__fastcall TfrmRate::TfrmRate(TComponent* Owner)
    : TRecBaseForm(Owner,euSdRate,"")
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmRate::FormShow(TObject *Sender)
{
      scRateFmon->Text=g_sdFMonth;
      comServer->FilterString = "RateFmonth = '"+scRateFmon->Text+"'";
      comServer->Query();
      FillGridWithData();
      comServer->MoveFirst();
      GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmRate::scRateFmonClick(TObject *Sender)
{
    comServer->FilterString = "RateFmonth = '"+scRateFmon->Text+"'";
    comServer->Query();
    FillGridWithData();
    comServer->MoveFirst();
    GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmRate::scRateCurrencyExit(TObject *Sender)
{
    scRateCurrency->LocateKey(scRateCurrency->Text);
    seRateCurrencyName->Text=scRateCurrency->ItemData[1];
    seRateCurrencySym->Text=scRateCurrency->ItemData[2];
    seRateAmtDec->Text      = scRateCurrency->ItemData[3];
    seRatePriceDec->Text    = scRateCurrency->ItemData[4];
    scRateCarry->LocateKey(scRateCurrency->ItemData[5]);

}
//---------------------------------------------------------------------------
void __fastcall TfrmRate::RefreshUpdateData(int MsgSrc,int MsgType)
{
      switch(MsgSrc)
      {
        case euSdFc:
          if(ShowUpdateMessage(MsgSrc,MsgType))
             FillComboBox(scRateFmon,"select FcMonth from sdFc order By FcMonth","FcMonth");
         break;
        case euSdCurrency:
         if(ShowUpdateMessage(MsgSrc,MsgType))
         {
            AnsiString m_SqlStr;
            m_SqlStr=AnsiString("select CurrencyCode,CurrencyName,CurrencySym,CurrencyAmtDec,CurrencyPriceDec,")+
            AnsiString("CurrencyCarry,CurrencyLocal from sdCurrency Order by CurrencyCode");
            FillComboBox(scRateCurrency,m_SqlStr,"CurrencyCode","CurrencyName","CurrencySym","CurrencyAmtDec","CurrencyPriceDec","CurrencyCarry","CurrencyLocal");
         }
         break;
       default:
         break;
      }
}
//---------------------------------------------------------------------------

void __fastcall TfrmRate::scRateCurrencyKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
    if(Key==13 && CurrentState==caNormal)
    {
      comServer->LocateByKey(scRateFmon->Text+scRateCurrency->Text);
      GetDataFromComObject();
    }

}
//---------------------------------------------------------------------------
void __fastcall TfrmRate::sgRateClick(TObject *Sender)
{
     if (sgRate->Row >0 )
     {                             
           comServer->LocateByKey(scRateFmon->Text+sgRate->TextMatrix[sgRate->Row][1]);
        if (!comServer->Eof)
          GetDataFromComObject();
     }

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



⌨️ 快捷键说明

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