btht.cpp

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

CPP
272
字号
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Btht.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "RecBaseForm"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmBtht *frmBtht;
//---------------------------------------------------------------------------
__fastcall TfrmBtht::TfrmBtht(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
    : TRecBaseForm(Owner,chWnd,MidCode,WhereStr)
{

}
//---------------------------------------------------------------------------
__fastcall TfrmBtht::TfrmBtht(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr,AnsiString LocCode,AnsiString GoodsCode)
    : TRecBaseForm(Owner,chWnd,MidCode,WhereStr)
{
    ClearControl(false);
    FLocCode=LocCode;
    FGoodsCode=GoodsCode;
    sgBtht->RowCount=1;
    LabCurFmonth->Caption=g_sdIMonth;
    LabBthtGoods->Caption=FGoodsCode;
    if(g_sdRsGoods->LocateByKey(WideString(FGoodsCode))==0)
       LabBthtGoodsName->Caption=GetGoodsValue(gtInitRs,"GoodsName");
    scBthtLoc->LocateKey(FLocCode);
    AnsiString FilStr="BthtFmonth='"+g_sdIMonth+"' and BthtGoods='"+FGoodsCode+"' and BthtLoc='"+FLocCode+"'";
    comServer->FilterString=WideString(FilStr);
    comServer->Query();    
    if(comServer->RecordCount>0)
    {
       FillGridWithData();
       comServer->MoveFirst();
       GetDataFromComObject();
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::ClearControl(bool BringToNext)
{
    if(!BringToNext)
    {
       scBthtBatch->ItemIndex = -1;
       seBthtBoyQty->Text   = "0";
       seBthtBopQty->Text   = "0";
       seBthtIopQty->Text   = "0";
       seBthtOopQty->Text   = "0";
       seBthtIoyQty->Text   = "0";
       seBthtOoyQty->Text   = "0";
       seBthtAoyQty->Text   = "0";
       cheBthtClose->Checked=false;
       cheBthtInit->Checked=false;
    }
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::GetDataFromComObject()
{
//    scBthtLoc->LocateKey(GetFieldValue("BthtLoc"));
    scBthtBatch->LocateKey(GetFieldValue("BthtBatch"));
    seBthtBoyQty->Text   = GetFieldValue("BthtBoyQty");
    seBthtBopQty->Text   = GetFieldValue("BthtBopQty");
    seBthtIopQty->Text   = GetFieldValue("BthtIopQty");
    seBthtOopQty->Text   = GetFieldValue("BthtOopQty");
    seBthtIoyQty->Text   = GetFieldValue("BthtIoyQty");
    seBthtOoyQty->Text   = GetFieldValue("BthtOoyQty");
    seBthtAoyQty->Text   = GetFieldValue("BthtAoyQty");
    cheBthtInit->Checked=GetFieldValue("BthtInit")=="1";
    if(cheBthtInit->Checked)
    {
      tbEditHead->Enabled=false;
      tbDeleteHead->Enabled=false;
    }
    else
    {
      tbEditHead->Enabled=true;
      tbDeleteHead->Enabled=true;
    }
    cheBthtClose->Checked=GetFieldValue("BthtClose")=="1";

}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::SendDataToComObject()
{
    SetFieldValue("BthtFmonth",g_sdIMonth);
    SetFieldValue("BthtGoods",FGoodsCode);
    SetFieldValue("BthtLoc",FLocCode);
    SetFieldValue("BthtBatch",scBthtBatch->ItemData[1]);
    SetFieldValue("BthtBoyQty",seBthtBoyQty->Text);
    SetFieldValue("BthtBopQty",seBthtBopQty->Text);
    SetFieldValue("BthtIoyQty",seBthtIoyQty->Text);
    SetFieldValue("BthtOopQty",seBthtOopQty->Text);
    SetFieldValue("BthtInit",cheBthtInit->Checked?"1":"0");
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::WaitUserInput()
{
    scBthtBatch->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmBtht::GetDataToGrid()
{
    AnsiString  tempS;
    tempS = GetFieldValue("BthtBatch")+
            "\t" + GetFieldValue("BthtBoyQty")+
            "\t" + GetFieldValue("BthtBopQty");
    return(tempS);
}
//---------------------------------------------------------------------------

void __fastcall TfrmBtht::RefreshGridData(int mAction)
{
    AnsiString ItemStr;
    ItemStr = GetDataToGrid();
    GetDataFromComObject();
    if(mAction == 0)
    {
        sgBtht->AddItem(ItemStr);
        sgBtht->Row=sgBtht->RowCount-1;
    }
    else if(mAction == 1)
    {
        sgBtht->ChangeItem(ItemStr,sgBtht->Row);
    }
    else if(mAction == 2)
    {
        sgBtht->RemoveItem(sgBtht->Row);
    }
}
//---------------------------------------------------------------------------

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

void __fastcall TfrmBtht::InitEditControl()
{
    ClientGroup->AddComponent(2,false,false,true,fpBtht,fpBtht->Name);
    ClientGroup->AddComponent(2,true,true,true,fpBtht1,fpBtht1->Name);
    ClientGroup->AddComponent(2,true,true,true, scBthtLoc,scBthtLoc->Name);
    ClientGroup->AddComponent(2,true,true,true, seBthtIopQty,seBthtIopQty->Name);
    ClientGroup->AddComponent(2,true,true,true, seBthtOopQty,seBthtOopQty->Name);
    ClientGroup->AddComponent(2,true,true,true, seBthtAoyQty,seBthtAoyQty->Name);
    ClientGroup->AddComponent(2,true,true,true, cheBthtClose,cheBthtClose->Name);
    ClientGroup->AddComponent(2,false,false,true, cheBthtInit,cheBthtInit->Name);
    ClientGroup->AddComponent(2,true,true,false, sgBtht,sgBtht->Name);
    FillComboBox(Handle,scBthtLoc,"select LocCode,memo=LocCode+space(1)+LocName from sdLoc where LocType=1 order by LocCode","memo","LocCode");
    FillComboBox(Handle,scBthtBatch,"select BatchCode,memo=BatchCode+space(1)+BatchDesc from sdBatch order by BatchCode","memo","BatchCode");
}
//---------------------------------------------------------------------------

void __fastcall TfrmBtht::RefreshUpdateData(int MsgSrc,int MsgType)
{
/*
    try
    {
       switch (MsgSrc)
       {
         case euSdLoc:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillComboBox(Handle,scBthtLoc,"select LocCode,memo=LocCode+space(1)+LocName from sdLoc where LocType=1 order by LocCode","memo","LocCode");
	           EndWaitForm();
	           break;
           }
         case euSdBatch:
           if(ShowUpdateMessage(MsgSrc,MsgType)){
	           StartWaitForm("正在刷新引用数据!");
               FillComboBox(Handle,scBthtBatch,"select BatchCode,memo=BatchCode+space(1)+BatchDesc from sdBatch order by BatchCode","memo","BatchCode");
	           EndWaitForm();
	           break;
           }
         default:
           break;
       }
    }
    __finally
    {
       //AddCode;
    }
*/    
}
//---------------------------------------------------------

void __fastcall TfrmBtht::FormClose(TObject *Sender, TCloseAction &Action)
{
    TRecBaseForm::FormClose(Sender,Action);
/*
    AnsiString FormIniFile = "D:\Test.Ini";
    WriteGridWidth(Name,sgPg,FormIniFile);
*/
}
//---------------------------------------------------------------------------
void __fastcall TfrmBtht::FormCreate(TObject *Sender)
{
/*
    AnsiString FormIniFile="D:\Test.Ini";
    SetGridWidth(Name,sgPg,FormIniFile);
*/
}
//---------------------------------------------------------------------------

void __fastcall TfrmBtht::sgBthtClick(TObject *Sender)
{
    int ARow;
    ARow=sgBtht->Row;
    if(ARow > 0)
    {
       AnsiString KeyStr=sgBtht->Cells[0][ARow]+LabCurFmonth->Caption
                        +FLocCode+LabBthtGoods->Caption;
       comServer->LocateByKey(WideString(KeyStr));
    }
    if(!comServer->Eof)
       GetDataFromComObject();
}
//---------------------------------------------------------------------------

void __fastcall TfrmBtht::muFirstClick(TObject *Sender)
{
    if(sgBtht->RowCount > 1)
    {
       sgBtht->Row=1;
       sgBthtClick(NULL);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmBtht::muPreviousClick(TObject *Sender)
{
    if(sgBtht->RowCount > 1 && sgBtht->Row > 1)
    {
       sgBtht->Row=sgBtht->Row-1;
       sgBthtClick(NULL);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmBtht::muNextClick(TObject *Sender)
{
    if(sgBtht->RowCount > 1 && sgBtht->Row < sgBtht->RowCount-1)
    {
       sgBtht->Row=sgBtht->Row+1;
       sgBthtClick(NULL);
    }
}
//---------------------------------------------------------------------------

void __fastcall TfrmBtht::muLastClick(TObject *Sender)
{
    if(sgBtht->RowCount > 1)
    {
      sgBtht->Row=sgBtht->RowCount-1;
      sgBthtClick(NULL);
    }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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