apnp.cpp

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

CPP
292
字号
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Apnp.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "RecBaseForm"
#pragma link "fpanel"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "DateEdit"
#pragma resource "*.dfm"
TfrmApnp *frmApnp;
//---------------------------------------------------------------------------
__fastcall TfrmApnp::TfrmApnp(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
        : TRecBaseForm(Owner,chWnd,MidCode,WhereStr)
{
   AutoCtl=seApnpCode;
   IsUserCheck=true;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TfrmApnp::ClearControl(bool BringToNext)
{
    tbCheck->Visible=true;
    if(!BringToNext)
    {
      seApnpCode->Text        ="Acm-52";  //票据号
      scApnpFmonth->Text      =g_sdFMonth;  //月份
      deApnpDate->Text        =g_sdCurDate;  //日期
      scApnpCant->ItemIndex   =-1;  //票据类型
      scApnpSupply->ItemIndex =-1;  //受票方(供应商)
      scApnpCurrency->ItemIndex =-1;  //币种
      seApnpEnrate->Text      ="";  //汇率
      seApnpAmt->Text         ="";  //票面金额
      seApnpUiRate->Text      ="";  //未到期利率
      seApnpEiRate->Text      ="";  //到期利率
      deApnpSdate->Text       ="";  //签发日期
      deApnpEdate->Text       ="";  //到期日期
      seApnpTerm->Text        ="";  //期限
      seApnpCAmt->Text        ="";  //核销金额
      memApnpDesc->Text       ="";  //备注
      scApnpState->ItemIndex  =0;  //状态
      lbApnpUser->Caption     =g_sdUserCode;  //操作员
      chkApnpCheck->Checked   =false;  //审核标志
      lbApnpChecker->Caption  ="";  //审核人
      lbApnpCheckDate->Caption="";  //审核日期
      lbApnpSysDate->Caption  ="";  //系统日期

    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmApnp::InitEditControl()
{
    ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
    ClientGroup->AddComponent(2,true,true,false, sgApnp,sgApnp->Name);
    ClientGroup->AddComponent(2,false,false,false, seApnpCode,seApnpCode->Name);
    ClientGroup->AddComponent(2,true,true,true, scApnpFmonth,scApnpFmonth->Name);
    ClientGroup->AddComponent(2,true,true,true, seApnpCAmt,seApnpCAmt->Name);
    ClientGroup->AddComponent(2,true,true,true,scApnpState,scApnpState->Name);
    FillComboBox(Handle,scApnpFmonth,"SELECT Fcmonth FROM sdFc","Fcmonth");
    FillComboBox(Handle,scApnpSupply,"SELECT SupplyCode,SupplyName FROM sdSupply  where supplycancel=0  order by SupplyCode","SupplyName","SupplyCode");
    AnsiString sSql;
    sSql =AnsiString("select currencycode,currencyname,currencyrate=coalesce(rateratio,1),currencylocal from sdcurrency,sdrate");
    sSql+=" where currencycode*=ratecurrency and ";
    sSql+=" ratefmonth='"+g_sdPMonth+"'";
    FillComboBox(Handle,scApnpCurrency,sSql,"CurrencyName","CurrencyCode","currencyrate","currencylocal");
    FillComboBox(Handle,scApnpCant,"select Cantname,Cantcode from sdCant","Cantname","Cantcode");
    scApnpState->AddItems("未处理","1");
    scApnpState->AddItems("付 款","2");
    scApnpState->AddItems("退 回","3");
}
//---------------------------------------------------------------------------
void __fastcall TfrmApnp::GetDataFromComObject()
{
      seApnpCode->Text  = GetFieldValue("ApnpCode");
      sgApnp->LocateGrid(1,seApnpCode->Text);
      scApnpFmonth->Text  = GetFieldValue("ApnpFmonth");
      deApnpDate->Text  = GetFieldValue("ApnpDate");
      scApnpCant->LocateKey(GetFieldValue("ApnpCant"));
      scApnpCant->Text  = scApnpCant->ItemData[0];
      scApnpSupply->LocateKey(GetFieldValue("ApnpSupply"));
      scApnpSupply->Text  = scApnpSupply->ItemData[0];
      scApnpCurrency->LocateKey(GetFieldValue("ApnpCurrency"));
      scApnpCurrency->Text  = scApnpCurrency->ItemData[0];
      seApnpEnrate->Text   =GetFieldValue("ApnpEnrate");
      seApnpAmt->Text   =GetFieldValue("ApnpAmt");
      seApnpUiRate->Text   =GetFieldValue("ApnpUiRate");
      seApnpEiRate->Text   =GetFieldValue("ApnpEiRate");
      deApnpSdate->Text   =GetFieldValue("ApnpSdate");
      deApnpEdate->Text   =GetFieldValue("ApnpEdate");
      seApnpTerm->Text   =GetFieldValue("ApnpTerm");
      seApnpCAmt->Text   =GetFieldValue("ApnpCAmt");
      memApnpDesc->Text   =GetFieldValue("ApnpDesc");
      scApnpState->LocateKey(GetFieldValue("ApnpState"));
      scApnpState->Text   =scApnpState->ItemData[0];
      lbApnpUser->Caption  = GetFieldValue("ApnpUser");
      chkApnpCheck->Checked   =(GetFieldValue("ApnpCheck")=="1"?true:false);
      if(chkApnpCheck->Checked)
         SetCheckToolbarStatus(true);
      else
         SetCheckToolbarStatus(false);
      lbApnpChecker->Caption   =GetFieldValue("ApnpChecker");
      lbApnpCheckDate->Caption   =GetFieldValue("ApnpCheckDate");
      lbApnpSysDate->Caption   =GetFieldValue("ApnpSysDate");
}
//---------------------------------------------------------------------------
void __fastcall TfrmApnp::SendDataToComObject()
{
      SetFieldValue("ApnpCode",seApnpCode->Text);
      SetFieldValue("ApnpFmonth",scApnpFmonth->Text);
      SetFieldValue("ApnpDate",deApnpDate->Text);
      SetFieldValue("ApnpCant",scApnpCant->ItemData[1]);
      SetFieldValue("ApnpSupply",scApnpSupply->ItemData[1]);
      SetFieldValue("ApnpCurrency",scApnpCurrency->ItemData[1]);
      SetFieldValue("ApnpEnrate",seApnpEnrate->Text);
      SetFieldValue("ApnpAmt",seApnpAmt->Text);
      SetFieldValue("ApnpUiRate",seApnpUiRate->Text);
      SetFieldValue("ApnpEiRate",seApnpEiRate->Text);
      SetFieldValue("ApnpSdate",deApnpSdate->Text);
      SetFieldValue("ApnpEdate",deApnpEdate->Text);
      SetFieldValue("ApnpTerm",seApnpTerm->Text);
      SetFieldValue("ApnpCAmt",seApnpCAmt->Text);
      SetFieldValue("ApnpDesc",memApnpDesc->Text);
      SetFieldValue("ApnpState",scApnpState->ItemData[1]);
      SetFieldValue("ApnpUser",lbApnpUser->Caption);
      SetFieldValue("ApnpCheck",(chkApnpCheck->Checked==true?"1":"0"));
      SetFieldValue("ApnpChecker",lbApnpChecker->Caption);
}
//---------------------------------------------------------------------------
void __fastcall TfrmApnp::WaitUserInput()
{
      seApnpCode->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmApnp::GetDataToGrid()
{
      AnsiString  s;
      s = "\t" + GetFieldValue("ApnpCode")    +
          "\t" + GetFieldValue("ApnpDate")    +
          "\t" + GetFieldValue("ApnpAmt")     +
          "\t" + GetFieldValue("ApnpCAmt");
      return s;
}
//---------------------------------------------------------------------------
void __fastcall TfrmApnp::RefreshGridData(int mAction)
{
      AnsiString ItemStr;
      ItemStr = GetDataToGrid();
      if (mAction ==  0)   //Add
      {
          sgApnp->AddItem(ItemStr);
      }
      else if(mAction ==  1)   //Modify
      {
          int i   =   sgApnp->Row;
          sgApnp->ChangeItem(ItemStr,i);
      }
      else if(mAction ==  2)      //Delete
      {
          sgApnp->RemoveItem(sgApnp->Row);
      }
}
//---------------------------------------------------------------------------
void __fastcall TfrmApnp::FillGridWithData()
{
      AnsiString ItemStr;
      comServer->MoveFirst();
      sgApnp->RowCount    =   1;
      while (comServer->Eof   ==  0)
      {
         ItemStr =  GetDataToGrid();
         sgApnp->AddItem(ItemStr);
         comServer->MoveNext();
      }
      comServer->MoveFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmApnp::FormShow(TObject *Sender)
{
      FillGridWithData();
      comServer->MoveFirst();
      GetDataFromComObject();

}
//---------------------------------------------------------------------------
void __fastcall TfrmApnp::seApnpCodeKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
      if(Key==13 && CurrentState==caNormal)
      {
       comServer->LocateByKey(WideString(seApnpCode->Text));
       GetDataFromComObject();
      }
}
//---------------------------------------------------------------------------
void __fastcall TfrmApnp::sgApnpClick(TObject *Sender)
{
      if (sgApnp->Row > 0)
          comServer->LocateByKey(WideString(sgApnp->TextMatrix[sgApnp->Row][1]));
      if (!comServer->Eof)
       GetDataFromComObject();

}
//---------------------------------------------------------------------------
void __fastcall TfrmApnp::RefreshUpdateData(int MsgSrc,int MsgType)
{
/*
   switch(MsgSrc)
   {
     case euSdFc:
     if(ShowUpdateMessage(MsgSrc,MsgType))
       FillComboBox(Handle,scApnpFmonth,"SELECT Fcmonth FROM sdFc","Fcmonth");
     break;
     case euSdSupply:
     if(ShowUpdateMessage(MsgSrc,MsgType))
       FillComboBox(Handle,scApnpSupply,"SELECT SupplyCode,SupplyName FROM sdSupply  where supplycancel=0  order by SupplyCode","SupplyName","SupplyCode");
     break;
     case euSdCurrency:
     if(ShowUpdateMessage(MsgSrc,MsgType))
     {
       AnsiString sSql;
       sSql =AnsiString("select currencycode,currencyname,currencyrate=coalesce(rateratio,1),currencylocal from sdcurrency,sdrate");
       sSql+=" where currencycode*=ratecurrency and ";
       sSql+=" ratefmonth='"+g_sdPMonth+"'";
       FillComboBox(Handle,scApnpCurrency,sSql,"CurrencyName","CurrencyCode","currencyrate","currencylocal");
     }
     break;
     case euSdCant:
     if(ShowUpdateMessage(MsgSrc,MsgType))
       FillComboBox(Handle,scApnpCant,"select Cantname,Cantcode from sdCant","Cantname","Cantcode");
     break;
     default:
     break;

   }
*/
}
//---------------------------------------------------------------------------
void __fastcall TfrmApnp::deApnpSdateExit(TObject *Sender)
{
    AnsiString B_Date,E_Date;
    TDateTime  tempDate;
    tempDate=StrToDateTime(deApnpSdate->Text);
    for(int i=1;i<10000;i++)
    {
      tempDate++;
      B_Date=FormatDateTime("yyyy-mm-dd",tempDate);
      if(B_Date==deApnpEdate->Text)
      {
        seApnpTerm->Text=AnsiString(i);
        break;
      }
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmApnp::scApnpCurrencyClick(TObject *Sender)
{
   seApnpEnrate->Text=scApnpCurrency->ItemData[2];
}
//---------------------------------------------------------------------------
bool __fastcall TfrmApnp::BeforeCheck()
{
  SetFieldValue("ApnpCheck",1);
  SetFieldValue("ApnpChecker",g_sdUserCode);
  SetFieldValue("ApnpCheckDate",g_sdCurDate);
  return true;
}
//---------------------------------------------------------------------------
bool __fastcall TfrmApnp::BeforeUnCheck()
{
  SetFieldValue("ApnpCheck",0);
  SetFieldValue("ApnpChecker","");
  SetFieldValue("ApnpCheckDate",NULL);
  return true;
}
//---------------------------------------------------------------------------


void __fastcall TfrmApnp::SupplyCodeButtonButtonClick(TObject *Sender)
{
if(OpenSupplyForm("")==true)
    {
    scApnpSupply->LocateKey(GetSupplyValue(gtOpenForm,"SupplyCode"));
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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