📄 adjinvh.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "AdjInvh.h"
#include "AdjInvd.h"
#include "func.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "DateEdit"
#pragma link "fpanel"
#pragma link "GenBaseForm"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma resource "*.dfm"
TfrmAdjInvh *frmAdjInvh;
//---------------------------------------------------------------------------
__fastcall TfrmAdjInvh::TfrmAdjInvh(TComponent* Owner)
: TGenBaseForm(Owner,euSdAdjInvh,"")
{
AutoCtl=seAdjInvhCode;
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::InitEditControl()
{
ClientGroup->AddComponent(1,false,false,true,FloatPanel1,FloatPanel1->Name);
ClientGroup->AddComponent(1,false,true,false,seAdjInvhCode,seAdjInvhCode->Name);
ClientGroup->AddComponent(1,false,true,true,scAdjInvhType,scAdjInvhType->Name);
ClientGroup->AddComponent(1,true,true,true,scAdjInvhFmonth,scAdjInvhFmonth->Name);
ClientGroup->AddComponent(2,false,false,true,FloatPanel2,FloatPanel2->Name);
ClientGroup->AddComponent(2,true,true,true,scAdjInvdUnit,scAdjInvdUnit->Name);
ClientGroup->AddComponent(2,true,true,true,scAdjInvdState,scAdjInvdState->Name);
ClientGroup->AddComponent(2,false,true,true,btnOK,btnOK->Name);
ClientGroup->AddComponent(2,false,false,false,btnCancel,btnCancel->Name);
//AdjInvh
FillComboBox(scAdjInvhFmonth,"SELECT Fcmonth FROM sdFc order by fcmonth","Fcmonth");
scAdjInvhType->ClearAll();
scAdjInvhType->AddItems("1-据盘点单调整","1");
scAdjInvhType->AddItems("2-直接调整","2");
//AdjInvd
FillComboBox(scAdjInvdUnit,"select unitname memo,unitcode from sdunit order by unitcode","memo","UnitCode");
FillEdit(seAdjInvdLoc,"select locname memo,loccode from sdloc where LocType=1 order by loccode","memo","LocCode");
scAdjInvdState->ClearAll();
scAdjInvdState->AddItems("1-手工","1");
scAdjInvdState->AddItems("2-生成","2");
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::ClearControl(int Section,bool BringToNext)
{
if (Section == 1)
{
if (! BringToNext)
{
seAdjInvhCode->Text ="";
scAdjInvhType->ItemIndex =0;
deAdjInvhDate->Text =g_sdCurDate;
scAdjInvhFmonth->Text =g_sdIMonth;
chkAdjInvhCheck->Checked =false;
labAdjInvhChecker->Caption ="";
labAdjInvhUser->Caption =g_sdUserCode;
labAdjInvhSysDate->Caption="";
memAdjInvhDesc->Text="";
//新增单据,工具栏使能
SetCheckToolbarStatus(false);
}
sgAdjInvh->RowCount=1;
}
else if (Section==2)
{
if (!BringToNext)
{
seAdjInvdLine->Text =AnsiString(comServer->ItemCount+1);
seAdjInvdTsCode->Text="";
seAdjInvdTsdLine->Text="";
seAdjInvdLoc->ItemIndex =-1;
seAdjInvdLoc->Text="";
seAdjInvdGoods->Text="";
labAdjInvdGoodsName->Caption ="";
scAdjInvdUnit->ItemIndex =-1;
scAdjInvdUnit->Text="";
seAdjInvdQty->Text="0";
scAdjInvdState->ItemIndex=0;
memAdjInvdDesc->Text="";
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::GetDataFromComObject(int Section)
{
if (Section==1)
{
seAdjInvhCode->Text=GetHeadValue(fiAdjInvhCode);
scAdjInvhType->LocateKey(GetHeadValue(fiAdjInvhType));
scAdjInvhType->Text=scAdjInvhType->ItemData[0];
deAdjInvhDate->Text=GetHeadValue(fiAdjInvhDate);
scAdjInvhFmonth->Text=GetHeadValue(fiAdjInvhFmonth);
labAdjInvhUser->Caption=GetHeadValue(fiAdjInvhUser);
chkAdjInvhCheck->Checked=GetHeadValue(fiAdjInvhCheck)=="1";
labAdjInvhChecker->Caption=GetHeadValue(fiAdjInvhChecker);
labAdjInvhSysDate->Caption=GetHeadValue(fiAdjInvhSysDate);
memAdjInvhDesc->Text=GetHeadValue(fiAdjInvhDesc);
//根据审核、取消状态,设置工具栏
if(GetHeadValue(fiAdjInvhCheck)=="1")
SetCheckToolbarStatus(true);
else
SetCheckToolbarStatus(false);
}
else
{
seAdjInvdLine->Text=GetDetailValue(fiAdjInvdLine);
seAdjInvdTsCode->Text=GetDetailValue(fiAdjInvdTsCode);
seAdjInvdTsdLine->Text=GetDetailValue(fiAdjInvdTsdLine);
seAdjInvdLoc->LocateKey(GetDetailValue(fiAdjInvdLoc));
seAdjInvdLoc->Text=seAdjInvdLoc->ItemData[0];
g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiAdjInvdGoods)));
seAdjInvdGoods->Text = GetGoodsValue("GoodsCode");
labAdjInvdGoodsName->Caption=GetGoodsValue("GoodsName");
scAdjInvdUnit->LocateKey(GetDetailValue(fiAdjInvdUnit));
scAdjInvdUnit->Text=scAdjInvdUnit->ItemData[0];
seAdjInvdQty->Text=GetDetailValue(fiAdjInvdQty);
scAdjInvdState->LocateKey(GetDetailValue(fiAdjInvdState));
scAdjInvdState->Text=scAdjInvdState->ItemData[0];
memAdjInvdDesc->Text=GetDetailValue(fiAdjInvdDesc);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::SendDataToComObject(int Section)
{
if (Section==1)
{
SetHeadValue(fiAdjInvhCode,seAdjInvhCode->Text);
if(scAdjInvhType->ItemData[1] == "")
throw Exception("请选择调整类型");
SetHeadValue(fiAdjInvhType,scAdjInvhType->ItemData[1]);
SetHeadValue(fiAdjInvhDate,deAdjInvhDate->Text);
SetHeadValue(fiAdjInvhFmonth,scAdjInvhFmonth->Text);
SetHeadValue(fiAdjInvhUser,labAdjInvhUser->Caption);
SetHeadValue(fiAdjInvhDesc,memAdjInvhDesc->Text);
}
else
{
SetDetailValue(fiAdjInvdCode,seAdjInvhCode->Text);
if(seAdjInvdLine->Text == "")
throw Exception("请输入调整单行号");
SetDetailValue(fiAdjInvdLine,seAdjInvdLine->Text);
SetDetailValue(fiAdjInvdTsCode,seAdjInvdTsCode->Text);
if(seAdjInvdTsdLine->Text=="")
SetDetailValue(fiAdjInvdTsdLine,"0");
else
SetDetailValue(fiAdjInvdTsdLine,seAdjInvdTsdLine->Text);
SetDetailValue(fiAdjInvdLoc,seAdjInvdLoc->ItemData[1]);
SetDetailValue(fiAdjInvdGoods,seAdjInvdGoods->Text);
SetDetailValue(fiAdjInvdUnit,scAdjInvdUnit->ItemData[1]);
if(seAdjInvdQty->Text == "")
throw Exception("请输入调整数量");
SetDetailValue(fiAdjInvdQty,seAdjInvdQty->Text);
SetDetailValue(fiAdjInvdState,scAdjInvdState->ItemData[1]);
SetDetailValue(fiAdjInvdDesc,memAdjInvdDesc->Text);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::WaitUserInput(int Section)
{
if (Section ==1)
{
if(seAdjInvhCode->Enabled)
seAdjInvhCode->SetFocus();
}
else
{
ChangeToBrowseState(false);
if(scAdjInvhType->ItemData[1] == "1") //据盘点单调整
{
seAdjInvdTsCode->Enabled=true;
seAdjInvdLoc->Enabled=false;
seAdjInvdGoods->Enabled=false;
}
else
{
seAdjInvdTsCode->Enabled=false;
seAdjInvdLoc->Enabled=true;
seAdjInvdGoods->Enabled=true;
}
if(seAdjInvdTsCode->Enabled)
seAdjInvdTsCode->SetFocus();
else
seAdjInvdLoc->SetFocus();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::RefreshGridData(int mAction)
{
int i;
AnsiString ItemStr=GetItemStringToGrid();
switch(mAction)
{
case 0:
sgAdjInvh->AddItem(ItemStr);
break;
case 1:
i=sgAdjInvh->Row;
sgAdjInvh->ChangeItem(ItemStr,i);
break;
case 2:
sgAdjInvh->RemoveItem(sgAdjInvh->Row);
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmAdjInvh::GetItemStringToGrid()
{
AnsiString s_ItemStr;
g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiAdjInvdGoods)));
s_ItemStr="\t"+GetDetailValue(fiAdjInvdLine)+
"\t"+GetDetailValue(fiAdjInvdTsCode)+
"\t"+GetDetailValue(fiAdjInvdTsdLine)+
"\t"+GetDetailValue(fiAdjInvdLoc)+
"\t"+GetDetailValue(fiAdjInvdGoods)+
"\t"+GetGoodsValue("GoodsName")+
"\t"+GetDetailValue(fiAdjInvdQty);
return(s_ItemStr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::DisplayBill()
{
if(comServer->RecordCount == 0)
return ;
GetDataFromComObject(1);
FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::GetBill(AnsiString BillID)
{
int iRow;
iRow=comServer->Find("AdjInvhCode='"+BillID+"'");
if (iRow>0) //FIND THIS BILL
{
DisplayBill();
}
else
if (ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
{
AddHeadRecord();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::FillGridWithData()
{
int i;
AnsiString ItemStr;
sgAdjInvh->RowCount=1;
for (i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
RefreshGridData(0);
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmAdjInvh::GetHeadValue(int Index)
{
AnsiString S;
S = ReadFieldValue(comServer,Index);
return S;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmAdjInvh::GetDetailValue(int Index)
{
AnsiString S;
S = ReadItemValue(comServer,Index);
return S;
}
//---------------------------------------------------------------------------
void __fastcall TfrmAdjInvh::SetHeadValue(int Index,AnsiString Value)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -