📄 dbmsexampleform.cpp
字号:
/*
-----------------------------------------------------------------------------
CDBMSexampleForm::ProcessCommandL( TInt aCommandId )
Description: processes commands in the form
Comments:
Return values: N/A
-----------------------------------------------------------------------------
*/
void CDBMSexampleForm::ProcessCommandL( TInt aCommandId )
{
CAknForm::ProcessCommandL( aCommandId );
}
/*
-----------------------------------------------------------------------------
CDBMSexampleForm::ConfigurePopfieldValueL()
Description: configures the popup fields
Comments:
Return values: N/A
-----------------------------------------------------------------------------
*/
void CDBMSexampleForm::ConfigurePopfieldValueL()
{
DiscardArrays();
CAknPopupField* popup[ 1 ];
popup[ 0 ] = NULL;
TInt controlId( EAknPopFieldDlgCtrlIdText_Sex );
CCoeControl* control = ControlOrNull( controlId );
if ( control )
{
popup[ 0 ] = STATIC_CAST( CAknPopupField*, control );
}
// Create text array.
iTextArray = iCoeEnv->ReadDesCArrayResourceL(
R_AKNPOPFIELD_SEX_TEXT_ARRAY );
iValueTextArray = CAknQueryValueTextArray::NewL();
iValueTextArray->SetArray( *iTextArray );
// Set the same array into all the values, and initial value index.
iTextValues[ 0 ] = CAknQueryValueText::NewL();
iTextValues[ 0 ]->SetArrayL( iValueTextArray );
iTextValues[ 0 ]->SetCurrentValueIndex( iSex );
iTextValues[ 0 ]->SetQueryCaption( R_AKNPOPFIELD_QUERY_PROMPT );
// Set values into popup fields.
popup[ 0 ]->SetQueryValueL( iTextValues[ 0 ] );
}
/*
-----------------------------------------------------------------------------
CDBMSexampleForm::DiscardArrays()
Description: discards the arrays for the popup fields
Comments:
Return values: N/A
-----------------------------------------------------------------------------
*/
void CDBMSexampleForm::DiscardArrays()
{
if ( iTextArray )
{
delete iTextArray;
iTextArray = NULL;
}
if ( iValueTextArray )
{
delete iValueTextArray;
iValueTextArray = NULL;
}
if ( iTextValues[ 0 ] )
{
delete iTextValues[ 0 ];
iTextValues[ 0 ] = NULL;
}
}
/*
-----------------------------------------------------------------------------
CDBMSexampleForm::OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType)
Description: processes key input
Comments:
Return values: whether the key has been processed or not.
-----------------------------------------------------------------------------
*/
TKeyResponse CDBMSexampleForm::OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType)
{
if ( aType != EEventKey )
return EKeyWasNotConsumed;
return CAknForm::OfferKeyEventL( aKeyEvent, aType );
}
/*
-----------------------------------------------------------------------------
CDBMSexampleForm::GetSex()
Description: Get the sex value
Comments:
Return values: sex value
-----------------------------------------------------------------------------
*/
TInt CDBMSexampleForm::GetSex() const
{
return iSex;
}
/*
-----------------------------------------------------------------------------
CDBMSexampleForm::SetSex(TInt aSex)
Description: set the sex value
Comments:
Return values: N/A
-----------------------------------------------------------------------------
*/
void CDBMSexampleForm::SetSex(TInt aSex)
{
iSex = aSex;
}
/*
-----------------------------------------------------------------------------
CDBMSexampleForm::GetPersonalId()
Description: get the personal Id
Comments:
Return values: personal id
-----------------------------------------------------------------------------
*/
TInt CDBMSexampleForm::GetPersonalId() const
{
return iNumberId;
}
/*
-----------------------------------------------------------------------------
CDBMSexampleForm::SetPersonalId(TInt aPersonalId)
Description: set the personal id
Comments:
Return values: N/A
-----------------------------------------------------------------------------
*/
void CDBMSexampleForm::SetPersonalId(TInt aPersonalId)
{
iNumberId = aPersonalId;
}
/*
-----------------------------------------------------------------------------
CDBMSexampleForm::GetName(TDes& aName)
Description: get name
Comments:
Return values: N/A
-----------------------------------------------------------------------------
*/
void CDBMSexampleForm::GetName(TDes& aName) const
{
aName = iEdwinName;
}
/*
-----------------------------------------------------------------------------
CDBMSexampleForm::SetName(TDes& aName)
Description: set name
Comments:
Return values: N/A
-----------------------------------------------------------------------------
*/
void CDBMSexampleForm::SetName(TDes& aName)
{
iEdwinName = aName;
}
/*
-----------------------------------------------------------------------------
CDBMSexampleForm::GetBirthday( )
Description: get birthday
Comments:
Return values: birthday value
-----------------------------------------------------------------------------
*/
TTime& CDBMSexampleForm::GetBirthday( )
{
return iDateBirth;
}
/*
-----------------------------------------------------------------------------
CDBMSexampleForm::SetBirthday( TTime aTTime )
Description: set birthday
Comments:
Return values: birthday value
-----------------------------------------------------------------------------
*/
void CDBMSexampleForm::SetBirthday( TTime aTTime )
{
iDateBirth = aTTime;
}
/*
-----------------------------------------------------------------------------
CDBMSexampleForm::CreateRecordL( )
Description: create a record
Comments:
Return values: N/A
-----------------------------------------------------------------------------
*/
void CDBMSexampleForm::CreateRecordL( )
{
// Get the data from form, and pass them into engine.
_LIT( KFormatDate, "%d%+02d%+02d:000000.000000");
TBuf<30> buf;
TDateTime datetime = iDateBirth.DateTime();
buf.Format( KFormatDate, datetime.Year(), datetime.Month(), datetime.Day());
iEngine->SetBirthday( buf );
iEngine->SetName( iEdwinName );
iEngine->SetPersonalId( iNumberId );
iEngine->SetSex( iSex );
// Now create the record
iEngine->AddRecordL();
}
/*
-----------------------------------------------------------------------------
CDBMSexampleForm::UpdateRecordL( )
Description: Update a record
Comments:
Return values: N/A
-----------------------------------------------------------------------------
*/
void CDBMSexampleForm::UpdateRecordL( )
{
iEngine->SetName( iEdwinName );
_LIT( KFormatDate, "%d%+02d%+02d:000000.000000");
TBuf<30> buf;
TDateTime datetime = iDateBirth.DateTime();
buf.Format( KFormatDate, datetime.Year(), datetime.Month(), datetime.Day());
iEngine->SetBirthday( buf );
iEngine->SetPersonalId( iNumberId );
iEngine->SetSex( iSex );
// Now Update the record
iEngine->UpdateRecordL();
}
/*
-----------------------------------------------------------------------------
CDBMSexampleCreateView::DeleteRecordL(CAknFormSaveForm *form)
Description: Delets a record
Comments:
Return values: N/A
-----------------------------------------------------------------------------
*/
void CDBMSexampleForm::DeleteRecordL( )
{
// We have to get the name first from the form, and the name is used to
// index into the database to remove a the specified reocord
iEngine->SetName( iEdwinName );
// Remove the record from database
iEngine->DeleteRecordL();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -