📄 qcm.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Qcm.h"
#include "WnQuery.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "RecBaseForm"
#pragma link "fpanel"
#pragma link "SDEdit"
#pragma link "SDGrid"
#pragma link "SDComboBox"
#pragma resource "*.dfm"
TfrmQcm *frmQcm;
//---------------------------------------------------------------------------
__fastcall TfrmQcm::TfrmQcm(TComponent* Owner)
: TRecBaseForm(Owner,euSdQcm,"")
{
}
AnsiString __fastcall TfrmQcm::GetFieldValue(int FieldIndex)
{
return this->comServer->FieldValue[FieldIndex];
}
AnsiString __fastcall TfrmQcm::GetDataToGrid()
{
AnsiString Str;
Str = "\t"+this->comServer->FieldValue[fiQcmCode]+"\t"+
this->comServer->FieldValue[fiQcmTel]+"\t"+
this->comServer->FieldValue[fiQcmBeepPage];
return Str;
}
void __fastcall TfrmQcm::ClearControl(bool BringToNext)
{
if(!BringToNext)
{
seQcmCode->Text = "";
seQcmTel->Text = "";
seQcmBeepPage->Text = "";
}
}
void __fastcall TfrmQcm::GetDataFromComObject()
{
seQcmCode->LocateKey(this->comServer->FieldValue[fiQcmCode]);
seQcmTel->Text = this->comServer->FieldValue[fiQcmTel];
seQcmBeepPage->Text= this->comServer->FieldValue[fiQcmBeepPage];
sgQcm->LocateGrid(1,seQcmCode->ItemData[1]);
}
void __fastcall TfrmQcm::SendDataToComObject()
{
this->comServer->FieldValue[fiQcmCode] = seQcmCode->ItemData[1];
this->comServer->FieldValue[fiQcmTel] = seQcmTel->Text;
this->comServer->FieldValue[fiQcmBeepPage] = seQcmBeepPage->Text;
}
void __fastcall TfrmQcm::WaitUserInput()
{
switch(CurrentState)
{
case caAddHead:
case caAddDetail:
seQcmCode->SetFocus();
break;
case caEditHead:
case caEditDetail:
seQcmTel->SetFocus();
break;
default:
break;
}
}
void __fastcall TfrmQcm::RefreshGridData(int mAction)
{
AnsiString Str;
Str = GetDataToGrid();
if(mAction==0) //--add item
{
sgQcm->AddItem(Str);
}else if(mAction==1) //--modify item
{
sgQcm->ChangeItem(Str,sgQcm->Row);
}else if(mAction==2) //--delete item
{
sgQcm->RemoveItem(sgQcm->Row);
}
sgQcm->LocateGrid(1,seQcmCode->ItemData[1]);
}
void __fastcall TfrmQcm::FillGridWithData()
{
sgQcm->RowCount = 1;
comServer->MoveFirst();
while(comServer->Eof == 0)
{
sgQcm->AddItem(GetDataToGrid());
comServer->MoveNext();
}
comServer->MoveFirst();
GetDataFromComObject();
}
void __fastcall TfrmQcm::InitEditControl()
{
ClientGroup->AddComponent(2,true,true,false,
sgQcm,sgQcm->Name);
ClientGroup->AddComponent(2,false,true,true,
seQcmCode,seQcmCode->Name);
ClientGroup->AddComponent(2,false,false,true,
seQcmTel,seQcmTel->Name);
ClientGroup->AddComponent(2,false,false,true,
seQcmBeepPage,seQcmBeepPage->Name);
FillEdit(seQcmCode,"select usermsg=usercode+space(18-len(usercode))+'|'+username,usercode from sduser order by usercode","Usermsg","Usercode");
}
//---------------------------------------------------------------------------
void __fastcall TfrmQcm::sgQcmClick(TObject *Sender)
{
if (sgQcm->Row > 0)
comServer->LocateByKey(WideString(sgQcm->TextMatrix[sgQcm->Row][1]));
if (!comServer->Eof)
GetDataFromComObject();
}
//---------------------------------------------------------------------------
void __fastcall TfrmQcm::FormShow(TObject *Sender)
{
comServer->Query();
FillGridWithData();
}
//---------------------------------------------------------------------------
void __fastcall TfrmQcm::RefreshUpdateData(int MsgSrc,int MsgType)
{
switch(MsgSrc)
{
case euSdUser:
if(ShowUpdateMessage(MsgSrc,MsgType))
FillEdit(seQcmCode,"select usermsg=usercode+space(18-len(usercode))+'|'+username,usercode from sduser order by usercode","Usermsg","Usercode");
break;
default:
break;
}
}
void __fastcall TfrmQcm::seQcmCodeButtonClick(TObject *Sender)
{
AnsiString SqlStr;
SqlStr="004[用户代码][用户名称][说明][部门]";
SqlStr+="select UserCode,UserName,UserDesc,isnull(DeptName,'') from sdUser";
SqlStr+=" left outer join sdDept on UserDept=DeptCode";
SqlStr+=" where UserCode not in (select QcmCode from sdQcm)";
TfrmWnQuery *p;
try
{
StartWaitForm("正在查询,请稍候...");
p=new TfrmWnQuery(this,"系统用户查询",SqlStr);
}
__finally
{
EndWaitForm();
}
if(p->ShowModal()==mrOk)
{
seQcmCode->LocateKey(p->ColData[1]);
}
delete p;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -