📄 postype.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#include "PosType.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"
TfrmPosType *frmPosType;
//---------------------------------------------------------------------------
__fastcall TfrmPosType::TfrmPosType(TComponent* Owner)
: TRecBaseForm(Owner,euSdPosType,"")
{
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPosType::GetFieldValue(int FieldIndex)
{
AnsiString S;
S = ReadFieldValue(comServer,FieldIndex);
return(S);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPosType::ClearControl(bool BringToNext)
{
if(!BringToNext)
{
sePosTypeCode->Text = "";
sePosTypeName->Text = "";
memPosTypeDesc->Text = "";
scPosTypeFlg->ItemIndex = -1;
optPosTypeInc->Checked= true;
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPosType::GetDataFromComObject()
{
sePosTypeCode->Text = GetFieldValue(fiPosTypeCode);
sgPosType->LocateGrid(1,GetFieldValue(fiPosTypeCode));
sePosTypeName->Text = GetFieldValue(fiPosTypeName);
memPosTypeDesc->Text = GetFieldValue(fiPosTypeDesc);
scPosTypeFlg->LocateKey(GetFieldValue(fiPosTypeFlg));
if (GetFieldValue(fiPosTypeIncrease) == "1")
optPosTypeInc->Checked=true;
else if(GetFieldValue(fiPosTypeDecrease) == "1")
optPosTypeDec->Checked=true;
else
optPosTypeNone->Checked=true;
}
//---------------------------------------------------------------------------
void __fastcall TfrmPosType::SendDataToComObject()
{
WriteFieldValue(comServer,fiPosTypeCode, sePosTypeCode->Text);
WriteFieldValue(comServer,fiPosTypeName, sePosTypeName->Text);
WriteFieldValue(comServer,fiPosTypeDesc, memPosTypeDesc->Text);
if(scPosTypeFlg->ItemData[1] == "")
throw Exception("请选择收发类型");
WriteFieldValue(comServer,fiPosTypeFlg, scPosTypeFlg->ItemData[1]);
if (optPosTypeInc->Checked)
WriteFieldValue(comServer,fiPosTypeIncrease, "1");
else
WriteFieldValue(comServer,fiPosTypeIncrease, "0");
//------------------------
if (optPosTypeDec->Checked)
WriteFieldValue(comServer,fiPosTypeDecrease, "1");
else
WriteFieldValue(comServer,fiPosTypeDecrease, "0");
//------------------------
if (optPosTypeNone->Checked)
WriteFieldValue(comServer,fiPosTypeNone, "1");
else
WriteFieldValue(comServer,fiPosTypeNone, "0");
}
//---------------------------------------------------------------------------
void __fastcall TfrmPosType::WaitUserInput()
{
sePosTypeCode->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmPosType::GetDataToGrid()
{
AnsiString s;
s = "\t" + GetFieldValue(fiPosTypeCode) +
"\t" + GetFieldValue(fiPosTypeName) ;
if (GetFieldValue(fiPosTypeIncrease) == "1")
s = s + "\t" + "增加";
else if (GetFieldValue(fiPosTypeDecrease) == "1")
s = s + "\t" + "减少";
else
s = s + "\t" + "无影响";
return(s);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPosType::RefreshGridData(int mAction)
{
AnsiString ItemStr;
ItemStr = GetDataToGrid();
if (mAction == 0)
{
sgPosType->AddItem(ItemStr);
}
else if(mAction == 1)
{
int i = sgPosType->Row;
sgPosType->ChangeItem(ItemStr,i);
}
else if(mAction == 2)
{
sgPosType->RemoveItem(sgPosType->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPosType::FillGridWithData()
{
AnsiString ItemStr;
comServer->MoveFirst();
sgPosType->RowCount = 1;
while (comServer->Eof == 0)
{
ItemStr = GetDataToGrid();
sgPosType->AddItem(ItemStr);
comServer->MoveNext();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmPosType::InitEditControl()
{
ClientGroup->AddComponent(2,true,true,false,sgPosType,sgPosType->Name);
ClientGroup->AddComponent(2,false,false,true,FloatPanel1,FloatPanel1->Name);
// ClientGroup->AddComponent(2,false,false,false,sePosTypeCode,sePosTypeCode->Name);
scPosTypeFlg->AddItems("1-采购类型","1");
scPosTypeFlg->AddItems("2-销售类型","2");
scPosTypeFlg->AddItems("3-制造类型","3");
scPosTypeFlg->AddItems("4-委外类型","4");
scPosTypeFlg->AddItems("5-来料类型","5");
scPosTypeFlg->AddItems("6-库存类型","6");
scPosTypeFlg->AddItems("7-质检类型","7");
}
//---------------------------------------------------------------------------
void __fastcall TfrmPosType::FormShow(TObject *Sender)
{
ClearControl(false);
FillGridWithData();
comServer->MoveFirst();
GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPosType::FormClose(TObject *Sender,
TCloseAction &Action)
{
TRecBaseForm::FormClose(Sender,Action);
//AnsiString FormIniFile = "D:\Test.Ini";
//WriteGridWidth(Name,sgPosType,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPosType::FormCreate(TObject *Sender)
{
//AnsiString FormIniFile="D:\Test.Ini";
//SetGridWidth(Name,sgPosType,FormIniFile);
}
//---------------------------------------------------------------------------
void __fastcall TfrmPosType::sgPosTypeClick(TObject *Sender)
{
int ARow=sgPosType->Row;
if (ARow > 0)
comServer->LocateByKey(WideString(sgPosType->TextMatrix[ARow][1]));
if (!comServer->Eof)
GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmPosType::sePosTypeCodeExit(TObject *Sender)
{
if(CurrentState==caNormal)
{
comServer->LocateByKey(WideString(sePosTypeCode->Text));
GetDataFromComObject();
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -