📄 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;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
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=0;
scLopLr->ItemIndex=-1;
seLopUser->LocateKey(g_sdUserCode);
lbLopSysDate->Caption="";
}
}
//---------------------------------------------------------------------------
void __fastcall TfrmLop::GetDataFromComObject()
{
seLopCode->Text=GetFieldValue("LopCode");
memLopDesc->Text=GetFieldValue("LopDesc");
scLopEmployee->LocateKey(GetFieldValue("LopEmployee"));
scLopEmployee->Text=scLopEmployee->ItemData[cbItem1];
scLopMgr->Text=GetFieldValue("LopMgr");
deLopAdate->Text=GetFieldValue("LopAdate");
deLopRdate->Text=GetFieldValue("LopRdate");
deLopLdate->Text=GetFieldValue("LopLdate");
deLopCdate->Text=GetFieldValue("LopCdate");
scLopState->LocateKey(GetFieldValue("LopState"));
scLopLr->LocateKey(GetFieldValue("LopLr"));
seLopUser->LocateKey(GetFieldValue("LopUser"));
lbLopSysDate->Caption=GetFieldValue("LopSyaDate");
sgLop->LocateGrid(1,seLopCode->Text);
}
//---------------------------------------------------------------------------
void __fastcall TfrmLop::SendDataToComObject()
{
SetFieldValue("LopCode",WideString(seLopCode->Text));
SetFieldValue("LopEmployee",WideString(scLopEmployee->ItemData[cbItem2]));
SetFieldValue("LopMgr",WideString(scLopMgr->Text));
SetFieldValue("LopAdate",WideString(deLopAdate->Text));
SetFieldValue("LopRdate",WideString(deLopRdate->Text));
SetFieldValue("LopLdate",WideString(deLopLdate->Text));
SetFieldValue("LopCdate",WideString(deLopCdate->Text));
SetFieldValue("LopState",WideString(scLopState->ItemData[cbItem2]));
SetFieldValue("LopUser",WideString(g_sdUserCode/*lbLopUser->Caption*/));
SetFieldValue("LopDesc",WideString(memLopDesc->Text));
SetFieldValue("LopLr",WideString(scLopLr->ItemData[cbItem2]));
}
//---------------------------------------------------------------------------
void __fastcall TfrmLop::WaitUserInput()
{
if(seLopCode->Enabled)
seLopCode->SetFocus();
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmLop::GetDataToGrid()
{
AnsiString s;
s = "\t" + GetFieldValue("LopCode")+
"\t" + GetFieldValue("LopEmployee")+
"\t" + GetFieldValue("LopAdate")+
"\t" + GetFieldValue("LopLdate");
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(Handle,scLopEmployee,"select Employee=EmployeeCode+'|'+EmployeeName,EmployeeCode from sdEmployee where EmployeeState <>1 order by EmployeeCode ","Employee","EmployeeCode");
FillComboBox(Handle,scLopLr,"select LrCode,LrDesc from sdLr","LrDesc","LrCode");
FillEdit(Handle,seLopUser,"select UserCode,UserName from SdUser","UserName","UserCode");
scLopState->ClearAll();
scLopState->AddItems("预备态","0");
scLopState->AddItems("确认态","1");
}
//---------------------------------------------------------------------------
__fastcall TfrmLop::TfrmLop(TComponent* Owner, HWND chWnd, AnsiString MidCode,AnsiString WhereStr)
: TRecBaseForm(Owner,chWnd,MidCode,WhereStr)
{
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)
{
}
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 + -