📄 alfh.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "Alfh.h"
//---------------------------------------------------------------------------
#pragma hdrstop
#pragma package(smart_init)
#pragma link "BillBaseForm"
#pragma link "fpanel"
#pragma link "SDGrid"
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma link "SDEdit"
#pragma resource "*.dfm"
TfrmAlfh *frmAlfh;
//---------------------------------------------------------------------------
__fastcall TfrmAlfh::TfrmAlfh(TComponent* Owner)
: TBillBaseForm(Owner,euSdAlfh,"")
{
AutoCtl=seAlfhCode;
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::InitEditControl()
{
ClientGroup->AddComponent(1,false,false,true,FloatPanel1,FloatPanel1->Name);
//调拨单号不允许修改
ClientGroup->AddComponent(1,false,true,false,seAlfhCode,seAlfhCode->Name);
ClientGroup->AddComponent(1,true,true,true,scAlfhInvFlg,scAlfhInvFlg->Name);
ClientGroup->AddComponent(1,true,true,true,scAlfhFmonth,scAlfhFmonth->Name);
ClientGroup->AddComponent(1,false,true,true,scAlfhIDept,scAlfhIDept->Name);
ClientGroup->AddComponent(1,false,true,true,scAlfhODept,scAlfhODept->Name);
ClientGroup->AddComponent(2,false,false,true,FloatPanel2,FloatPanel2->Name);
ClientGroup->AddComponent(2,true,true,true,seAlfdConv,seAlfdConv->Name);
ClientGroup->AddComponent(2,true,true,true,scAlfdUnit,scAlfdUnit->Name);
ClientGroup->AddComponent(2,false,true,true,seAlfdLine,seAlfdLine->Name);
ClientGroup->AddComponent(2,false,true,true,seAlfdGoods,seAlfdGoods->Name);
ClientGroup->AddComponent(2,false,true,true,scAlfdILoc,scAlfdILoc->Name);
ClientGroup->AddComponent(2,false,true,true,scAlfdOLoc,scAlfdOLoc->Name);
ClientGroup->AddComponent(2,false,false,false,btnCancel,btnCancel->Name);
ClientGroup->AddComponent(2,false,true,true,btnOk,btnOk->Name);
//Alfh
FillComboBox(scAlfhFmonth,"Select FcMonth from sdFc order by fcmonth","FcMonth");
FillComboBox(scAlfhODept,"select DeptName memo,DeptCode from sdDept where DeptEnd=1 order by deptcode","memo","DeptCode");
FillComboBox(scAlfhPosType,"select postypename memo,postypecode from sdPosType where PosTypeFlg=6 order by PosTypeCode","memo","PosTypeCode");
FillComboBox(scAlfhIDept,"select DeptName memo,DeptCode from sdDept where DeptEnd=1 order by DeptCode","memo","DeptCode");
FillComboBox(scAlfhKeeper,"select UserCode,UserName from sdKeeper,sduser where UserCode=KeeperCode order by UserCode","UserName","UserCode");
scAlfhType->ClearAll();
scAlfhType->AddItems("1-库存调拨","1");
scAlfhInvFlg->ClearAll();
scAlfhInvFlg->AddItems("1-未操作","1");
scAlfhInvFlg->AddItems("2-已出库","2");
scAlfhInvFlg->AddItems("3-已入库","3");
//Alfd
FillComboBox(scAlfdUnit,"SELECT UnitName memo,UnitCode,UnitRate FROM sdUnit Order by UnitCode ","Memo","UnitCode","UnitRate");
FillComboBox(scAlfdSBatch,"SELECT BatchCode FROM sdBatch order by BatchCode","BatchCode");
FillComboBox(scAlfdDBatch,"SELECT BatchCode FROM sdBatch order by BatchCode","BatchCode");
FillComboBox(scAlfdOLoc,"select locname memo,loccode from sdloc order by loccode","memo","LocCode");
FillComboBox(scAlfdILoc,"select locname memo,loccode from sdloc order by LocCode","memo","LocCode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::ClearControl(int Section,bool BringToNext)
{
if (Section == 1)
{
if (!BringToNext)
{
seAlfhCode->Text ="";
deAlfhDate->Text =g_sdCurDate;
scAlfhFmonth->Text=g_sdIMonth;
scAlfhPosType->ItemIndex =-1;
scAlfhPosType->Text="";
scAlfhType->ItemIndex =0;
scAlfhInvFlg->ItemIndex =0;
scAlfhODept->ItemIndex =-1;
scAlfhODept->Text="";
scAlfhIDept->ItemIndex =-1;
scAlfhIDept->Text="";
labAlfhUser->Caption =g_sdUserCode;
scAlfhKeeper->LocateKey(g_sdUserCode);
cbxAlfhCheck->Checked =false;
labAlfhChecker->Caption ="";
cbxAlfhCancel->Checked=false;
memAlfhDesc->Text ="";
labAlfhSysDate->Caption="";
//新增单据,工具栏使能
SetCheckToolbarStatus(false);
}
sgAlfd->RowCount=1;
}
else if (Section==2)
{
if (!BringToNext)
{
seAlfdLine->Text =AnsiString(comServer->ItemCount+1);
scAlfdOLoc->ItemIndex =-1;
scAlfdOLoc->Text ="";
scAlfdILoc->ItemIndex =-1;
scAlfdILoc->Text="";
seAlfdGoods->Text="";
pv_GoodsCode="";
labAlfdGoodsName->Caption ="";
scAlfdUnit->ItemIndex =-1;
scAlfdUnit->Text="";
seAlfdConv->Text ="1";
seAlfdQty->Text ="0.00";
seAlfdDSo->Text ="";
seAlfdDSodLine->Text="";
scAlfdDBatch->ItemIndex=-1;
scAlfdDBatch->Text="";
seAlfdSSo->Text ="";
seAlfdSSodLine->Text="";
scAlfdSBatch->ItemIndex=-1;
scAlfdSBatch->Text="";
memAlfdDesc->Text ="";
}
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::GetDataFromComObject(int Section)
{
AnsiString s;
if (Section==1)
{
seAlfhCode->Text =GetHeadValue(fiAlfhCode);
deAlfhDate->Text =GetHeadValue(fiAlfhDate);
scAlfhFmonth->Text =GetHeadValue(fiAlfhFmonth);
scAlfhPosType->LocateKey(GetHeadValue(fiAlfhPosType));
// scAlfhPosType->Text =scAlfhPosType->ItemData[0];
scAlfhType->LocateKey(GetHeadValue(fiAlfhType));
scAlfhInvFlg->LocateKey(GetHeadValue(fiAlfhInvFlg));
s=GetHeadValue(fiAlfhODept);
scAlfhODept->LocateKey(s);
// scAlfhODept->Text = scAlfhODept->ItemData[0];
s=GetHeadValue(fiAlfhIDept);
scAlfhIDept->LocateKey(s);
// scAlfhIDept->Text = scAlfhIDept->ItemData[0];
labAlfhUser->Caption =GetHeadValue(fiAlfhUser);
scAlfhKeeper->LocateKey(GetHeadValue(fiAlfhKeeper));
cbxAlfhCheck->Checked =GetHeadValue(fiAlfhCheck)=="1";
labAlfhChecker->Caption=GetHeadValue(fiAlfhChecker);
cbxAlfhCancel->Checked =GetHeadValue(fiAlfhCancel)=="1";
memAlfhDesc->Text =GetHeadValue(fiAlfhDesc);
labAlfhSysDate->Caption=GetHeadValue(fiAlfhSysDate);
//根据审核、取消状态,设置工具栏
if(GetHeadValue(fiAlfhCheck)=="1")
SetCheckToolbarStatus(true);
else
SetCheckToolbarStatus(false);
/*
if(GetHeadValue(fiAlfhCancel)=="1")
SetCancelToolbarStatus(true);
else
SetCancelToolbarStatus(false);
*/
}
else
{
seAlfdLine->Text =GetDetailValue(fiAlfdLine);
scAlfdOLoc->LocateKey(GetDetailValue(fiAlfdOLoc));
// scAlfdOLoc->Text =scAlfdOLoc->ItemData[0];
scAlfdILoc->LocateKey(GetDetailValue(fiAlfdILoc));
// scAlfdILoc->Text =scAlfdILoc->ItemData[0];
g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiAlfdGoods)));
seAlfdGoods->Text = GetGoodsValue("GoodsCode");
labAlfdGoodsName->Caption=GetGoodsValue("GoodsName");
scAlfdUnit->LocateKey(GetDetailValue(fiAlfdUnit));
seAlfdConv->Text =GetDetailValue(fiAlfdConv);
seAlfdQty->Text =GetDetailValue(fiAlfdQty);
seAlfdDSo->Text =GetDetailValue(fiAlfdDSo);
seAlfdDSodLine->Text=GetDetailValue(fiAlfdDSodLine);
scAlfdDBatch->LocateKey(GetDetailValue(fiAlfdDBatch));
seAlfdSSo->Text =GetDetailValue(fiAlfdSSo);
seAlfdSSodLine->Text=GetDetailValue(fiAlfdSSodLine);
scAlfdSBatch->LocateKey(GetDetailValue(fiAlfdSBatch));
memAlfdDesc->Text =GetDetailValue(fiAlfdDesc);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::SendDataToComObject(int Section)
{
AnsiString s;
if (Section==1)
{
SetHeadValue(fiAlfhCode,seAlfhCode->Text);
SetHeadValue(fiAlfhDate,deAlfhDate->Text);
SetHeadValue(fiAlfhFmonth,scAlfhFmonth->Text);
SetHeadValue(fiAlfhPosType,scAlfhPosType->ItemData[1]);
if(scAlfhType->ItemData[1] == "")
throw Exception("请选择调拨类型");
SetHeadValue(fiAlfhType,scAlfhType->ItemData[1]);
SetHeadValue(fiAlfhODept,scAlfhODept->ItemData[1]);
SetHeadValue(fiAlfhIDept,scAlfhIDept->ItemData[1]);
SetHeadValue(fiAlfhUser,labAlfhUser->Caption);
SetHeadValue(fiAlfhKeeper,scAlfhKeeper->ItemData[1]);
SetHeadValue(fiAlfhDesc,memAlfhDesc->Text);
}
else
{
SetDetailValue(fiAlfdCode,seAlfhCode->Text);
if(seAlfdLine->Text == "")
throw Exception("请输入调拨单行号");
SetDetailValue(fiAlfdLine,seAlfdLine->Text);
SetDetailValue(fiAlfdOLoc,scAlfdOLoc->ItemData[1]);
SetDetailValue(fiAlfdILoc,scAlfdILoc->ItemData[1]);
SetDetailValue(fiAlfdGoods,seAlfdGoods->Text);
//SetDetailValue(fiAlfdUnit,scAlfdUnit->ItemData[1]);
//if(seAlfdConv->Text == "")
// throw Exception("请输入单位转换系数");
//SetDetailValue(fiAlfdConv,seAlfdConv->Text);
if(seAlfdQty->Text == "")
throw Exception("请输入调拨数量");
SetDetailValue(fiAlfdQty,seAlfdQty->Text);
SetDetailValue(fiAlfdDSo,seAlfdDSo->Text);
if(seAlfdDSodLine->Text == "")
SetDetailValue(fiAlfdDSodLine,"0");
else
SetDetailValue(fiAlfdDSodLine,seAlfdDSodLine->Text);
SetDetailValue(fiAlfdDBatch,scAlfdDBatch->Text);
SetDetailValue(fiAlfdSSo,seAlfdSSo->Text);
if(seAlfdSSodLine->Text == "")
SetDetailValue(fiAlfdSSodLine,"0");
else
SetDetailValue(fiAlfdSSodLine,seAlfdSSodLine->Text);
SetDetailValue(fiAlfdSBatch,scAlfdSBatch->Text);
SetDetailValue(fiAlfdDesc,memAlfdDesc->Text);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::WaitUserInput(int Section)
{
if (Section ==1)
{
if(seAlfhCode->Enabled)
seAlfhCode->SetFocus();
}
else
{
sgAlfd->Visible=false;
FloatPanel2->Visible=true;
pv_GoodsCode=Trim(seAlfdGoods->Text);
SetDetail(Trim(seAlfdGoods->Text));
if(scAlfdOLoc->Enabled)
scAlfdOLoc->SetFocus();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::RefreshGridData(int mAction)
{
int i;
AnsiString ItemStr=GetItemStringToGrid();
switch(mAction)
{
case 0:
sgAlfd->AddItem(ItemStr);
break;
case 1:
i=sgAlfd->Row;
sgAlfd->AddItem(ItemStr,i);
break;
case 2:
sgAlfd->RemoveItem(sgAlfd->Row);
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmAlfh::GetItemStringToGrid()
{
AnsiString s_ItemStr;
g_sdRsGoods->LocateByKey(WideString(GetDetailValue(fiAlfdGoods)));
s_ItemStr = "\t"+GetDetailValue(fiAlfdLine)+
"\t"+GetDetailValue(fiAlfdGoods)+
"\t"+GetGoodsValue("GoodsName")+
"\t"+GetDetailValue(fiAlfdOLoc)+
"\t"+GetDetailValue(fiAlfdILoc)+
"\t"+GetDetailValue(fiAlfdUnit)+
"\t"+GetDetailValue(fiAlfdQty);
return(s_ItemStr);
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::DisplayBill()
{
if(comServer->RecordCount==0)
return;
GetDataFromComObject(1);
FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::GetBill(AnsiString BillID)
{
int iRow;
iRow=comServer->Find("AlfhCode='"+BillID+"'");
if (iRow>0) //FIND THIS BILL
{
DisplayBill();
}
else
if (ShowMessageWindow("在数据库中没有查到记录:"+BillID+",要增加吗?",mwsConfirmation)==IDYES)
{
AddHeadRecord();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmAlfh::FillGridWithData()
{
int i;
AnsiString ItemStr;
sgAlfd->RowCount=1;
if(comServer->RecordCount > 0)
for (i=0;i<comServer->ItemCount;i++)
{
comServer->LocateItemByIndex(i);
RefreshGridData(0);
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmAlfh::GetHeadValue(int Index)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -