adjcoh.cpp
来自「一个以前收集的基于C/S架构的ERP客户端源代码」· C++ 代码 · 共 447 行 · 第 1/2 页
CPP
447 行
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "AdjCoh.h"
#include "WnQuery.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "BillBaseForm"
#pragma link "DateEdit"
#pragma link "fpanel"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "KSAdvReport"
#pragma resource "*.dfm"
TfrmAdjCoh *frmAdjCoh;
//---------------------------------------------------------------------------
__fastcall TfrmAdjCoh::TfrmAdjCoh(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TBillBaseForm(Owner,chWnd,MidCode,WhereStr)
{
SetAutoCodeString(seAdjCohCode,"Acm-017");
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjCoh::InitEditControl()
{
ClientGroup->AddComponent(1,false,false,true,fpAdjCohHead,fpAdjCohHead->Name);
ClientGroup->AddComponent(2,false,false,true,fpAdjCohDetail,fpAdjCohDetail->Name);
ClientGroup->AddComponent(2,false,false,false,btnCancel,btnCancel->Name);
ClientGroup->AddComponent(2,false,true,true,btnOK,btnOK->Name);
ClientGroup->AddComponent(2,true,true,true,scAdjCodGoodsUnit,scAdjCodGoodsUnit->Name);
ClientGroup->AddComponent(1,false,true,false,seAdjCohCode,seAdjCohCode->Name);
ClientGroup->AddComponent(1,true,true,true,scAdjCohFmonth,scAdjCohFmonth->Name);
// ClientGroup->AddComponent(1,true,true,true,scAdjCohKeeper,scAdjCohKeeper->Name);
//h
FillComboBox(Query,scAdjCohFmonth,"SELECT Fcmonth FROM sdFc","Fcmonth");
FillComboBox(Query,scAdjCohPosType,"select postypename,postypecode from sdpostype where POSTYPEFLG=6 ","postypename","postypecode");
// FillComboBox(Query,scAdjCohKeeper,"select username,keepercode from sdkeeper ,sduser where keepercode=usercode","username","KeeperCode");
//d
FillComboBox(Query,scAdjCodBatch,"SELECT BatchCode FROM sdBatch","BatchCode");
FillComboBox(Query,scAdjCodGoodsUnit,"select Unitname,unitcode from sdunit","unitname","unitcode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjCoh::ClearControl(int Section,bool BringToNext)
{
if (Section == 1)
{
if (!BringToNext)
{
seAdjCohCode->Text ="";
deAdjCohDate->Text =g_sdCurDate;
scAdjCohFmonth->Text =g_sdCMonth;
seAdjCohDesc->Text ="";
chkAdjCohPost->Checked =false;
labAdjCohPoster->Caption ="";
scAdjCohPosType->ItemIndex =-1;
scAdjCohPosType->Text ="";
labAdjCohSysDate->Caption ="";
// scAdjCohKeeper->LocateKey(g_sdUserCode);
scAdjCohKeeper->Text=g_sdUserCode;
// scAdjCohKeeper->Text =scAdjCohKeeper->ItemData[0];
chkAdjCohCheck->Checked =false;
labAdjCohChecker->Caption ="";
labAdjCohUser->Caption =g_sdUserCode;
}
sgAdjCoh->RowCount=1;
}
else if (Section==2)
{
if (!BringToNext)
{
seAdjCodLine->Text =AnsiString(comServer->ItemCount+1);
seAdjCodGoods->Text ="";
seAdjCodAmt->Text ="";
scAdjCodBatch->Text ="";
memAdjCodDesc->Text ="";
seAdjCodGoodsName->Text ="";
scAdjCodGoodsUnit->Text ="";
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjCoh::GetDataFromComObject(int Section)
{
AnsiString s;
if (Section==1)
{
seAdjCohCode->Text = GetHeadValue("AdjCohCode");
deAdjCohDate->Text = GetHeadValue("AdjCohDate");
scAdjCohFmonth->Text = GetHeadValue("AdjCohFmonth");
seAdjCohDesc->Text = GetHeadValue("AdjCohDesc");
scAdjCohPosType->LocateKey(GetHeadValue("AdjCohPosType"));
scAdjCohPosType->Text =scAdjCohPosType->ItemData[0];
labAdjCohSysDate->Caption = GetHeadValue("AdjCohSysDate");
// scAdjCohKeeper->LocateKey(GetHeadValue("AdjCohKeeper"));
// scAdjCohKeeper->Text =scAdjCohKeeper->ItemData[0];
scAdjCohKeeper->Text=GetHeadValue("AdjCohKeeper");
if(GetHeadValue("AdjCohPost")=="1")
chkAdjCohPost->Checked =true;
else
chkAdjCohPost->Checked =false;
labAdjCohPoster->Caption=(GetHeadValue("AdjCohPoster"));
chkAdjCohCheck->Checked=(GetHeadValue("AdjCohCheck")==1)?true:false;
if(chkAdjCohCheck->Checked)
SetCheckToolbarStatus(true);
else
SetCheckToolbarStatus(false);
labAdjCohChecker->Caption = GetHeadValue("AdjCohChecker");
labAdjCohUser->Caption =GetHeadValue("AdjCohUser");
}
else
{
seAdjCodLine->Text = GetDetailValue("AdjCodLine");
seAdjCodGoods->Text=GetDetailValue("AdjCodCode"); /////
if(InitRsGoods(WideString(Trim(seAdjCodGoods->Text)))) //输入无效编码
{
seAdjCodGoodsName->Text=GetGoodsValue(gtInitRs,"GoodsName"); /////
scAdjCodGoodsUnit->LocateKey(GetGoodsValue(gtInitRs,"GoodsUnitCode"));/////
}
else
{
seAdjCodGoodsName->Text="";
scAdjCodGoodsUnit->Text="";
}
scAdjCodGoodsUnit->Text=scAdjCodGoodsUnit->ItemData[0];
scAdjCodBatch->Text =GetDetailValue("AdjCodBatch");
seAdjCodAmt->Text = GetDetailValue("AdjCodAmt");
memAdjCodDesc->Text = GetDetailValue("AdjCodDesc");
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjCoh::SendDataToComObject(int Section)
{
if (Section==1) // Head
{
SetHeadValue("AdjCohCode",seAdjCohCode->Text);
SetHeadValue("AdjCohDate",deAdjCohDate->Text);
SetHeadValue("AdjCohFmonth",scAdjCohFmonth->Text);
SetHeadValue("AdjCohDesc",seAdjCohDesc->Text);
SetHeadValue("AdjCohPosType",scAdjCohPosType->ItemData[1]);
// SetHeadValue("AdjCohKeeper",scAdjCohKeeper->ItemData[1]);
SetHeadValue("AdjCohKeeper",scAdjCohKeeper->Text);
SetHeadValue("AdjCohUser",labAdjCohUser->Caption);
SetHeadValue("AdjCohCheck",chkAdjCohCheck->Checked?"1":"0");
SetHeadValue("AdjCohChecker",labAdjCohChecker->Caption);
}
else
{
SetDetailValue("AdjCodCode",seAdjCohCode->Text);
SetDetailValue("AdjCodLine",seAdjCodLine->Text);
SetDetailValue("AdjCodGoods",seAdjCodGoods->Text);
SetDetailValue("AdjCodBatch",scAdjCodBatch->Text);
SetDetailValue("AdjCodAmt",seAdjCodAmt->Text);
SetDetailValue("AdjCodDesc",memAdjCodDesc->Text);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjCoh::WaitUserInput(int Section)
{
if (Section ==1)
{
seAdjCohDesc->SetFocus();
}
else
{
sgAdjCoh->Visible=false;
fpAdjCohDetail->Visible=true;
seAdjCodLine->SetFocus();
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmAdjCoh::GetDataToGrid()
{
AnsiString ItemStr;
ItemStr="\t"+GetDetailValue("AdjCodLine")+
"\t"+GetDetailValue("AdjCodGoods")+
"\t"+GetDetailValue("AdjCodBatch")+
"\t"+GetDetailValue("AdjCodAmt");
return ItemStr;
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjCoh::RefreshGridData(int mAction)
{
int i;
AnsiString ItemStr;
switch(mAction)
{
case 0: // Append
ItemStr=GetDataToGrid();
sgAdjCoh->AddItem(ItemStr);
break;
case 1: // Modify
sgAdjCoh->ChangeItem(ItemStr,sgAdjCoh->Row);
break;
case 2: // Delete
sgAdjCoh->RemoveItem(sgAdjCoh->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjCoh::FillGridWithData()
{
int i;
AnsiString ItemStr;
sgAdjCoh->RowCount=1;
if(comServer->RecordCount > 0)
for (i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
RefreshGridData(0); // Append
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?