📄 lop.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Lop.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "fpanel"
#pragma link "RecBaseForm"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "DateEdit"
#pragma link "SDComboBox"
#pragma resource "*.dfm"
TfrmLop *frmLop;
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmLop::GetFieldValue(int FieldIndex)
{
WideString S;
S = ReadFieldValue(comServer,FieldIndex);
return(S);
}
//---------------------------------------------------------------------------
void __fastcall TfrmLop::ClearControl(bool BringToNext)
{
if(!BringToNext)
{
seLopCode->Text="";
memLopDesc->Text="";
scLopEmployee->Text="";
scLopMgr->Text="";
deLopAdate->Text=g_sdCurDate;
deLopRdate->Text="";
deLopLdate->Text="";
deLopCdate->Text="";
scLopState->ItemIndex=1;
scLopLr->ItemIndex=-1;
seLopUser->LocateKey(g_sdUserCode);
lbLopSysDate->Caption="";
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmLop::GetDataFromComObject()
{
seLopCode->Text=GetFieldValue(fiLopCode);
memLopDesc->Text=GetFieldValue(fiLopDesc);
scLopEmployee->LocateKey(GetFieldValue(fiLopEmployee));
scLopEmployee->Text=scLopEmployee->ItemData[cbItem1];
scLopMgr->Text=GetFieldValue(fiLopMgr);
deLopAdate->Text=GetFieldValue(fiLopAdate);
deLopRdate->Text=GetFieldValue(fiLopRdate);
deLopLdate->Text=GetFieldValue(fiLopLdate);
deLopCdate->Text=GetFieldValue(fiLopCdate);
scLopState->LocateKey(GetFieldValue(fiLopState));
scLopLr->LocateKey(GetFieldValue(fiLopLr));
seLopUser->LocateKey(GetFieldValue(fiLopUser));
lbLopSysDate->Caption=GetFieldValue(fiLopSyaDate);
sgLop->LocateGrid(1,seLopCode->Text);
}
//---------------------------------------------------------------------------
void __fastcall TfrmLop::SendDataToComObject()
{
WriteFieldValue(comServer,fiLopCode,WideString(seLopCode->Text));
WriteFieldValue(comServer,fiLopEmployee,WideString(scLopEmployee->ItemData[cbItem2]));
WriteFieldValue(comServer,fiLopMgr,WideString(scLopMgr->Text));
WriteFieldValue(comServer,fiLopAdate,WideString(deLopAdate->Text));
WriteFieldValue(comServer,fiLopRdate,WideString(deLopRdate->Text));
WriteFieldValue(comServer,fiLopLdate,WideString(deLopLdate->Text));
WriteFieldValue(comServer,fiLopCdate,WideString(deLopCdate->Text));
WriteFieldValue(comServer,fiLopState,WideString(scLopState->ItemData[cbItem2]));
WriteFieldValue(comServer,fiLopUser,WideString(g_sdUserCode/*lbLopUser->Caption*/));
WriteFieldValue(comServer,fiLopDesc,WideString(memLopDesc->Text));
WriteFieldValue(comServer,fiLopLr,WideString(scLopLr->ItemData[cbItem2]));
}
//---------------------------------------------------------------------------
void __fastcall TfrmLop::WaitUserInput()
{
if(seLopCode->Enabled)
seLopCode->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmLop::GetDataToGrid()
{
AnsiString s;
s = "\t" + GetFieldValue(fiLopCode)+
"\t" + GetFieldValue(fiLopEmployee)+
"\t" + GetFieldValue(fiLopAdate)+
"\t" + GetFieldValue(fiLopLdate);
return(s);
}
//---------------------------------------------------------------------------
void __fastcall TfrmLop::RefreshGridData(int mAction)
{
AnsiString ItemStr;
ItemStr = GetDataToGrid();
// 新增
if (mAction == 0)
{
sgLop->AddItem(ItemStr);
sgLop->Row=sgLop->RowCount-1;
}
// 修改
else if(mAction == 1)
{
sgLop->ChangeItem(ItemStr,sgLop->Row);
}
// 删除
else if(mAction == 2)
{
sgLop->RemoveItem(sgLop->Row);
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmLop::FillGridWithData()
{
AnsiString ItemStr;
comServer->MoveFirst();
sgLop->RowCount = 1;
while (comServer->Eof == 0)
{
ItemStr =GetDataToGrid();
sgLop->AddItem(ItemStr);
comServer->MoveNext();
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmLop::InitEditControl()
{
ClientGroup->AddComponent(2,true,true,false, sgLop,sgLop->Name);
ClientGroup->AddComponent(2,false,false,true, FloatPanel1,FloatPanel1->Name);
ClientGroup->AddComponent(2,false,true,true, scLopEmployee,scLopEmployee->Name);
ClientGroup->AddComponent(2,true,true,true, scLopState,scLopState->Name);
ClientGroup->AddComponent(2,false,true,false, seLopCode,seLopCode->Name);
FillComboBox(scLopEmployee,"select Employee=EmployeeCode+'|'+EmployeeName,EmployeeCode from sdEmployee","Employee","EmployeeCode");
FillComboBox(scLopLr,"select LrCode,LrDesc from sdLr","LrDesc","LrCode");
FillEdit(seLopUser,"select UserCode,UserName from SdUser","UserName","UserCode");
scLopState->ClearAll();
scLopState->AddItems("预备态","1");
scLopState->AddItems("确认态","2");
scLopState->AddItems("待下达","3");
scLopState->AddItems("已下达","4");
scLopState->AddItems("已完成","5");
}
//---------------------------------------------------------------------------
__fastcall TfrmLop::TfrmLop(TComponent* Owner)
: TRecBaseForm(Owner,euSdLop,"")
{
AutoCtl=seLopCode;
}
//---------------------------------------------------------------------------
void __fastcall TfrmLop::FormShow(TObject *Sender)
{
FillGridWithData();
ClearControl(false);
comServer->MoveFirst();
GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmLop::sgLopClick(TObject *Sender)
{
if (sgLop->Row > 0)
comServer->LocateByKey(WideString(sgLop->TextMatrix[sgLop->Row][1]));
if (!comServer->Eof)
GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmLop::RefreshUpdateData(int MsgSrc,int MsgType)
{
/* if(MsgSrc==euSdEmployee)
if(ShowUpdateMessage(MsgSrc,MsgType))
FillComboBox(scLopEmployee,"select Employee=EmployeeCode+'|'+EmployeeName,EmployeeCode from sdEmployee","Employee","EmployeeCode");*/
if(MsgSrc==euSdLr)
if(ShowUpdateMessage(MsgSrc,MsgType))
FillComboBox(scLopLr,"select LrCode,LrDesc from sdLr","LrDesc","LrCode");
}
void __fastcall TfrmLop::seLopCodeKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if(Key==13 && CurrentState==caNormal)
{
comServer->LocateByKey(WideString(seLopCode->Text));
GetDataFromComObject();
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -