npin.cpp

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

CPP
243
字号
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Npin.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "RecBaseForm"
#pragma link "DateEdit"
#pragma link "fpanel"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmNpin *frmNpin;
//---------------------------------------------------------------------------
__fastcall TfrmNpin::TfrmNpin(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
        : TRecBaseForm(Owner,chWnd,MidCode,WhereStr)
{ SetAutoCodeString(seNpinCode,"Acm-78");
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TfrmNpin::ClearControl(bool BringToNext)
{
    if(!BringToNext)
    {
      seNpinCode->Text     ="";  //票据号
      deNpinDate->Text     =g_sdCurDate;  //日期
      scNpinFmonth->Text=g_sdFMonth;;  //月份
      scNpinSupply->ItemIndex =-1;  //退票方
      seNpinAmt->Text   ="";  //金额
      seNpinInr->Text   ="";  //利息
      seNpinExp->Text   ="";  //费用
      scNpinExpense->ItemIndex =-1;  //费用类型
      memNpinDesc->Text   ="";  //备注
      scNpinReason->ItemIndex =-1;  //退回原因
//      scNpinUser->LocateKey(g_sdUserCode);
//      scNpinUser->Text    =scNpinUser->ItemData[0];  //操作员
      scNpinUser->Text    =g_sdUserCode;  //操作员

    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmNpin::InitEditControl()
{
    ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
    ClientGroup->AddComponent(2,true,true,false, sgNpin,sgNpin->Name);
    ClientGroup->AddComponent(2,false,false,false, seNpinCode,seNpinCode->Name);
    ClientGroup->AddComponent(2,true,true,true, scNpinFmonth,scNpinFmonth->Name);
    ClientGroup->AddComponent(2,true,true,true, seNpinAmt,seNpinAmt->Name);

    FillComboBox(Handle,scNpinExpense,"SELECT Expensename,Expensecode FROM sdExpense order by Expensecode","ExpenseName","ExpenseCOde");
//    FillComboBox(Handle,scNpinUser,"select username,Usercode from sduser","Username","Usercode");
    FillComboBox(Handle,scNpinReason,"select INRDESC,Inrcode from sdInr","Inrdesc","Inrcode");
    FillComboBox(Handle,scNpinFmonth,"SELECT Fcmonth FROM sdFc","Fcmonth");
    FillComboBox(Handle,scNpinSupply,"SELECT SupplyCode,SupplyName FROM sdSupply  where supplycancel=0  order by SupplyCode","SupplyName","SupplyCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmNpin::GetDataFromComObject()
{
      seNpinCode->Text  =GetFieldValue("NpinCode");
      sgNpin->LocateGrid(1,seNpinCode->Text);
      deNpinDate->Text   =GetFieldValue("NpinDate");
      scNpinFmonth->Text  =GetFieldValue("NpinFmonth");
      scNpinSupply->LocateKey(GetFieldValue("NpinSupply"));
      scNpinSupply->Text  = scNpinSupply->ItemData[0];
      seNpinAmt->Text   =GetFieldValue("NpinAmt");
      seNpinInr->Text   =GetFieldValue("NpinInr");
      seNpinExp->Text   =GetFieldValue("NpinExp");
      scNpinExpense->LocateKey(GetFieldValue("NpinExpense"));
      scNpinExpense->Text  = scNpinExpense->ItemData[0];
      memNpinDesc->Text   =GetFieldValue("NpinDesc");
      scNpinReason->LocateKey(GetFieldValue("NpinReason"));
      scNpinReason->Text  = scNpinReason->ItemData[0];
//      scNpinUser->LocateKey(GetFieldValue("NpinUser"));
//      scNpinUser->Text  = scNpinUser->ItemData[0];
      scNpinUser->Text  =GetFieldValue("NpinUser");
}
//---------------------------------------------------------------------------
void __fastcall TfrmNpin::SendDataToComObject()
{
      SetFieldValue("NpinCode",seNpinCode->Text);
      SetFieldValue("NpinDate",deNpinDate->Text);
      SetFieldValue("NpinFmonth",scNpinFmonth->Text);
      SetFieldValue("NpinSupply",scNpinSupply->ItemData[1]);
      SetFieldValue("NpinAmt",seNpinAmt->Text);
      SetFieldValue("NpinInr",seNpinInr->Text);
      SetFieldValue("NpinExp",seNpinExp->Text);
      SetFieldValue("NpinExpense",scNpinExpense->ItemData[1]);
      SetFieldValue("NpinDesc",memNpinDesc->Text);
      SetFieldValue("NpinReason",scNpinReason->ItemData[1]);
//      SetFieldValue("NpinUser",scNpinUser->ItemData[1]);
      SetFieldValue("NpinUser",scNpinUser->Text);
}
//---------------------------------------------------------------------------
void __fastcall TfrmNpin::WaitUserInput()
{
      seNpinCode->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmNpin::GetDataToGrid()
{
      AnsiString  s;
      s = "\t" + GetFieldValue("NpinCode")    +
          "\t" + GetFieldValue("NpinDate")    +
          "\t" + GetFieldValue("NpinAmt")    +
          "\t" + GetFieldValue("NpinExp")    ;
      return s;
}
//---------------------------------------------------------------------------
void __fastcall TfrmNpin::RefreshGridData(int mAction)
{
      AnsiString ItemStr;
      ItemStr = GetDataToGrid();
      if (mAction ==  0)   //Add
      {
          sgNpin->AddItem(ItemStr);
      }
      else if(mAction ==  1)   //Modify
      {
          int i   =   sgNpin->Row;
          sgNpin->ChangeItem(ItemStr,i);
      }
      else if(mAction ==  2)      //Delete
      {
          sgNpin->RemoveItem(sgNpin->Row);
      }
}
//---------------------------------------------------------------------------
void __fastcall TfrmNpin::FillGridWithData()
{
      AnsiString ItemStr;
      comServer->MoveFirst();
      sgNpin->RowCount    =   1;
      while (comServer->Eof   ==  0)
      {
         ItemStr =  GetDataToGrid();
         sgNpin->AddItem(ItemStr);
         comServer->MoveNext();
      }
      comServer->MoveFirst();
}
//---------------------------------------------------------------------------
void __fastcall TfrmNpin::FormShow(TObject *Sender)
{
      FillGridWithData();
      comServer->MoveFirst();
      GetDataFromComObject();

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

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

}
//---------------------------------------------------------------------------
void __fastcall TfrmNpin::RefreshUpdateData(int MsgSrc,int MsgType)
{
/*
   switch(MsgSrc)
   {
     case euSdSupply:
     if(ShowUpdateMessage(MsgSrc,MsgType))
        FillComboBox(Handle,scNpinSupply,"SELECT SupplyCode,SupplyName FROM sdSupply  where supplycancel=0  order by SupplyCode","SupplyName","SupplyCode");
     break;
     case euSdFc:
     if(ShowUpdateMessage(MsgSrc,MsgType))
        FillComboBox(Handle,scNpinFmonth,"SELECT Fcmonth FROM sdFc","Fcmonth");
     break;
     case euSdInr:
     if(ShowUpdateMessage(MsgSrc,MsgType))
        FillComboBox(Handle,scNpinReason,"select INRDESC,Inrcode from sdInr","Inrdesc","Inrcode");
     break;
     case euSdUser:
     if(ShowUpdateMessage(MsgSrc,MsgType))
        FillComboBox(Handle,scNpinUser,"select username,Usercode from sduser","Username","Usercode");
     break;
     case euSdExpense:
     if(ShowUpdateMessage(MsgSrc,MsgType))
        FillComboBox(Handle,scNpinExpense,"SELECT Expensename,Expensecode FROM sdExpense order by Expensecode","ExpenseName","ExpenseCOde");
     break;
     default:
     break;

   }
*/
}
//---------------------------------------------------------------------------

void __fastcall TfrmNpin::seNpinCodeButtonClick(TObject *Sender)
{
    AnsiString SqlStr;
    TfrmWnQuery *p;
    try
    {
        StartWaitForm("正在查询,请稍候...");
         SqlStr="005[应付票据号][金额][供应商][未到期利率][到期利率]";
         SqlStr+=" select ApnpCode,ApnpAmt,ApnpSupply,ApnpEiRate,ApnpUiRate from sdApnp ";
         SqlStr+=" where ApnpState=2 and ApnpCheck=1  order by Apnpcode";
         p=new TfrmWnQuery(this,"应付票据查询",SqlStr);
         
     }
     __finally
     {
       EndWaitForm();
     }
     if(p->ShowModal()==mrOk)
     {
      seNpinCode->Text=p->ColData[1];
      seNpinAmt->Text=p->ColData[2];
      scNpinSupply->LocateKey(p->ColData[3]);
      scNpinSupply->Text=scNpinSupply->ItemData[0];
     }
     delete p;
}
//---------------------------------------------------------------------------

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

⌨️ 快捷键说明

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