Define variables:
Private Const String SQL _select_body_byid = " Select * From health_t_layout where layoutid = @ layoutid " ;
Private Const String Parm_entity_layoutid = " @ Layoutid " ;
Private Const String Parm_entity_layoutcols = " @ Layoutcols " ;
Private Const String Parm_entity_layoutrows = " @ Layoutrows " ;
Private Const String Parm_entity_widthpercent = " @ Widthpercent " ;
Private Const String Parm_entity_remark = " @ Remark " ;
Obtain object classes
# Region Obtain the layout Object Class Based on the layout ID.
/// <Summary>
/// Obtain the layout Object Class Based on the layout ID.
/// </Summary>
/// <Param name = "questionid"> Layout ID </Param>
/// <Returns> Layout entity class </Returns>
Public Static Entitylayout getentitylayoutbyid ( Int Layoutid)
{
Sqlconnection myconn = DB. getcon ();
Try
{
Myconn. open ();
Sqlcommand mycomm = New Sqlcommand (SQL _select_body_byid, myconn );
Sqlparameter parm_layoutid = New Sqlparameter (parm_entity_layoutid, sqldbtype. Int, 4 );
Parm_layoutid.value = Layoutid;
Mycomm. Parameters. Add (parm_layoutid );
Sqldatareader SDR = Mycomm. executereader ();
While (SDR. Read ())
{
Entitylayout = New Entitylayout ();
Entitylayout. layoutcols = (SDR [ " Layoutcols " ] = Dbnull. value) ? 0 : Convert. toint32 (SDR [ " Layoutcols " ]);
Entitylayout. layoutid = (SDR [ " Layoutid " ] = Dbnull. value) ? 0 : Convert. toint32 (SDR [ " Layoutid " ]);
Entitylayout. layoutrows = (SDR [ " Layoutrows " ] = Dbnull. value) ? 0 : Convert. toint32 (SDR [ " Layoutrows " ]);
Entitylayout. widthpercent = (SDR [ " Widthpercent " ] = Dbnull. value) ? 0 : Convert. toint32 (SDR [ " Widthpercent " ]);
Entitylayout. remark = (SDR [ " Remark " ] = Dbnull. value) ? String . Empty: Convert. tostring (SDR [ " Remark " ]);
Entitylayout. Status = (SDR [ " Status " ] = Dbnull. value) ? False : Convert. toboolean (Dr [ " Status " ]);
Return Entitylayout;
}
SDR. Close ();
SDR. Dispose ();
}
Catch
{
Return Null ;
}
Finally
{
DB. Close (myconn );
}
Return Null ;
}
# Endregion